rspec-parameterized-core 1.0.0.beta1 → 1.0.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/CHANGELOG.md +9 -2
- data/Gemfile +0 -6
- data/README.md +171 -16
- data/lib/rspec/parameterized/core/version.rb +1 -1
- data/rspec-parameterized-core.gemspec +2 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9a8d43ccf0423ea5eeeee84ec63814c779d554b67c72e117328422f019f6589
|
4
|
+
data.tar.gz: 85648988761216691d64e09db8e7ca8e35e9b66d3ddcea55f3e693bbab8c938e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c99e4fef851bd42987a161ff6cb75dc95480a2eb6364c7e8b57b6fe5008412ec6b688f90befcce3cba7479b9ed76077fa7a5e2d7bd445e44c5983ebd9fe9aed9
|
7
|
+
data.tar.gz: dc8ff9f56961a767b5cf999da41936ddd9fe2f91df1ff02559179d637472b396db80f6efd377b455b9d5c7b16a70f44832920c697ddc3b3d2d3f85cff7030d5c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
## [Unreleased]
|
2
|
+
[Full Changelog](https://github.com/rspec-parameterized/rspec-parameterized-core/compare/v1.0.1...main)
|
2
3
|
|
3
|
-
## [0.1
|
4
|
+
## [1.0.1] - 2024-05-04
|
5
|
+
[Full Changelog](https://github.com/rspec-parameterized/rspec-parameterized-core/compare/v1.0.0...v1.0.1)
|
4
6
|
|
5
|
-
-
|
7
|
+
- Requires proc_to_ast 0.2.0+
|
8
|
+
- https://github.com/rspec-parameterized/rspec-parameterized-core/pull/12
|
9
|
+
|
10
|
+
## [1.0.0] - 2022-12-31
|
11
|
+
- https://github.com/tomykaira/rspec-parameterized/blob/master/CHANGELOG.md#v100-2022-12-31
|
12
|
+
- Drop support Ruby < 2.6 (explicitly)
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,24 +1,179 @@
|
|
1
1
|
# Rspec::Parameterized::Core
|
2
|
+
`rspec-parameterized-core` provides parameterized test syntax in [rspec](https://rspec.info/).
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rspec/parameterized/core`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
[](https://badge.fury.io/rb/rspec-parameterized-core)
|
5
|
+
[](https://github.com/rspec-parameterized/rspec-parameterized-core/actions/workflows/rspec.yml)
|
6
6
|
|
7
7
|
## Installation
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
8
|
+
```ruby
|
9
|
+
# Install all components
|
10
|
+
group :test do
|
11
|
+
gem "rspec-parameterized", ">= 1.0.0"
|
12
|
+
end
|
13
|
+
|
14
|
+
# Install only rspec-parameterized-core
|
15
|
+
group :test do
|
16
|
+
gem "rspec-parameterized-core", ">= 1.0.0"
|
17
|
+
end
|
18
|
+
```
|
18
19
|
|
19
20
|
## Usage
|
20
|
-
|
21
|
-
|
21
|
+
### Nested Array Style
|
22
|
+
```ruby
|
23
|
+
describe "plus" do
|
24
|
+
where(:a, :b, :answer) do
|
25
|
+
[
|
26
|
+
[1 , 2 , 3],
|
27
|
+
[5 , 8 , 13],
|
28
|
+
[0 , 0 , 0]
|
29
|
+
]
|
30
|
+
end
|
31
|
+
with_them do
|
32
|
+
it "should do additions" do
|
33
|
+
expect(a + b).to eq answer
|
34
|
+
end
|
35
|
+
end
|
36
|
+
with_them do
|
37
|
+
# Can browse parameters via `params` method in with_them block
|
38
|
+
# Can browse all parameters via `all_params` method in with_them block
|
39
|
+
it "#{params[:a]} + #{params[:b]} == #{params[:answer]}" do
|
40
|
+
expect(a + b).to eq answer
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
### Hash and Array Style
|
47
|
+
```ruby
|
48
|
+
# Given parameters is each value combinations
|
49
|
+
# On this case
|
50
|
+
# [
|
51
|
+
# [1, 5, 2],
|
52
|
+
# [1, 5, 4],
|
53
|
+
# [1, 7, 2],
|
54
|
+
# [1, 7, 4],
|
55
|
+
# [1, 9, 2],
|
56
|
+
# [1, 9, 4],
|
57
|
+
# [3, 5, 2],
|
58
|
+
# [3, 5, 4],
|
59
|
+
# [3, 7, 2],
|
60
|
+
# [3, 7, 4],
|
61
|
+
# [3, 9, 2],
|
62
|
+
# [3, 9, 4]
|
63
|
+
# ]
|
64
|
+
describe "Hash arguments" do
|
65
|
+
where(a: [1, 3], b: [5, 7, 9], c: [2, 4])
|
66
|
+
with_them do
|
67
|
+
it "sums is even" do
|
68
|
+
expect(a + b + c).to be_even
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
```
|
73
|
+
|
74
|
+
### Verbose Syntax
|
75
|
+
```ruby
|
76
|
+
# For complex inputs or if you just want to be super explicit
|
77
|
+
describe "Verbose syntax" do
|
78
|
+
where do
|
79
|
+
{
|
80
|
+
"positive integers" => {
|
81
|
+
a: 1,
|
82
|
+
b: 2,
|
83
|
+
answer: 3,
|
84
|
+
},
|
85
|
+
"negative_integers" => {
|
86
|
+
a: -1,
|
87
|
+
b: -2,
|
88
|
+
answer: -3,
|
89
|
+
},
|
90
|
+
"mixed_integers" => {
|
91
|
+
a: 3,
|
92
|
+
b: -3,
|
93
|
+
answer: 0,
|
94
|
+
},
|
95
|
+
}
|
96
|
+
end
|
97
|
+
with_them do
|
98
|
+
it "should do additions" do
|
99
|
+
expect(a + b).to eq answer
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
```
|
104
|
+
|
105
|
+
### Custom names
|
106
|
+
```ruby
|
107
|
+
# It's also possible to override each combination name using magic variable :case_name
|
108
|
+
# Output:
|
109
|
+
# Custom names for regular syntax
|
110
|
+
# positive integers
|
111
|
+
# should do additions
|
112
|
+
# negative integers
|
113
|
+
# should do additions
|
114
|
+
# mixed integers
|
115
|
+
# should do additions
|
116
|
+
describe "Custom names for regular syntax" do
|
117
|
+
where(:case_name, :a, :b, :answer) do
|
118
|
+
[
|
119
|
+
["positive integers", 6, 2, 8],
|
120
|
+
["negative integers", -1, -2, -3],
|
121
|
+
[ "mixed integers", -5, 3, -2],
|
122
|
+
]
|
123
|
+
end
|
124
|
+
with_them do
|
125
|
+
it "should do additions" do
|
126
|
+
expect(a + b).to eq answer
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
# Or :case_names lambda for hash syntax
|
131
|
+
# Output:
|
132
|
+
# Custom naming for hash syntax
|
133
|
+
# 1 + 5 + 2
|
134
|
+
# sum is even
|
135
|
+
# 1 + 5 + 4
|
136
|
+
# sum is even
|
137
|
+
# 1 + 7 + 2
|
138
|
+
# sum is even
|
139
|
+
# ...
|
140
|
+
describe "Custom naming for hash syntax" do
|
141
|
+
where(case_names: ->(a, b, c){"#{a} + #{b} + #{c}"}, a: [1, 3], b: [5, 7, 9], c: [2, 4])
|
142
|
+
with_them do
|
143
|
+
it "sum is even" do
|
144
|
+
expect(a + b + c).to be_even
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
```
|
149
|
+
|
150
|
+
### lazy and ref types
|
151
|
+
```ruby
|
152
|
+
# Use ref(:symbol) to use let/let! defined variables in the where block
|
153
|
+
# Use lazy when you want to create let/let! variables after the where block
|
154
|
+
#
|
155
|
+
# Failures will be more readable in the future - https://github.com/tomykaira/rspec-parameterized/pull/65
|
156
|
+
describe "lazy and ref types" do
|
157
|
+
let(:one) { 1 }
|
158
|
+
let(:four) { 4 }
|
159
|
+
where(:a, :b, :result) do
|
160
|
+
[
|
161
|
+
[ref(:one), ref(:four), lazy { two + three }]
|
162
|
+
]
|
163
|
+
end
|
164
|
+
with_them do
|
165
|
+
context "use let after where block" do
|
166
|
+
let(:two) { 2 }
|
167
|
+
let(:three) { 3 }
|
168
|
+
it 'should equal 5' do
|
169
|
+
expect(a + b).to eq result
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
```
|
175
|
+
|
176
|
+
I was inspired by [udzura's mock](https://gist.github.com/1881139).
|
22
177
|
|
23
178
|
## Development
|
24
179
|
|
@@ -28,7 +183,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
28
183
|
|
29
184
|
## Contributing
|
30
185
|
|
31
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
186
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rspec-parameterized/rspec-parameterized-core.
|
32
187
|
|
33
188
|
## License
|
34
189
|
|
@@ -19,6 +19,7 @@ I was inspired by [udzura's mock](https://gist.github.com/1881139).}
|
|
19
19
|
spec.metadata["homepage_uri"] = spec.homepage
|
20
20
|
spec.metadata["source_code_uri"] = spec.homepage
|
21
21
|
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
|
22
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
22
23
|
|
23
24
|
# Specify which files should be added to the gem when it is released.
|
24
25
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -32,7 +33,7 @@ I was inspired by [udzura's mock](https://gist.github.com/1881139).}
|
|
32
33
|
spec.require_paths = ["lib"]
|
33
34
|
|
34
35
|
spec.add_dependency "parser"
|
35
|
-
spec.add_dependency "proc_to_ast"
|
36
|
+
spec.add_dependency "proc_to_ast", ">= 0.2.0"
|
36
37
|
spec.add_dependency "rspec", ">= 2.13", "< 4"
|
37
38
|
spec.add_dependency "unparser"
|
38
39
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-parameterized-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sue445
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2024-05-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: parser
|
@@ -32,14 +32,14 @@ dependencies:
|
|
32
32
|
requirements:
|
33
33
|
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
35
|
+
version: 0.2.0
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
42
|
+
version: 0.2.0
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: rspec
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -119,6 +119,7 @@ metadata:
|
|
119
119
|
homepage_uri: https://github.com/rspec-parameterized/rspec-parameterized-core
|
120
120
|
source_code_uri: https://github.com/rspec-parameterized/rspec-parameterized-core
|
121
121
|
changelog_uri: https://github.com/rspec-parameterized/rspec-parameterized-core/blob/main/CHANGELOG.md
|
122
|
+
rubygems_mfa_required: 'true'
|
122
123
|
post_install_message:
|
123
124
|
rdoc_options: []
|
124
125
|
require_paths:
|
@@ -130,11 +131,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
130
131
|
version: 2.6.0
|
131
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
133
|
requirements:
|
133
|
-
- - "
|
134
|
+
- - ">="
|
134
135
|
- !ruby/object:Gem::Version
|
135
|
-
version:
|
136
|
+
version: '0'
|
136
137
|
requirements: []
|
137
|
-
rubygems_version: 3.
|
138
|
+
rubygems_version: 3.5.3
|
138
139
|
signing_key:
|
139
140
|
specification_version: 4
|
140
141
|
summary: RSpec::Parameterized supports simple parameterized test syntax in rspec.
|