Skip to content

Commit fa9c5ed

Browse files
authored
Merge pull request #2 from rspec-parameterized/setup_ci
Setup CI
2 parents b482003 + ba390ee commit fa9c5ed

File tree

13 files changed

+206
-402
lines changed

13 files changed

+206
-402
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/rspec.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: RSpec
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
ruby-version:
16+
- '2.6'
17+
- '2.7'
18+
- '3.0'
19+
- '3.1'
20+
- '3.2'
21+
22+
steps:
23+
- uses: actions/checkout@v3
24+
- name: Set up Ruby
25+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
26+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
27+
uses: ruby/setup-ruby@v1
28+
with:
29+
ruby-version: ${{ matrix.ruby-version }}
30+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
31+
- name: Run tests
32+
run: bundle exec rake

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@
99

1010
# rspec failure tracking
1111
.rspec_status
12+
13+
Gemfile.lock

.rubocop.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

Gemfile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,3 @@ source "https://rubygems.org"
44

55
# Specify your gem's dependencies in rspec-parameterized-table_syntax.gemspec
66
gemspec
7-
8-
gem "rake", "~> 13.0"
9-
10-
gem "rspec", "~> 3.0"
11-
12-
gem "rubocop", "~> 1.21"

Rakefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,4 @@ require "rspec/core/rake_task"
55

66
RSpec::Core::RakeTask.new(:spec)
77

8-
require "rubocop/rake_task"
9-
10-
RuboCop::RakeTask.new
11-
12-
task default: %i[spec rubocop]
8+
task default: %i[spec]

lib/rspec/parameterized/table.rb

Lines changed: 0 additions & 49 deletions
This file was deleted.

lib/rspec/parameterized/table_syntax.rb

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,13 @@
11
# frozen_string_literal: true
22

3-
require_relative "table_syntax/version"
4-
require 'rspec/parameterized/table'
3+
require "rspec/parameterized/table_syntax/version"
4+
require 'rspec/parameterized/table_syntax/table'
5+
require 'rspec/parameterized/table_syntax/table_syntax_implement'
6+
require "rspec/parameterized/core"
57
require 'binding_of_caller'
68

79
module RSpec
810
module Parameterized
9-
module TableSyntaxImplement
10-
def |(other)
11-
where_binding = binding.of_caller(1) # get where block binding
12-
caller_instance = eval("self", where_binding) # get caller instance (ExampleGroup)
13-
14-
if caller_instance.instance_variable_defined?(:@__parameter_table)
15-
table = caller_instance.instance_variable_get(:@__parameter_table)
16-
else
17-
table = RSpec::Parameterized::Table.new
18-
caller_instance.instance_variable_set(:@__parameter_table, table)
19-
end
20-
21-
row = Table::Row.new(self)
22-
table.add_row(row)
23-
row.add_param(other)
24-
table
25-
end
26-
end
27-
2811
module TableSyntax
2912
if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create("3.2.0.rc1")
3013
refine Object do
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
module RSpec
2+
module Parameterized
3+
module TableSyntax
4+
class Table
5+
attr_reader :last_row
6+
7+
def initialize
8+
@rows = []
9+
@last_row = nil
10+
end
11+
12+
def add_row(row)
13+
unless @rows.find {|r| r.object_id == row.object_id}
14+
@rows << row
15+
@last_row = row
16+
end
17+
self
18+
end
19+
20+
def add_param_to_last_row(param)
21+
last_row.add_param(param)
22+
self
23+
end
24+
alias :| :add_param_to_last_row
25+
26+
def to_a
27+
@rows.map(&:to_a)
28+
end
29+
alias :to_params :to_a
30+
31+
class Row
32+
def initialize(param)
33+
@params = [param]
34+
end
35+
36+
def add_param(param)
37+
@params << param
38+
end
39+
40+
def to_a
41+
@params
42+
end
43+
44+
def to_params
45+
[@params]
46+
end
47+
end
48+
end
49+
end
50+
end
51+
end
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module RSpec
2+
module Parameterized
3+
module TableSyntax
4+
module TableSyntaxImplement
5+
def |(other)
6+
where_binding = binding.of_caller(1) # get where block binding
7+
caller_instance = eval("self", where_binding) # get caller instance (ExampleGroup)
8+
9+
if caller_instance.instance_variable_defined?(:@__parameter_table)
10+
table = caller_instance.instance_variable_get(:@__parameter_table)
11+
else
12+
table = RSpec::Parameterized::TableSyntax::Table.new
13+
caller_instance.instance_variable_set(:@__parameter_table, table)
14+
end
15+
16+
row = Table::Row.new(self)
17+
table.add_row(row)
18+
row.add_param(other)
19+
table
20+
end
21+
end
22+
end
23+
end
24+
end

0 commit comments

Comments
 (0)