rspec-permutations 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +13 -0
- data/.gitignore +8 -0
- data/.rspec +1 -0
- data/.rubocop.yml +210 -0
- data/.tool-versions +1 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +66 -0
- data/README.md +102 -0
- data/Rakefile +25 -0
- data/bin/console +14 -0
- data/bin/rspec +27 -0
- data/bin/rubocop +27 -0
- data/bin/setup +8 -0
- data/lib/rspec/permutations/hook.rb +19 -0
- data/lib/rspec/permutations/loader.rb +17 -0
- data/lib/rspec/permutations/parser.rb +71 -0
- data/lib/rspec/permutations/spec_finder.rb +9 -0
- data/lib/rspec/permutations/version.rb +5 -0
- data/lib/rspec/permutations.rb +13 -0
- data/rspec-permutations.gemspec +33 -0
- metadata +151 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f97c4e8733b6ee2ce5ff770bfcade25d189c936e7b77c0a6cd9f6b40b6cafff1
|
4
|
+
data.tar.gz: 6a57cc16edea0f7e3662aa58086d5684bad7092bd57560447564475e8eff1fe4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 688cffa84e709f258ddfc85465cad743417d02075817dcf206a29fca5420537dd7746395e55a0b160a0b7293f274beb9d9ba5fe91fbf72ec2579c81bc0c5fa66
|
7
|
+
data.tar.gz: ace1366b723a5985b1e59367acfcc5eea9de79efbcf7ca9ab40bc84537450acd3c8aad3406a51c45740856e923d08ddb239387ad83168d13e76bf3e6270c1ef3
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,210 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.7
|
3
|
+
<% unless ENV["CI"] %>
|
4
|
+
Exclude:
|
5
|
+
<% `git status --ignored --porcelain`.scan(/^!!\s+(.*)$/).each do |match| %>
|
6
|
+
- <%= match[0] %>**/*
|
7
|
+
<% end %>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
# Extensions
|
11
|
+
require:
|
12
|
+
- rubocop-rake
|
13
|
+
- rubocop-rspec
|
14
|
+
|
15
|
+
# New rules
|
16
|
+
Lint/DuplicateBranch: # (new in 1.3)
|
17
|
+
Enabled: true
|
18
|
+
Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
|
19
|
+
Enabled: true
|
20
|
+
Lint/EmptyBlock: # (new in 1.1)
|
21
|
+
Enabled: true
|
22
|
+
Lint/EmptyClass: # (new in 1.3)
|
23
|
+
Enabled: true
|
24
|
+
Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
|
25
|
+
Enabled: true
|
26
|
+
Lint/ToEnumArguments: # (new in 1.1)
|
27
|
+
Enabled: true
|
28
|
+
Lint/UnexpectedBlockArity: # (new in 1.5)
|
29
|
+
Enabled: true
|
30
|
+
Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
|
31
|
+
Enabled: true
|
32
|
+
Style/ArgumentsForwarding: # (new in 1.1)
|
33
|
+
Enabled: true
|
34
|
+
Style/CollectionCompact: # (new in 1.2)
|
35
|
+
Enabled: true
|
36
|
+
Style/DocumentDynamicEvalDefinition: # (new in 1.1)
|
37
|
+
Enabled: true
|
38
|
+
Style/NegatedIfElseCondition: # (new in 1.2)
|
39
|
+
Enabled: true
|
40
|
+
Style/NilLambda: # (new in 1.3)
|
41
|
+
Enabled: true
|
42
|
+
Style/RedundantArgument: # (new in 1.4)
|
43
|
+
Enabled: true
|
44
|
+
Style/SwapValues: # (new in 1.1)
|
45
|
+
Enabled: true
|
46
|
+
Gemspec/DeprecatedAttributeAssignment: # new in 1.30
|
47
|
+
Enabled: true
|
48
|
+
Gemspec/RequireMFA: # new in 1.23
|
49
|
+
Enabled: true
|
50
|
+
Layout/LineContinuationLeadingSpace: # new in 1.31
|
51
|
+
Enabled: true
|
52
|
+
Layout/LineContinuationSpacing: # new in 1.31
|
53
|
+
Enabled: true
|
54
|
+
Layout/LineEndStringConcatenationIndentation: # new in 1.18
|
55
|
+
Enabled: true
|
56
|
+
Layout/SpaceBeforeBrackets: # new in 1.7
|
57
|
+
Enabled: true
|
58
|
+
Lint/AmbiguousAssignment: # new in 1.7
|
59
|
+
Enabled: true
|
60
|
+
Lint/AmbiguousOperatorPrecedence: # new in 1.21
|
61
|
+
Enabled: true
|
62
|
+
Lint/AmbiguousRange: # new in 1.19
|
63
|
+
Enabled: true
|
64
|
+
Lint/ConstantOverwrittenInRescue: # new in 1.31
|
65
|
+
Enabled: true
|
66
|
+
Lint/DeprecatedConstants: # new in 1.8
|
67
|
+
Enabled: true
|
68
|
+
Lint/DuplicateMagicComment: # new in 1.37
|
69
|
+
Enabled: true
|
70
|
+
Lint/EmptyInPattern: # new in 1.16
|
71
|
+
Enabled: true
|
72
|
+
Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
|
73
|
+
Enabled: true
|
74
|
+
Lint/LambdaWithoutLiteralBlock: # new in 1.8
|
75
|
+
Enabled: true
|
76
|
+
Lint/NonAtomicFileOperation: # new in 1.31
|
77
|
+
Enabled: true
|
78
|
+
Lint/NumberedParameterAssignment: # new in 1.9
|
79
|
+
Enabled: true
|
80
|
+
Lint/OrAssignmentToConstant: # new in 1.9
|
81
|
+
Enabled: true
|
82
|
+
Lint/RedundantDirGlobSort: # new in 1.8
|
83
|
+
Enabled: true
|
84
|
+
Lint/RefinementImportMethods: # new in 1.27
|
85
|
+
Enabled: true
|
86
|
+
Lint/RequireRangeParentheses: # new in 1.32
|
87
|
+
Enabled: true
|
88
|
+
Lint/RequireRelativeSelfPath: # new in 1.22
|
89
|
+
Enabled: true
|
90
|
+
Lint/SymbolConversion: # new in 1.9
|
91
|
+
Enabled: true
|
92
|
+
Lint/TripleQuotes: # new in 1.9
|
93
|
+
Enabled: true
|
94
|
+
Lint/UselessRuby2Keywords: # new in 1.23
|
95
|
+
Enabled: true
|
96
|
+
Naming/BlockForwarding: # new in 1.24
|
97
|
+
Enabled: true
|
98
|
+
Security/CompoundHash: # new in 1.28
|
99
|
+
Enabled: true
|
100
|
+
Security/IoMethods: # new in 1.22
|
101
|
+
Enabled: true
|
102
|
+
Style/EmptyHeredoc: # new in 1.32
|
103
|
+
Enabled: true
|
104
|
+
Style/EndlessMethod: # new in 1.8
|
105
|
+
Enabled: true
|
106
|
+
Style/EnvHome: # new in 1.29
|
107
|
+
Enabled: true
|
108
|
+
Style/FetchEnvVar: # new in 1.28
|
109
|
+
Enabled: true
|
110
|
+
Style/FileRead: # new in 1.24
|
111
|
+
Enabled: true
|
112
|
+
Style/FileWrite: # new in 1.24
|
113
|
+
Enabled: true
|
114
|
+
Style/HashConversion: # new in 1.10
|
115
|
+
Enabled: true
|
116
|
+
Style/HashExcept: # new in 1.7
|
117
|
+
Enabled: true
|
118
|
+
Style/IfWithBooleanLiteralBranches: # new in 1.9
|
119
|
+
Enabled: true
|
120
|
+
Style/InPatternThen: # new in 1.16
|
121
|
+
Enabled: true
|
122
|
+
Style/MagicCommentFormat: # new in 1.35
|
123
|
+
Enabled: true
|
124
|
+
Style/MapCompactWithConditionalBlock: # new in 1.30
|
125
|
+
Enabled: true
|
126
|
+
Style/MapToHash: # new in 1.24
|
127
|
+
Enabled: true
|
128
|
+
Style/MultilineInPatternThen: # new in 1.16
|
129
|
+
Enabled: true
|
130
|
+
Style/NestedFileDirname: # new in 1.26
|
131
|
+
Enabled: true
|
132
|
+
Style/NumberedParameters: # new in 1.22
|
133
|
+
Enabled: true
|
134
|
+
Style/NumberedParametersLimit: # new in 1.22
|
135
|
+
Enabled: true
|
136
|
+
Style/ObjectThen: # new in 1.28
|
137
|
+
Enabled: true
|
138
|
+
Style/OpenStructUse: # new in 1.23
|
139
|
+
Enabled: true
|
140
|
+
Style/OperatorMethodCall: # new in 1.37
|
141
|
+
Enabled: true
|
142
|
+
Style/QuotedSymbols: # new in 1.16
|
143
|
+
Enabled: true
|
144
|
+
Style/RedundantEach: # new in 1.38
|
145
|
+
Enabled: true
|
146
|
+
Style/RedundantInitialize: # new in 1.27
|
147
|
+
Enabled: true
|
148
|
+
Style/RedundantSelfAssignmentBranch: # new in 1.19
|
149
|
+
Enabled: true
|
150
|
+
Style/RedundantStringEscape: # new in 1.37
|
151
|
+
Enabled: true
|
152
|
+
Style/SelectByRegexp: # new in 1.22
|
153
|
+
Enabled: true
|
154
|
+
Style/StringChars: # new in 1.12
|
155
|
+
Enabled: true
|
156
|
+
RSpec/BeEq: # new in 2.9.0
|
157
|
+
Enabled: true
|
158
|
+
RSpec/BeNil: # new in 2.9.0
|
159
|
+
Enabled: true
|
160
|
+
RSpec/ChangeByZero: # new in 2.11
|
161
|
+
Enabled: true
|
162
|
+
RSpec/ClassCheck: # new in 2.13
|
163
|
+
Enabled: true
|
164
|
+
RSpec/ExcessiveDocstringSpacing: # new in 2.5
|
165
|
+
Enabled: true
|
166
|
+
RSpec/IdenticalEqualityAssertion: # new in 2.4
|
167
|
+
Enabled: true
|
168
|
+
RSpec/NoExpectationExample: # new in 2.13
|
169
|
+
Enabled: true
|
170
|
+
RSpec/SortMetadata: # new in 2.14
|
171
|
+
Enabled: true
|
172
|
+
RSpec/SubjectDeclaration: # new in 2.5
|
173
|
+
Enabled: true
|
174
|
+
RSpec/VerifiedDoubleReference: # new in 2.10.0
|
175
|
+
Enabled: true
|
176
|
+
|
177
|
+
# Unused
|
178
|
+
RSpec/Capybara/NegationMatcher: # new in 2.14
|
179
|
+
Enabled: false
|
180
|
+
RSpec/Capybara/SpecificActions: # new in 2.14
|
181
|
+
Enabled: false
|
182
|
+
RSpec/Capybara/SpecificFinders: # new in 2.13
|
183
|
+
Enabled: false
|
184
|
+
RSpec/Capybara/SpecificMatcher: # new in 2.12
|
185
|
+
Enabled: false
|
186
|
+
RSpec/FactoryBot/ConsistentParenthesesStyle: # new in 2.14
|
187
|
+
Enabled: false
|
188
|
+
RSpec/FactoryBot/SyntaxMethods: # new in 2.7
|
189
|
+
Enabled: false
|
190
|
+
RSpec/Rails/AvoidSetupHook: # new in 2.4
|
191
|
+
Enabled: false
|
192
|
+
RSpec/Rails/HaveHttpStatus: # new in 2.12
|
193
|
+
Enabled: false
|
194
|
+
RSpec/Rails/InferredSpecType: # new in 2.14
|
195
|
+
Enabled: false
|
196
|
+
|
197
|
+
# Alterations
|
198
|
+
Naming/RescuedExceptionsVariableName:
|
199
|
+
Enabled: false
|
200
|
+
Style/BlockComments:
|
201
|
+
Exclude:
|
202
|
+
- spec/**/*
|
203
|
+
Style/Documentation:
|
204
|
+
Enabled: false
|
205
|
+
Style/FrozenStringLiteralComment:
|
206
|
+
Enabled: false
|
207
|
+
Layout/MultilineMethodCallIndentation:
|
208
|
+
Enabled: false
|
209
|
+
Style/StringLiterals:
|
210
|
+
EnforcedStyle: double_quotes
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.1.2
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rspec-permutations (1.0.0)
|
5
|
+
rspec (~> 3)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
ast (2.4.2)
|
11
|
+
diff-lcs (1.5.0)
|
12
|
+
json (2.6.2)
|
13
|
+
parallel (1.22.1)
|
14
|
+
parser (3.1.3.0)
|
15
|
+
ast (~> 2.4.1)
|
16
|
+
rainbow (3.1.1)
|
17
|
+
rake (13.0.1)
|
18
|
+
regexp_parser (2.6.1)
|
19
|
+
rexml (3.2.5)
|
20
|
+
rspec (3.12.0)
|
21
|
+
rspec-core (~> 3.12.0)
|
22
|
+
rspec-expectations (~> 3.12.0)
|
23
|
+
rspec-mocks (~> 3.12.0)
|
24
|
+
rspec-core (3.12.0)
|
25
|
+
rspec-support (~> 3.12.0)
|
26
|
+
rspec-expectations (3.12.0)
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
+
rspec-support (~> 3.12.0)
|
29
|
+
rspec-mocks (3.12.0)
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
+
rspec-support (~> 3.12.0)
|
32
|
+
rspec-support (3.12.0)
|
33
|
+
rubocop (1.39.0)
|
34
|
+
json (~> 2.3)
|
35
|
+
parallel (~> 1.10)
|
36
|
+
parser (>= 3.1.2.1)
|
37
|
+
rainbow (>= 2.2.2, < 4.0)
|
38
|
+
regexp_parser (>= 1.8, < 3.0)
|
39
|
+
rexml (>= 3.2.5, < 4.0)
|
40
|
+
rubocop-ast (>= 1.23.0, < 2.0)
|
41
|
+
ruby-progressbar (~> 1.7)
|
42
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
43
|
+
rubocop-ast (1.23.0)
|
44
|
+
parser (>= 3.1.1.0)
|
45
|
+
rubocop-rake (0.6.0)
|
46
|
+
rubocop (~> 1.0)
|
47
|
+
rubocop-rspec (2.15.0)
|
48
|
+
rubocop (~> 1.33)
|
49
|
+
ruby-progressbar (1.11.0)
|
50
|
+
unicode-display_width (2.3.0)
|
51
|
+
|
52
|
+
PLATFORMS
|
53
|
+
ruby
|
54
|
+
x86_64-darwin-19
|
55
|
+
x86_64-darwin-21
|
56
|
+
|
57
|
+
DEPENDENCIES
|
58
|
+
rake (~> 13.0)
|
59
|
+
rspec (~> 3.12)
|
60
|
+
rspec-permutations!
|
61
|
+
rubocop (~> 1.39)
|
62
|
+
rubocop-rake (~> 0.6)
|
63
|
+
rubocop-rspec (~> 2.15)
|
64
|
+
|
65
|
+
BUNDLED WITH
|
66
|
+
2.3.25
|
data/README.md
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
# Rspec::Permutations
|
2
|
+
|
3
|
+
[![SmartCasual](https://circleci.com/gh/SmartCasual/rspec-permutations.svg?style=svg)](https://app.circleci.com/pipelines/github/SmartCasual/rspec-permutations)
|
4
|
+
|
5
|
+
RSpec::Permutations is a gem that provides a simple way to run your RSpec tests with different permutations of parameters.
|
6
|
+
|
7
|
+
This makes combinatorial unit testing faster to write and easier to read.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem "rspec-permutations"
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle install
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install rspec-permutations
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Define a permutation group in your spec file, then use the `permutations` method to run your tests once for each permutation:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
=begin
|
31
|
+
| a | b | c |
|
32
|
+
| 1 | 2 | "apple" |
|
33
|
+
| 2 | 3 | "banana" |
|
34
|
+
=end
|
35
|
+
|
36
|
+
RSpec.describe SomeClass do
|
37
|
+
permutations do
|
38
|
+
it "does something" do
|
39
|
+
# a, b, and c are available here
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
### Multiple permutation blocks
|
46
|
+
|
47
|
+
You can define multiple permutation blocks in a single spec file, then use the `permutations` method to run your tests once for each permutation, giving the permutation block's name:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
=begin First permutation group
|
51
|
+
| a | b | c |
|
52
|
+
| 1 | 2 | "apple" |
|
53
|
+
| 2 | 3 | "banana" |
|
54
|
+
=end
|
55
|
+
|
56
|
+
=begin Second permutation group
|
57
|
+
| d | e |
|
58
|
+
| 5 | {a: 1, b: 2} |
|
59
|
+
| 2 | 3 |
|
60
|
+
=end
|
61
|
+
|
62
|
+
RSpec.describe SomeClass do
|
63
|
+
permutations "First permutation group" do
|
64
|
+
it "does something" do
|
65
|
+
# a, b, and c are available here
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
permutations "Second permutation group" do
|
70
|
+
it "does something else" do
|
71
|
+
# d and e are available here
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
```
|
76
|
+
|
77
|
+
Your blocks can be named however you like.
|
78
|
+
|
79
|
+
See `spec/rspec/permutations_spec.rb` for more examples.
|
80
|
+
|
81
|
+
### Rubocop
|
82
|
+
|
83
|
+
Rubocop will complain about the `=begin` and `=end` comments. You may want to disable it for spec files:
|
84
|
+
|
85
|
+
```yaml
|
86
|
+
# .rubocop.yml
|
87
|
+
Style/BlockComments:
|
88
|
+
Exclude:
|
89
|
+
- spec/**/*
|
90
|
+
```
|
91
|
+
|
92
|
+
## Development
|
93
|
+
|
94
|
+
The instructions in this section were added when the gem was generated, please let me know if any of them are incorrect.
|
95
|
+
|
96
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
97
|
+
|
98
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
99
|
+
|
100
|
+
## Contributing
|
101
|
+
|
102
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/SmartCasual/rspec-permutations/pulls.
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
begin
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
require "rubocop/rake_task"
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
RuboCop::RakeTask.new
|
8
|
+
rescue LoadError => exception
|
9
|
+
puts "Library not available: #{exception.message}"
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "Build, lint, and test"
|
13
|
+
task :build_and_test do
|
14
|
+
Rake::Task["lint"].invoke
|
15
|
+
Rake::Task["test"].invoke
|
16
|
+
Rake::Task["build"].invoke unless ENV["CI"]
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Lint"
|
20
|
+
task lint: :rubocop
|
21
|
+
|
22
|
+
desc "Test"
|
23
|
+
task test: :spec
|
24
|
+
|
25
|
+
task default: :build_and_test
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rspec/permutations"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/rspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("rspec-core", "rspec")
|
data/bin/rubocop
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rubocop' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("rubocop", "rubocop")
|
data/bin/setup
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative "loader"
|
2
|
+
|
3
|
+
module RSpec
|
4
|
+
module Permutations
|
5
|
+
module Hook
|
6
|
+
def permutations(name = nil, &block)
|
7
|
+
Loader.new(name).permutations.each do |permutation|
|
8
|
+
context("with permutation #{permutation}") do
|
9
|
+
permutation.each do |key, value|
|
10
|
+
let(key.to_sym) { instance_eval(value) }
|
11
|
+
end
|
12
|
+
|
13
|
+
instance_eval(&block)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative "spec_finder"
|
2
|
+
require_relative "parser"
|
3
|
+
|
4
|
+
module RSpec
|
5
|
+
module Permutations
|
6
|
+
class Loader
|
7
|
+
def initialize(name)
|
8
|
+
@name = name
|
9
|
+
end
|
10
|
+
|
11
|
+
def permutations
|
12
|
+
spec_file = RSpec::Permutations::SpecFinder.find
|
13
|
+
RSpec::Permutations::Parser.new(spec_file).permutations(@name)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require_relative "permutation"
|
2
|
+
|
3
|
+
module RSpec
|
4
|
+
module Permutations
|
5
|
+
class Parser
|
6
|
+
def initialize(spec_file)
|
7
|
+
@spec_file = spec_file
|
8
|
+
end
|
9
|
+
|
10
|
+
def permutations(name = nil)
|
11
|
+
if name
|
12
|
+
permutation_blocks.find { |pb| pb.name == name }.permutations
|
13
|
+
else
|
14
|
+
permutation_blocks.first.permutations
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def permutation_blocks
|
21
|
+
@permutation_blocks ||= File.read(@spec_file)
|
22
|
+
.scan(/^=begin(?:[[:blank:]]+([^\n]+))?\n(.*?)=end$/m)
|
23
|
+
.map do |name, table|
|
24
|
+
PermutationBlock.new(name, table)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class PermutationBlock
|
29
|
+
def initialize(name = nil, table)
|
30
|
+
@name = name
|
31
|
+
@permutations = Table.parse(table)
|
32
|
+
end
|
33
|
+
|
34
|
+
attr_reader :name, :permutations
|
35
|
+
end
|
36
|
+
|
37
|
+
class Table
|
38
|
+
class << self
|
39
|
+
def parse(raw_table)
|
40
|
+
headers, *rows = raw_table.strip.split("\n")
|
41
|
+
headers = headers.strip.split("|").map(&:strip)
|
42
|
+
headers = strip_start_and_end_blanks(headers)
|
43
|
+
|
44
|
+
rows.map do |row|
|
45
|
+
values = row.strip.split("|").compact.map(&:strip)
|
46
|
+
values = strip_start_and_end_blanks(values)
|
47
|
+
|
48
|
+
headers.each.with_object(Permutation.new(row)).with_index do |(header, hash), index|
|
49
|
+
hash[header] = values[index]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def blank?(string)
|
57
|
+
string.nil? || string == ""
|
58
|
+
end
|
59
|
+
|
60
|
+
def strip_start_and_end_blanks(array)
|
61
|
+
array
|
62
|
+
.drop_while { |s| blank?(s) }
|
63
|
+
.reverse
|
64
|
+
.drop_while { |s| blank?(s) }
|
65
|
+
.reverse
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative "lib/rspec/permutations/version"
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "rspec-permutations"
|
5
|
+
spec.version = Rspec::Permutations::VERSION
|
6
|
+
spec.authors = ["Elliot Crosby-McCullough"]
|
7
|
+
spec.email = ["elliot.cm@gmail.com"]
|
8
|
+
|
9
|
+
spec.summary = "An experimental RSpec extension for test permutations."
|
10
|
+
spec.homepage = "https://github.com/SmartCasual/rspec-permutations"
|
11
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
12
|
+
|
13
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
14
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
15
|
+
spec.metadata["changelog_uri"] = "https://github.com/SmartCasual/rspec-permutations/blob/master/CHANGELOG.md"
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = "bin"
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_dependency "rspec", "~> 3"
|
26
|
+
|
27
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.12"
|
29
|
+
spec.add_development_dependency "rubocop", "~> 1.39"
|
30
|
+
spec.add_development_dependency "rubocop-rake", "~> 0.6"
|
31
|
+
spec.add_development_dependency "rubocop-rspec", "~> 2.15"
|
32
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-permutations
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Elliot Crosby-McCullough
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-11-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '13.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '13.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.12'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.12'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.39'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.39'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop-rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.6'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.6'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop-rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.15'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.15'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- elliot.cm@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".circleci/config.yml"
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rspec"
|
107
|
+
- ".rubocop.yml"
|
108
|
+
- ".tool-versions"
|
109
|
+
- CHANGELOG.md
|
110
|
+
- Gemfile
|
111
|
+
- Gemfile.lock
|
112
|
+
- README.md
|
113
|
+
- Rakefile
|
114
|
+
- bin/console
|
115
|
+
- bin/rspec
|
116
|
+
- bin/rubocop
|
117
|
+
- bin/setup
|
118
|
+
- lib/rspec/permutations.rb
|
119
|
+
- lib/rspec/permutations/hook.rb
|
120
|
+
- lib/rspec/permutations/loader.rb
|
121
|
+
- lib/rspec/permutations/parser.rb
|
122
|
+
- lib/rspec/permutations/spec_finder.rb
|
123
|
+
- lib/rspec/permutations/version.rb
|
124
|
+
- rspec-permutations.gemspec
|
125
|
+
homepage: https://github.com/SmartCasual/rspec-permutations
|
126
|
+
licenses: []
|
127
|
+
metadata:
|
128
|
+
homepage_uri: https://github.com/SmartCasual/rspec-permutations
|
129
|
+
source_code_uri: https://github.com/SmartCasual/rspec-permutations
|
130
|
+
changelog_uri: https://github.com/SmartCasual/rspec-permutations/blob/master/CHANGELOG.md
|
131
|
+
rubygems_mfa_required: 'true'
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options: []
|
134
|
+
require_paths:
|
135
|
+
- lib
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: 2.7.0
|
141
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
requirements: []
|
147
|
+
rubygems_version: 3.3.7
|
148
|
+
signing_key:
|
149
|
+
specification_version: 4
|
150
|
+
summary: An experimental RSpec extension for test permutations.
|
151
|
+
test_files: []
|