File tree Expand file tree Collapse file tree 13 files changed +206
-402
lines changed Expand file tree Collapse file tree 13 files changed +206
-402
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change 9
9
10
10
# rspec failure tracking
11
11
.rspec_status
12
+
13
+ Gemfile.lock
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -4,9 +4,3 @@ source "https://rubygems.org"
4
4
5
5
# Specify your gem's dependencies in rspec-parameterized-table_syntax.gemspec
6
6
gemspec
7
-
8
- gem "rake" , "~> 13.0"
9
-
10
- gem "rspec" , "~> 3.0"
11
-
12
- gem "rubocop" , "~> 1.21"
Original file line number Diff line number Diff line change @@ -5,8 +5,4 @@ require "rspec/core/rake_task"
5
5
6
6
RSpec ::Core ::RakeTask . new ( :spec )
7
7
8
- require "rubocop/rake_task"
9
-
10
- RuboCop ::RakeTask . new
11
-
12
- task default : %i[ spec rubocop ]
8
+ task default : %i[ spec ]
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
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"
5
7
require 'binding_of_caller'
6
8
7
9
module RSpec
8
10
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
-
28
11
module TableSyntax
29
12
if Gem ::Version . create ( RUBY_VERSION ) >= Gem ::Version . create ( "3.2.0.rc1" )
30
13
refine Object do
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments