rspec-parameterized 0.5.3 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0394579cf5005becd6e7b94186ea47ba37aee0440ea354483b4d2fde7acc2a24'
4
- data.tar.gz: 7f0bcb5613a91aba4c460dea82ad59c603563c83f87e6b907816fbaa202b2934
3
+ metadata.gz: f0297d4fdb64af8cc3a01fb4e9b87bb13089382502e0bd9b166b4d0f809fa39e
4
+ data.tar.gz: b6d184b0ed068b1bc009bcf84a8735eba6a36cea053df5f9049518f9fc7ed0b6
5
5
  SHA512:
6
- metadata.gz: 744d46bd1d4180c2fc884681e95c84314593af287278a61eeeb0d3ceb1d4400a1d2322c35ae3bbcc74a5fc650e65c4d4e87c5fda0e03b6e87c7af63ab292adb8
7
- data.tar.gz: f71bbf3fb4f4e7e35a6ab23e1d2be5f266abec76f3279af6dc5aeb75ac5bbc66c9ddd9368a7978bee54a099595cca26ac8bac29eda8cc5268492dac8115b79ae
6
+ metadata.gz: e25ca54ba93879ebb9aa84651c843807370b1084aadc07e2ae7e2fc72e054ba2ef81a78e12b42fca4ece6ad5302e02c6e11f198ae046cc740306bba6111d7ffc
7
+ data.tar.gz: c763de06b61b28093c9c5d8a09a16abfe689a84ee80de035241099e54176d450465aaa409f4ba142c342157ad67c88a5ed95563e5fdb19e782c91925f4c516b0
data/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
  ## Unreleased
3
3
  [Full Changelog](https://github.com/tomykaira/rspec-parameterized/compare/v0.5.3...master)
4
4
 
5
+ - Split gems
6
+ - https://github.com/tomykaira/rspec-parameterized/issues/82
7
+ - https://github.com/tomykaira/rspec-parameterized/pull/83
8
+
9
+ See also
10
+
11
+ - [Upgrading Guide](UPGRADING.md#v10)
12
+ - https://github.com/rspec-parameterized/rspec-parameterized-table_syntax/blob/main/CHANGELOG.md#100---2022-12-31
13
+ - https://github.com/rspec-parameterized/rspec-parameterized-core/blob/main/CHANGELOG.md#100---2022-12-31
14
+
5
15
  ## [v0.5.3](https://github.com/tomykaira/rspec-parameterized/tree/v0.5.3) (2022-12-29)
6
16
  [Full Changelog](https://github.com/tomykaira/rspec-parameterized/compare/v0.5.2...v0.5.3)
7
17
 
data/README.md CHANGED
@@ -182,18 +182,11 @@ I was inspired by [udzura's mock](https://gist.github.com/1881139).
182
182
  Ruby-2.6.0 or later.
183
183
 
184
184
  ## Installation
185
-
186
- Add this line to your application's Gemfile:
187
-
188
- gem 'rspec-parameterized'
189
-
190
- And then execute:
191
-
192
- $ bundle
193
-
194
- Or install it yourself as:
195
-
196
- $ gem install rspec-parameterized
185
+ ```ruby
186
+ group :test do
187
+ gem "rspec-parameterized", ">= 1.0.0"
188
+ end
189
+ ```
197
190
 
198
191
  ## Usage
199
192
 
@@ -212,3 +205,8 @@ Arguments given to `with_them` is directly passed to `describe`. You can specif
212
205
  3. Commit your changes (`git commit -am 'Added some feature'`)
213
206
  4. Push to the branch (`git push origin my-new-feature`)
214
207
  5. Create new Pull Request
208
+
209
+ ## Also see
210
+
211
+ * https://github.com/rspec-parameterized/rspec-parameterized-table_syntax
212
+ * https://github.com/rspec-parameterized/rspec-parameterized-core
data/UPGRADING.md ADDED
@@ -0,0 +1,16 @@
1
+ # v1.0
2
+ Moved all implements to https://github.com/rspec-parameterized/rspec-parameterized-core and https://github.com/rspec-parameterized/rspec-parameterized-table_syntax
3
+
4
+ For v0.x users, there is basically no need to do anything other than `bundle update`.
5
+
6
+ If you are not using `RSpec::Parameterized::TableSyntax`, you can write `rspec-parameterized-core` instead of `rspec-parameterized` in your `Gemfile` to reduce the dependency.
7
+
8
+ e.g.
9
+
10
+ ```ruby
11
+ # Before
12
+ gem "rspec-parameterized"
13
+
14
+ # After
15
+ gem "rspec-parameterized-core"
16
+ ```
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module Parameterized
3
- VERSION = "0.5.3"
3
+ VERSION = "1.0.0.rc1"
4
4
  end
5
5
  end
@@ -1,178 +1,8 @@
1
1
  require "rspec/parameterized/version"
2
- require 'parser'
3
- require 'unparser'
4
- require 'proc_to_ast'
5
- require 'rspec/parameterized/helper_methods'
6
- require 'rspec/parameterized/example_helper_methods'
2
+ require "rspec/parameterized/core"
3
+ require "rspec/parameterized/table_syntax"
7
4
 
8
5
  module RSpec
9
6
  module Parameterized
10
- autoload :TableSyntax, 'rspec/parameterized/table_syntax'
11
-
12
- module ExampleGroupMethods
13
- # capsulize parameter attributes
14
- class Parameter
15
- attr_reader :arg_names, :block
16
-
17
- def initialize(arg_names, &block)
18
- @arg_names, @block = arg_names, block
19
- end
20
- end
21
-
22
- # Set parameters to be bound in specs under this example group.
23
- #
24
- # ## Example1
25
- #
26
- # where(:a, :b, :answer) do
27
- # [
28
- # [1 , 2 , 3],
29
- # [5 , 8 , 13],
30
- # [0 , 0 , 0]
31
- # ]
32
- # end
33
- #
34
- # ## Example2
35
- # using RSpec::Parameterized::TableSyntax
36
- # where(:a, :b, :answer) do
37
- # 1 | 2 | 3 >
38
- # 5 | 8 | 13 >
39
- # 0 | 0 | 0
40
- # end
41
- #
42
- def where(*args, &b)
43
-
44
- if args.size == 1 && args[0].instance_of?(Hash)
45
- naming_func = args.first.delete(:case_names)
46
- params = args[0]
47
- first, *rest = params.values
48
- arg_names = params.keys
49
- arg_values = first.product(*rest)
50
-
51
- if naming_func && naming_func.respond_to?(:call)
52
- arg_names << :case_name
53
- arg_values.map! { |row| row << naming_func.call(*row) }
54
- end
55
-
56
- set_parameters(arg_names) {
57
- arg_values
58
- }
59
- elsif args.size == 0
60
- set_verbose_parameters(&b)
61
- else
62
- set_parameters(args, &b)
63
- end
64
- end
65
-
66
- # Use parameters to execute the block.
67
- # The given block is converted into +describe+s for each parameter set.
68
- #
69
- # ## Example
70
- # with_them do
71
- # it "should do additions" do
72
- # (a + b).should == answer
73
- # end
74
- # end
75
- #
76
- def with_them(*args, &b)
77
- opts = args.last.is_a?(Hash) ? args.pop : {}
78
- opts[:caller] = caller unless opts[:caller]
79
- args.push(opts)
80
- @parameter ||= nil
81
-
82
- if @parameter.nil?
83
- @parameterized_pending_cases ||= []
84
- @parameterized_pending_cases << [args, b]
85
- else
86
- define_cases(@parameter, *args, &b)
87
- end
88
- end
89
-
90
- private
91
- def set_parameters(arg_names, &b)
92
- @parameter = Parameter.new(arg_names, &b)
93
- @parameterized_pending_cases ||= []
94
-
95
- @parameterized_pending_cases.each { |e|
96
- define_cases(@parameter, *e[0], &e[1])
97
- }
98
- end
99
-
100
- def define_cases(parameter, *args, &block)
101
- instance = new # for evaluate let methods.
102
- instance.extend HelperMethods
103
- if defined?(self.superclass::LetDefinitions)
104
- instance.extend self.superclass::LetDefinitions
105
- end
106
-
107
- extracted = instance.instance_eval(&parameter.block)
108
- param_sets = extracted.is_a?(Array) ? extracted : extracted.to_params
109
-
110
- # for only one parameters
111
- param_sets = param_sets.map { |x| Array[x] } if !param_sets[0].is_a?(Array)
112
-
113
- param_sets.each do |param_set|
114
- pairs = [parameter.arg_names, param_set].transpose.to_h
115
- pretty_params = pairs.has_key?(:case_name) ? pairs[:case_name] : pairs.map {|name, val| "#{name}: #{params_inspect(val)}"}.join(", ")
116
- describe(pretty_params, *args) do
117
- include ExampleHelperMethods
118
-
119
- pairs.each do |name, val|
120
- let(name) { recursive_apply(val) }
121
- end
122
-
123
- singleton_class.module_eval do
124
- if respond_to?(:params)
125
- warn "ExampleGroup.params method is overrided."
126
- end
127
-
128
- define_method(:params) do
129
- pairs
130
- end
131
-
132
- if respond_to?(:all_params)
133
- warn "ExampleGroup.all_params method is overrided."
134
- end
135
-
136
- define_method(:all_params) do
137
- param_sets
138
- end
139
- end
140
-
141
- module_eval(&block)
142
- end
143
- end
144
- end
145
-
146
- def params_inspect(obj)
147
- begin
148
- obj.is_a?(Proc) ? obj.to_raw_source : obj.inspect
149
- rescue Parser::SyntaxError
150
- return obj.inspect
151
- end
152
- end
153
-
154
- def set_verbose_parameters(&block)
155
- arguments_hash = yield
156
- arg_names = arguments_hash.values.reduce(Set.new) { |memo, pairs| memo | pairs.keys }.to_a
157
- arg_values = []
158
- arguments_hash.each do |name, values_hash|
159
- row = [name]
160
- arg_names.each do |argument_name|
161
- row << values_hash[argument_name]
162
- end
163
- arg_values << row
164
- end
165
- arg_names.unshift(:case_name)
166
- set_parameters(arg_names) {
167
- arg_values
168
- }
169
- end
170
- end
171
- end
172
-
173
- module Core
174
- class ExampleGroup
175
- extend ::RSpec::Parameterized::ExampleGroupMethods
176
- end
177
7
  end
178
8
  end
@@ -11,11 +11,9 @@ I was inspired by [udzura's mock](https://gist.github.com/1881139).}
11
11
 
12
12
  gem.metadata["rubygems_mfa_required"] = "true"
13
13
 
14
- gem.add_dependency('rspec', '>= 2.13', '< 4')
15
- gem.add_dependency('parser')
16
- gem.add_dependency('unparser')
17
- gem.add_dependency('proc_to_ast')
18
- gem.add_dependency('binding_of_caller')
14
+ gem.add_dependency('rspec-parameterized-core', '< 2')
15
+ gem.add_dependency('rspec-parameterized-table_syntax', '< 2')
16
+
19
17
  gem.add_development_dependency('rake', '>= 12.0.0')
20
18
 
21
19
  gem.files = `git ls-files`.split($\)
metadata CHANGED
@@ -1,91 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-parameterized
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 1.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - tomykaira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-28 00:00:00.000000000 Z
11
+ date: 2022-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rspec
14
+ name: rspec-parameterized-core
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '2.13'
20
17
  - - "<"
21
18
  - !ruby/object:Gem::Version
22
- version: '4'
19
+ version: '2'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '2.13'
30
24
  - - "<"
31
25
  - !ruby/object:Gem::Version
32
- version: '4'
33
- - !ruby/object:Gem::Dependency
34
- name: parser
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: '0'
40
- type: :runtime
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: '0'
26
+ version: '2'
47
27
  - !ruby/object:Gem::Dependency
48
- name: unparser
28
+ name: rspec-parameterized-table_syntax
49
29
  requirement: !ruby/object:Gem::Requirement
50
30
  requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: '0'
61
- - !ruby/object:Gem::Dependency
62
- name: proc_to_ast
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: '0'
68
- type: :runtime
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: '0'
75
- - !ruby/object:Gem::Dependency
76
- name: binding_of_caller
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">="
31
+ - - "<"
80
32
  - !ruby/object:Gem::Version
81
- version: '0'
33
+ version: '2'
82
34
  type: :runtime
83
35
  prerelease: false
84
36
  version_requirements: !ruby/object:Gem::Requirement
85
37
  requirements:
86
- - - ">="
38
+ - - "<"
87
39
  - !ruby/object:Gem::Version
88
- version: '0'
40
+ version: '2'
89
41
  - !ruby/object:Gem::Dependency
90
42
  name: rake
91
43
  requirement: !ruby/object:Gem::Requirement
@@ -115,17 +67,9 @@ files:
115
67
  - LICENSE
116
68
  - README.md
117
69
  - Rakefile
118
- - gemfiles/rspec-head.gemfile
119
- - gemfiles/rspec3.4.gemfile
70
+ - UPGRADING.md
120
71
  - lib/rspec-parameterized.rb
121
72
  - lib/rspec/parameterized.rb
122
- - lib/rspec/parameterized/arg.rb
123
- - lib/rspec/parameterized/example_helper_methods.rb
124
- - lib/rspec/parameterized/helper_methods.rb
125
- - lib/rspec/parameterized/lazy_arg.rb
126
- - lib/rspec/parameterized/ref_arg.rb
127
- - lib/rspec/parameterized/table.rb
128
- - lib/rspec/parameterized/table_syntax.rb
129
73
  - lib/rspec/parameterized/version.rb
130
74
  - rspec-parameterized.gemspec
131
75
  - spec/parametarized_spec.rb
@@ -145,9 +89,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
89
  version: '0'
146
90
  required_rubygems_version: !ruby/object:Gem::Requirement
147
91
  requirements:
148
- - - ">="
92
+ - - ">"
149
93
  - !ruby/object:Gem::Version
150
- version: '0'
94
+ version: 1.3.1
151
95
  requirements: []
152
96
  rubygems_version: 3.4.0.dev
153
97
  signing_key:
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem "rspec"
4
-
5
- gemspec path: "../"
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem "rspec", "~> 3.4.0"
4
-
5
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- module RSpec
2
- module Parameterized
3
- class Arg
4
- def apply(obj) ; end
5
- end
6
- end
7
- end
@@ -1,19 +0,0 @@
1
- module RSpec
2
- module Parameterized
3
- module ExampleHelperMethods
4
- def recursive_apply(val)
5
- return val.apply(self) if HelperMethods.applicable?(val)
6
-
7
- if val.is_a?(Array)
8
- return val.map { |child_val| recursive_apply(child_val) }
9
- end
10
-
11
- if val.is_a?(Hash)
12
- return val.map { |key, value| [recursive_apply(key), recursive_apply(value)] }.to_h
13
- end
14
-
15
- val
16
- end
17
- end
18
- end
19
- end
@@ -1,20 +0,0 @@
1
- require 'rspec/parameterized/ref_arg'
2
- require 'rspec/parameterized/lazy_arg'
3
- module RSpec
4
- module Parameterized
5
- module HelperMethods
6
- def ref(symbol)
7
- RefArg.new(symbol)
8
- end
9
-
10
- def lazy(&block)
11
- LazyArg.new(&block)
12
- end
13
-
14
- def self.applicable?(arg)
15
- arg.is_a? Arg
16
- end
17
- end
18
- end
19
- end
20
-
@@ -1,19 +0,0 @@
1
- module RSpec
2
- module Parameterized
3
- class LazyArg < Arg
4
- def initialize(&block)
5
- @block = block
6
- end
7
-
8
- def apply(obj)
9
- obj.instance_eval(&@block)
10
- end
11
-
12
- def inspect
13
- "#{@block.to_raw_source}"
14
- rescue Parser::SyntaxError
15
- super.inspect
16
- end
17
- end
18
- end
19
- end
@@ -1,19 +0,0 @@
1
- require 'rspec/parameterized/arg'
2
- module RSpec
3
- module Parameterized
4
- class RefArg < Arg
5
- def initialize(symbol)
6
- @symbol = symbol
7
- end
8
-
9
- def apply(obj)
10
- obj.send(@symbol)
11
- end
12
-
13
- def inspect
14
- "#{@symbol}"
15
- end
16
- end
17
- end
18
- end
19
-
@@ -1,49 +0,0 @@
1
- module RSpec
2
- module Parameterized
3
- class Table
4
- attr_reader :last_row
5
-
6
- def initialize
7
- @rows = []
8
- @last_row = nil
9
- end
10
-
11
- def add_row(row)
12
- unless @rows.find {|r| r.object_id == row.object_id}
13
- @rows << row
14
- @last_row = row
15
- end
16
- self
17
- end
18
-
19
- def add_param_to_last_row(param)
20
- last_row.add_param(param)
21
- self
22
- end
23
- alias :| :add_param_to_last_row
24
-
25
- def to_a
26
- @rows.map(&:to_a)
27
- end
28
- alias :to_params :to_a
29
-
30
- class Row
31
- def initialize(param)
32
- @params = [param]
33
- end
34
-
35
- def add_param(param)
36
- @params << param
37
- end
38
-
39
- def to_a
40
- @params
41
- end
42
-
43
- def to_params
44
- [@params]
45
- end
46
- end
47
- end
48
- end
49
- end
@@ -1,77 +0,0 @@
1
- require 'rspec/parameterized/table'
2
- require 'binding_of_caller'
3
-
4
- module RSpec
5
- module Parameterized
6
- module TableSyntaxImplement
7
- def |(other)
8
- where_binding = binding.of_caller(1) # get where block binding
9
- caller_instance = eval("self", where_binding) # get caller instance (ExampleGroup)
10
-
11
- if caller_instance.instance_variable_defined?(:@__parameter_table)
12
- table = caller_instance.instance_variable_get(:@__parameter_table)
13
- else
14
- table = RSpec::Parameterized::Table.new
15
- caller_instance.instance_variable_set(:@__parameter_table, table)
16
- end
17
-
18
- row = Table::Row.new(self)
19
- table.add_row(row)
20
- row.add_param(other)
21
- table
22
- end
23
- end
24
-
25
- module TableSyntax
26
- if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create("3.2.0.rc1")
27
- refine Object do
28
- import_methods TableSyntaxImplement
29
- end
30
-
31
- refine Integer do
32
- import_methods TableSyntaxImplement
33
- end
34
-
35
- refine Array do
36
- import_methods TableSyntaxImplement
37
- end
38
-
39
- refine NilClass do
40
- import_methods TableSyntaxImplement
41
- end
42
-
43
- refine TrueClass do
44
- import_methods TableSyntaxImplement
45
- end
46
-
47
- refine FalseClass do
48
- import_methods TableSyntaxImplement
49
- end
50
- else
51
- refine Object do
52
- include TableSyntaxImplement
53
- end
54
-
55
- refine Integer do
56
- include TableSyntaxImplement
57
- end
58
-
59
- refine Array do
60
- include TableSyntaxImplement
61
- end
62
-
63
- refine NilClass do
64
- include TableSyntaxImplement
65
- end
66
-
67
- refine TrueClass do
68
- include TableSyntaxImplement
69
- end
70
-
71
- refine FalseClass do
72
- include TableSyntaxImplement
73
- end
74
- end
75
- end
76
- end
77
- end