rspec-parameterized 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/rspec.yml +26 -0
- data/CHANGELOG.md +15 -2
- data/README.md +5 -1
- data/lib/rspec/parameterized/example_helper_methods.rb +19 -0
- data/lib/rspec/parameterized/version.rb +1 -1
- data/lib/rspec/parameterized.rb +4 -5
- data/spec/parametarized_spec.rb +74 -24
- metadata +5 -4
- data/.travis.yml +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59435a789f542a5f80075f3dead8b2ffec470174a91b134b8a6c8cec3ae5bdc2
|
4
|
+
data.tar.gz: 5f1282e9687857cad7d18afb679779eb44c06aefe662cb743000082df4a4dece
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c719dc2e53f0d0070b76169115efa6e40b09b927f1440acd89a3cf7c7e97e7ac7f71c2dd7bbbbe139712ee4dcb0145d7d1b09475bf1103c653ba84246be2944
|
7
|
+
data.tar.gz: 181acdafb5baeec82d9e90dd3a29254f523b8432d850c6946b42d24532dc29bb80777af4a360019129062404da0685152b0841f6cc8508b382eab6583fd8d9a0
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: RSpec
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ $default-branch ]
|
6
|
+
pull_request:
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
test:
|
10
|
+
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
ruby-version: ['2.6', '2.7', '3.0', '3.1']
|
15
|
+
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v2
|
18
|
+
- name: Set up Ruby
|
19
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
20
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
21
|
+
uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: ${{ matrix.ruby-version }}
|
24
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
25
|
+
- name: Run tests
|
26
|
+
run: bundle exec rake
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,19 @@
|
|
1
1
|
# Change Log
|
2
2
|
## Unreleased
|
3
|
-
[Full Changelog](https://github.com/tomykaira/rspec-parameterized/compare/v0.
|
3
|
+
[Full Changelog](https://github.com/tomykaira/rspec-parameterized/compare/v0.5.1...master)
|
4
|
+
|
5
|
+
## [v0.5.1](https://github.com/tomykaira/rspec-parameterized/tree/v0.5.1) (2022-01-04)
|
6
|
+
[Full Changelog](https://github.com/tomykaira/rspec-parameterized/compare/v0.5.0...v0.5.1)
|
7
|
+
|
8
|
+
- Changes to apply method calls recursively when parameter is Array or Hash.
|
9
|
+
- https://github.com/tomykaira/rspec-parameterized/pull/75
|
10
|
+
|
11
|
+
## [v0.5.0](https://github.com/tomykaira/rspec-parameterized/tree/v0.5.0) (2021-06-29)
|
12
|
+
[Full Changelog](https://github.com/tomykaira/rspec-parameterized/compare/v0.4.2...v0.5.0)
|
13
|
+
|
14
|
+
- Support new parameter type: ref and lazy
|
15
|
+
- https://github.com/tomykaira/rspec-parameterized/pull/62
|
16
|
+
- https://github.com/tomykaira/rspec-parameterized/pull/65
|
4
17
|
|
5
18
|
## [v0.4.2](https://github.com/tomykaira/rspec-parameterized/tree/v0.4.2) (2019-04-26)
|
6
19
|
[Full Changelog](https://github.com/tomykaira/rspec-parameterized/compare/v0.4.1...v0.4.2)
|
@@ -163,4 +176,4 @@
|
|
163
176
|
## [v0.0.1](https://github.com/tomykaira/rspec-parameterized/tree/v0.0.1) (2012-05-20)
|
164
177
|
|
165
178
|
|
166
|
-
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
179
|
+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# RSpec::Parameterized [](https://badge.fury.io/rb/rspec-parameterized)
|
1
|
+
# RSpec::Parameterized [](https://badge.fury.io/rb/rspec-parameterized) 
|
2
2
|
|
3
3
|
Support simple parameterized test syntax in rspec.
|
4
4
|
|
@@ -177,6 +177,10 @@ end
|
|
177
177
|
|
178
178
|
I was inspired by [udzura's mock](https://gist.github.com/1881139).
|
179
179
|
|
180
|
+
## Support Versions
|
181
|
+
|
182
|
+
Ruby-2.6.0 or later.
|
183
|
+
|
180
184
|
## Installation
|
181
185
|
|
182
186
|
Add this line to your application's Gemfile:
|
@@ -0,0 +1,19 @@
|
|
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
|
data/lib/rspec/parameterized.rb
CHANGED
@@ -3,6 +3,7 @@ require 'parser'
|
|
3
3
|
require 'unparser'
|
4
4
|
require 'proc_to_ast'
|
5
5
|
require 'rspec/parameterized/helper_methods'
|
6
|
+
require 'rspec/parameterized/example_helper_methods'
|
6
7
|
|
7
8
|
module RSpec
|
8
9
|
module Parameterized
|
@@ -113,12 +114,10 @@ module RSpec
|
|
113
114
|
pairs = [parameter.arg_names, param_set].transpose.to_h
|
114
115
|
pretty_params = pairs.has_key?(:case_name) ? pairs[:case_name] : pairs.map {|name, val| "#{name}: #{params_inspect(val)}"}.join(", ")
|
115
116
|
describe(pretty_params, *args) do
|
117
|
+
include ExampleHelperMethods
|
118
|
+
|
116
119
|
pairs.each do |name, val|
|
117
|
-
|
118
|
-
let(name) { val.apply(self) }
|
119
|
-
else
|
120
|
-
let(name) { val }
|
121
|
-
end
|
120
|
+
let(name) { recursive_apply(val) }
|
122
121
|
end
|
123
122
|
|
124
123
|
singleton_class.module_eval do
|
data/spec/parametarized_spec.rb
CHANGED
@@ -192,46 +192,96 @@ describe RSpec::Parameterized do
|
|
192
192
|
end
|
193
193
|
|
194
194
|
describe "ref" do
|
195
|
-
|
195
|
+
context 'simple usecase' do
|
196
|
+
let(:foo) { 1 }
|
196
197
|
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
198
|
+
where(:value, :answer) do
|
199
|
+
[
|
200
|
+
[ref(:foo), 1],
|
201
|
+
]
|
202
|
+
end
|
203
|
+
|
204
|
+
with_them do
|
205
|
+
it "let variable in same example group can be used" do
|
206
|
+
expect(value).to eq answer
|
207
|
+
end
|
208
|
+
|
209
|
+
context "override let varibale" do
|
210
|
+
let(:foo) { 3 }
|
211
|
+
|
212
|
+
it "can override let variable" do
|
213
|
+
expect(value).to eq 3
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
201
217
|
end
|
202
218
|
|
203
|
-
|
204
|
-
|
205
|
-
|
219
|
+
context "recursive usecase" do
|
220
|
+
let(:foo) { 1 }
|
221
|
+
|
222
|
+
where(:value, :answer) do
|
223
|
+
[
|
224
|
+
[[ref(:foo), 2], [1, 2]],
|
225
|
+
]
|
206
226
|
end
|
207
227
|
|
208
|
-
|
209
|
-
let
|
228
|
+
with_them do
|
229
|
+
it "let variable in same example group can be used" do
|
230
|
+
expect(value).to eq answer
|
231
|
+
end
|
232
|
+
|
233
|
+
context "override let varibale" do
|
234
|
+
let(:foo) { 3 }
|
210
235
|
|
211
|
-
|
212
|
-
|
236
|
+
it "can override let variable" do
|
237
|
+
expect(value).to eq [3, 2]
|
238
|
+
end
|
213
239
|
end
|
214
240
|
end
|
215
241
|
end
|
216
242
|
end
|
217
243
|
|
218
244
|
describe "lazy" do
|
219
|
-
|
220
|
-
|
245
|
+
context "simple usecase" do
|
246
|
+
let(:one) { 1 }
|
247
|
+
let(:four) { 4 }
|
221
248
|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
249
|
+
where(:a, :b, :answer) do
|
250
|
+
[
|
251
|
+
[ref(:one), ref(:four), lazy { two + three }],
|
252
|
+
]
|
253
|
+
end
|
254
|
+
|
255
|
+
with_them do
|
256
|
+
context "define two and three after where block" do
|
257
|
+
let(:two) { 2 }
|
258
|
+
let(:three) { 3 }
|
259
|
+
|
260
|
+
it "should do additions" do
|
261
|
+
expect(a + b).to eq answer
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|
226
265
|
end
|
227
266
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
let(:three) { 3 }
|
267
|
+
context 'recursive usecase' do
|
268
|
+
let(:one) { 1 }
|
269
|
+
let(:four) { 4 }
|
232
270
|
|
233
|
-
|
234
|
-
|
271
|
+
where(:a, :b, :answer) do
|
272
|
+
[
|
273
|
+
[ref(:one), ref(:four), { result: lazy { two + three } }],
|
274
|
+
]
|
275
|
+
end
|
276
|
+
|
277
|
+
with_them do
|
278
|
+
context "define two and three after where block" do
|
279
|
+
let(:two) { 2 }
|
280
|
+
let(:three) { 3 }
|
281
|
+
|
282
|
+
it "should do additions" do
|
283
|
+
expect(a + b).to eq answer[:result]
|
284
|
+
end
|
235
285
|
end
|
236
286
|
end
|
237
287
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-parameterized
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tomykaira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -107,9 +107,9 @@ executables: []
|
|
107
107
|
extensions: []
|
108
108
|
extra_rdoc_files: []
|
109
109
|
files:
|
110
|
+
- ".github/workflows/rspec.yml"
|
110
111
|
- ".gitignore"
|
111
112
|
- ".rspec"
|
112
|
-
- ".travis.yml"
|
113
113
|
- CHANGELOG.md
|
114
114
|
- Gemfile
|
115
115
|
- LICENSE
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- lib/rspec-parameterized.rb
|
121
121
|
- lib/rspec/parameterized.rb
|
122
122
|
- lib/rspec/parameterized/arg.rb
|
123
|
+
- lib/rspec/parameterized/example_helper_methods.rb
|
123
124
|
- lib/rspec/parameterized/helper_methods.rb
|
124
125
|
- lib/rspec/parameterized/lazy_arg.rb
|
125
126
|
- lib/rspec/parameterized/ref_arg.rb
|
@@ -147,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
148
|
- !ruby/object:Gem::Version
|
148
149
|
version: '0'
|
149
150
|
requirements: []
|
150
|
-
rubygems_version: 3.2.
|
151
|
+
rubygems_version: 3.2.22
|
151
152
|
signing_key:
|
152
153
|
specification_version: 4
|
153
154
|
summary: RSpec::Parameterized supports simple parameterized test syntax in rspec.
|
data/.travis.yml
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
cache: bundler
|
3
|
-
rvm:
|
4
|
-
- 2.4
|
5
|
-
- 2.5
|
6
|
-
- 2.6
|
7
|
-
- 2.7
|
8
|
-
- ruby-head
|
9
|
-
- jruby-9.2.8.0
|
10
|
-
|
11
|
-
gemfile:
|
12
|
-
- gemfiles/rspec3.4.gemfile
|
13
|
-
- gemfiles/rspec-head.gemfile
|
14
|
-
|
15
|
-
before_install:
|
16
|
-
- travis_retry gem update --system || travis_retry gem update --system 2.7.8
|
17
|
-
- travis_retry gem install bundler --no-document || travis_retry gem install bundler --no-document -v 1.17.3
|
18
|
-
|
19
|
-
matrix:
|
20
|
-
allow_failures:
|
21
|
-
- rvm: ruby-head
|