minitest-around 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +15 -4
- data/Gemfile +4 -0
- data/README.md +28 -8
- data/Rakefile +17 -11
- data/config/cucumber.yml +1 -0
- data/examples/chdir_spec.rb +3 -18
- data/features/around_spec.feature +351 -0
- data/features/step_definitions/around_steps.rb +23 -0
- data/features/support/env.rb +48 -0
- data/lib/minitest/around.rb +7 -0
- data/lib/minitest/around/spec.rb +2 -2
- data/lib/minitest/around/unit.rb +2 -1
- data/lib/minitest/around/version.rb +2 -4
- data/minitest-around.gemspec +3 -2
- data/test/helper.rb +5 -0
- metadata +22 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 713334daf3b3e114e8d5bf5aa6a4767fe8cfddef
|
4
|
+
data.tar.gz: 4c485989c943ccddc3b3aa515ddc2923a590770a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 601fbba788d9d5983ea09cecd1d7658d7ce913636f87014d3691e0a5484e5c07427901f475ff45015bfd50ea0c02edfc7621ec2a49341e31c812c78a0dfab111
|
7
|
+
data.tar.gz: 5d67a70bf24e57b8d3a9e8af8be0e70bbba37b3afec9d14b507d882d43fc4c0bdfb763e547dbdfda43157271ca8f22b45fd34cd5384abe85c719b63c1c6f864c
|
data/.travis.yml
CHANGED
@@ -1,11 +1,22 @@
|
|
1
1
|
language: ruby
|
2
|
+
sudo: false
|
3
|
+
cache: bundler
|
2
4
|
rvm:
|
3
5
|
- 1.9.3
|
4
|
-
- 2.0
|
5
|
-
- 2.1
|
6
|
+
- 2.0
|
7
|
+
- 2.1
|
8
|
+
- 2.2
|
9
|
+
- ruby-head
|
6
10
|
- jruby
|
7
|
-
-
|
11
|
+
- jruby-head
|
12
|
+
- rbx-2
|
13
|
+
env:
|
14
|
+
global:
|
15
|
+
- CODECLIMATE_REPO_TOKEN=e2647eb4bb8263157b9d99d9f79a49f8262a7e5ed11b07bdfbd312afdb43c2fa
|
16
|
+
- JRUBY_OPTS='--dev -J-Xmx1024M'
|
8
17
|
matrix:
|
9
18
|
allow_failures:
|
10
|
-
- rvm:
|
19
|
+
- rvm: ruby-head
|
20
|
+
- rvm: jruby-head
|
21
|
+
- rvm: rbx-2
|
11
22
|
fast_finish: true
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,26 @@
|
|
1
|
+
[github]: https://github.com/splattael/minitest-around
|
2
|
+
[doc]: http://rubydoc.info/github/splattael/minitest-around/master/file/README.md
|
3
|
+
[gem]: https://rubygems.org/gems/minitest-around
|
4
|
+
[travis]: https://travis-ci.org/splattael/minitest-around
|
5
|
+
[codeclimate]: https://codeclimate.com/github/splattael/minitest-around
|
6
|
+
[inchpages]: https://inch-ci.org/github/splattael/minitest-around
|
7
|
+
|
1
8
|
# minitest-around
|
2
9
|
|
3
|
-
[![
|
10
|
+
[![Travis](https://img.shields.io/travis/splattael/minitest-around.svg?branch=master)][travis]
|
11
|
+
[![Gem Version](https://img.shields.io/gem/v/minitest-around.svg)][gem]
|
12
|
+
[![Code Climate](https://img.shields.io/codeclimate/github/splattael/minitest-around.svg)][codeclimate]
|
13
|
+
[![Test Coverage](https://codeclimate.com/github/splattael/minitest-around/badges/coverage.svg)][codeclimate]
|
14
|
+
[![Inline docs](https://inch-ci.org/github/splattael/minitest-around.svg?branch=master&style=flat)][inchpages]
|
15
|
+
|
16
|
+
[Gem][gem] |
|
17
|
+
[Source][github] |
|
18
|
+
[Documentation][doc]
|
4
19
|
|
5
20
|
Around block for minitest 5.X.
|
6
21
|
|
7
22
|
Alternative for setup/teardown dance.
|
8
23
|
|
9
|
-
[Gem](https://rubygems.org/gems/minitest-around) |
|
10
|
-
[Source](https://github.com/splattael/minitest-around) |
|
11
|
-
[RDoc](http://rubydoc.info/github/splattael/minitest-around/master/file/README.md)
|
12
|
-
|
13
24
|
## Installation
|
14
25
|
|
15
26
|
```Bash
|
@@ -40,6 +51,7 @@ end
|
|
40
51
|
|
41
52
|
### Spec
|
42
53
|
|
54
|
+
<!-- example -->
|
43
55
|
```Ruby
|
44
56
|
require 'minitest/autorun'
|
45
57
|
require 'minitest/around/spec'
|
@@ -48,7 +60,7 @@ require 'tmpdir'
|
|
48
60
|
describe "inside new directory" do
|
49
61
|
around do |test|
|
50
62
|
Dir.mktmpdir do |dir|
|
51
|
-
|
63
|
+
@dir = dir
|
52
64
|
Dir.chdir(dir) do
|
53
65
|
test.call
|
54
66
|
end
|
@@ -56,10 +68,15 @@ describe "inside new directory" do
|
|
56
68
|
end
|
57
69
|
|
58
70
|
it "is in new directory" do
|
59
|
-
assert_equal
|
71
|
+
assert_equal @dir, Dir.pwd.sub("/private/var/", "/var/")
|
60
72
|
end
|
61
73
|
end
|
62
74
|
```
|
75
|
+
<!-- example -->
|
76
|
+
|
77
|
+
## Multiple before/after blocks
|
78
|
+
|
79
|
+
Minitest-around also enables the use of multiple before/after blocks, which normally don't work in minitest.
|
63
80
|
|
64
81
|
## Caveats
|
65
82
|
|
@@ -85,6 +102,7 @@ for `minitest` 4.7.X support.
|
|
85
102
|
## [Contributors](https://github.com/splattael/minitest-around/graphs/contributors)
|
86
103
|
|
87
104
|
* [Michael Grosser](https://github.com/grosser)
|
105
|
+
* [Hendra Uzia](https://github.com/hendrauzia)
|
88
106
|
* [Rick Martínez](https://github.com/rickmzp)
|
89
107
|
* [Philip Nelson](https://github.com/pnelson)
|
90
108
|
|
@@ -105,5 +123,7 @@ bundle exec rake test
|
|
105
123
|
## Release
|
106
124
|
|
107
125
|
```Bash
|
108
|
-
|
126
|
+
edit lib/minitest/around/version.rb
|
127
|
+
git commit
|
128
|
+
rake release
|
109
129
|
```
|
data/Rakefile
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'bundler/setup'
|
2
2
|
require 'bundler/gem_tasks'
|
3
|
-
require '
|
3
|
+
require 'cucumber/rake/task'
|
4
4
|
|
5
5
|
desc 'Default: run unit tests.'
|
6
|
-
task :default => :test
|
6
|
+
task :default => [:test, :features]
|
7
7
|
|
8
8
|
# Test
|
9
9
|
TEST_FILES = FileList.new('test/*_{test,spec}.rb')
|
@@ -22,6 +22,21 @@ Rake::TestTask.new(:"test:isolated") do |test|
|
|
22
22
|
test.verbose = true
|
23
23
|
end
|
24
24
|
|
25
|
+
# Examples
|
26
|
+
EXAMPLES = FileList["examples/*.rb"]
|
27
|
+
desc "Run all examples"
|
28
|
+
task :"test:examples" do
|
29
|
+
EXAMPLES.each do |example|
|
30
|
+
sh "bundle", "exec", "ruby", example
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Features
|
35
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
36
|
+
skip_tags = %w[rspec todo].map { |tag| "--tag ~@#{tag}" }.join(" ")
|
37
|
+
t.cucumber_opts = "features #{skip_tags}"
|
38
|
+
end
|
39
|
+
|
25
40
|
# RDoc
|
26
41
|
require 'rdoc/task'
|
27
42
|
RDoc::Task.new do |rdoc|
|
@@ -32,12 +47,3 @@ RDoc::Task.new do |rdoc|
|
|
32
47
|
rdoc.options << "--all"
|
33
48
|
rdoc.options << "--markup markdown"
|
34
49
|
end
|
35
|
-
|
36
|
-
# Examples
|
37
|
-
EXAMPLES = FileList["examples/*.rb"]
|
38
|
-
desc "Run all examples"
|
39
|
-
task :"test:examples" do
|
40
|
-
EXAMPLES.each do |example|
|
41
|
-
sh "bundle", "exec", "ruby", example
|
42
|
-
end
|
43
|
-
end
|
data/config/cucumber.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
default: --tags ~@ignore -f progress
|
data/examples/chdir_spec.rb
CHANGED
@@ -1,18 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
describe "inside new directory" do
|
6
|
-
around do |test|
|
7
|
-
Dir.mktmpdir do |dir|
|
8
|
-
$dir = dir
|
9
|
-
Dir.chdir(dir) do
|
10
|
-
test.call
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
it "is in new directory" do
|
16
|
-
assert_equal $dir, Dir.pwd
|
17
|
-
end
|
18
|
-
end
|
1
|
+
code = File.read("README.md")[%r{<!-- example -->(.*)<!-- example -->}m].split("\n")[2..-3].join("\n")
|
2
|
+
puts code
|
3
|
+
eval code
|
@@ -0,0 +1,351 @@
|
|
1
|
+
Feature: `around` hooks
|
2
|
+
|
3
|
+
`around` hooks receive the example as a block argument, extended to behave as
|
4
|
+
a proc. This lets you define code that should be executed before and after the
|
5
|
+
example. Of course, you can do the same thing with `before` and `after` hooks;
|
6
|
+
and it's often cleaner to do so.
|
7
|
+
|
8
|
+
Where `around` hooks shine is when you want to run an example within a block.
|
9
|
+
For instance, if your database library offers a transaction method that
|
10
|
+
receives a block, you can use an `around` to cleanly open and close the
|
11
|
+
transaction around the example.
|
12
|
+
|
13
|
+
**WARNING:** `around` hooks do not share state with the example the way
|
14
|
+
`before` and `after` hooks do. This means that you cannot share instance
|
15
|
+
variables between `around` hooks and examples.
|
16
|
+
|
17
|
+
**WARNING:** Mock frameworks are set up and torn down within the context of
|
18
|
+
running the example. You cannot interact with them directly in `around` hooks.
|
19
|
+
|
20
|
+
Scenario: Use the example as a proc within the block passed to `around()`
|
21
|
+
Given a file named "example_spec.rb" with:
|
22
|
+
"""ruby
|
23
|
+
class Database
|
24
|
+
def self.transaction
|
25
|
+
puts "open transaction"
|
26
|
+
yield
|
27
|
+
puts "close transaction"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
RSpec.describe "around filter" do
|
32
|
+
around(:example) do |example|
|
33
|
+
Database.transaction(&example)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "gets run in order" do
|
37
|
+
puts "run the example"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
"""
|
41
|
+
When I run `rspec example_spec.rb`
|
42
|
+
Then the output should contain:
|
43
|
+
"""
|
44
|
+
open transaction
|
45
|
+
run the example
|
46
|
+
close transaction
|
47
|
+
"""
|
48
|
+
|
49
|
+
Scenario: Invoke the example using `run()`
|
50
|
+
Given a file named "example_spec.rb" with:
|
51
|
+
"""ruby
|
52
|
+
RSpec.describe "around hook" do
|
53
|
+
around(:example) do |example|
|
54
|
+
puts "around example before"
|
55
|
+
example.run
|
56
|
+
puts "around example after"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "gets run in order" do
|
60
|
+
puts "in the example"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
"""
|
64
|
+
When I run `rspec example_spec.rb`
|
65
|
+
Then the output should contain:
|
66
|
+
"""
|
67
|
+
around example before
|
68
|
+
in the example
|
69
|
+
around example after
|
70
|
+
"""
|
71
|
+
|
72
|
+
@rspec
|
73
|
+
Scenario: Access the example metadata
|
74
|
+
Given a file named "example_spec.rb" with:
|
75
|
+
"""ruby
|
76
|
+
RSpec.describe "something" do
|
77
|
+
around(:example) do |example|
|
78
|
+
puts example.metadata[:foo]
|
79
|
+
example.run
|
80
|
+
end
|
81
|
+
|
82
|
+
it "does something", :foo => "this should show up in the output" do
|
83
|
+
end
|
84
|
+
end
|
85
|
+
"""
|
86
|
+
When I run `rspec example_spec.rb`
|
87
|
+
Then the output should contain "this should show up in the output"
|
88
|
+
|
89
|
+
@rspec
|
90
|
+
Scenario: Define a global `around` hook
|
91
|
+
Given a file named "example_spec.rb" with:
|
92
|
+
"""ruby
|
93
|
+
RSpec.configure do |c|
|
94
|
+
c.around(:example) do |example|
|
95
|
+
puts "around example before"
|
96
|
+
example.run
|
97
|
+
puts "around example after"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
RSpec.describe "around filter" do
|
102
|
+
it "gets run in order" do
|
103
|
+
puts "in the example"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
"""
|
107
|
+
When I run `rspec example_spec.rb`
|
108
|
+
Then the output should contain:
|
109
|
+
"""
|
110
|
+
around example before
|
111
|
+
in the example
|
112
|
+
around example after
|
113
|
+
"""
|
114
|
+
|
115
|
+
Scenario: Per example hooks are wrapped by the `around` hook
|
116
|
+
Given a file named "example_spec.rb" with:
|
117
|
+
"""ruby
|
118
|
+
RSpec.describe "around filter" do
|
119
|
+
around(:example) do |example|
|
120
|
+
puts "around example before"
|
121
|
+
example.run
|
122
|
+
puts "around example after"
|
123
|
+
end
|
124
|
+
|
125
|
+
before(:example) do
|
126
|
+
puts "before example"
|
127
|
+
end
|
128
|
+
|
129
|
+
after(:example) do
|
130
|
+
puts "after example"
|
131
|
+
end
|
132
|
+
|
133
|
+
it "gets run in order" do
|
134
|
+
puts "in the example"
|
135
|
+
end
|
136
|
+
end
|
137
|
+
"""
|
138
|
+
When I run `rspec example_spec.rb`
|
139
|
+
Then the output should contain:
|
140
|
+
"""
|
141
|
+
around example before
|
142
|
+
before example
|
143
|
+
in the example
|
144
|
+
after example
|
145
|
+
around example after
|
146
|
+
"""
|
147
|
+
|
148
|
+
@todo
|
149
|
+
Scenario: Context hooks are NOT wrapped by the `around` hook
|
150
|
+
Given a file named "example_spec.rb" with:
|
151
|
+
"""ruby
|
152
|
+
RSpec.describe "around filter" do
|
153
|
+
around(:example) do |example|
|
154
|
+
puts "around example before"
|
155
|
+
example.run
|
156
|
+
puts "around example after"
|
157
|
+
end
|
158
|
+
|
159
|
+
before(:context) do
|
160
|
+
puts "before context"
|
161
|
+
end
|
162
|
+
|
163
|
+
after(:context) do
|
164
|
+
puts "after context"
|
165
|
+
end
|
166
|
+
|
167
|
+
it "gets run in order" do
|
168
|
+
puts "in the example"
|
169
|
+
end
|
170
|
+
end
|
171
|
+
"""
|
172
|
+
When I run `rspec --format progress example_spec.rb`
|
173
|
+
Then the output should contain:
|
174
|
+
"""
|
175
|
+
before context
|
176
|
+
around example before
|
177
|
+
in the example
|
178
|
+
around example after
|
179
|
+
.after context
|
180
|
+
"""
|
181
|
+
|
182
|
+
@rspec
|
183
|
+
Scenario: Examples run by an `around` block are run in the configured context
|
184
|
+
Given a file named "example_spec.rb" with:
|
185
|
+
"""ruby
|
186
|
+
module IncludedInConfigureBlock
|
187
|
+
def included_in_configure_block; true; end
|
188
|
+
end
|
189
|
+
|
190
|
+
RSpec.configure do |c|
|
191
|
+
c.include IncludedInConfigureBlock
|
192
|
+
end
|
193
|
+
|
194
|
+
RSpec.describe "around filter" do
|
195
|
+
around(:example) do |example|
|
196
|
+
example.run
|
197
|
+
end
|
198
|
+
|
199
|
+
it "runs the example in the correct context" do
|
200
|
+
expect(included_in_configure_block).to be_truthy
|
201
|
+
end
|
202
|
+
end
|
203
|
+
"""
|
204
|
+
When I run `rspec example_spec.rb`
|
205
|
+
Then the output should contain "1 example, 0 failure"
|
206
|
+
|
207
|
+
@rspec
|
208
|
+
Scenario: Implicitly pending examples are detected as Not yet implemented
|
209
|
+
Given a file named "example_spec.rb" with:
|
210
|
+
"""ruby
|
211
|
+
RSpec.describe "implicit pending example" do
|
212
|
+
around(:example) do |example|
|
213
|
+
example.run
|
214
|
+
end
|
215
|
+
|
216
|
+
it "should be detected as Not yet implemented"
|
217
|
+
end
|
218
|
+
"""
|
219
|
+
When I run `rspec example_spec.rb`
|
220
|
+
Then the output should contain "1 example, 0 failures, 1 pending"
|
221
|
+
And the output should contain:
|
222
|
+
"""
|
223
|
+
Pending:
|
224
|
+
implicit pending example should be detected as Not yet implemented
|
225
|
+
# Not yet implemented
|
226
|
+
"""
|
227
|
+
|
228
|
+
|
229
|
+
@rspec
|
230
|
+
Scenario: Explicitly pending examples are detected as pending
|
231
|
+
Given a file named "example_spec.rb" with:
|
232
|
+
"""ruby
|
233
|
+
RSpec.describe "explicit pending example" do
|
234
|
+
around(:example) do |example|
|
235
|
+
example.run
|
236
|
+
end
|
237
|
+
|
238
|
+
it "should be detected as pending" do
|
239
|
+
pending
|
240
|
+
fail
|
241
|
+
end
|
242
|
+
end
|
243
|
+
"""
|
244
|
+
When I run `rspec example_spec.rb`
|
245
|
+
Then the output should contain "1 example, 0 failures, 1 pending"
|
246
|
+
And the output should contain:
|
247
|
+
"""
|
248
|
+
explicit pending example should be detected as pending
|
249
|
+
# No reason given
|
250
|
+
"""
|
251
|
+
|
252
|
+
Scenario: Multiple `around` hooks in the same scope
|
253
|
+
Given a file named "example_spec.rb" with:
|
254
|
+
"""ruby
|
255
|
+
RSpec.describe "if there are multiple around hooks in the same scope" do
|
256
|
+
around(:example) do |example|
|
257
|
+
puts "first around hook before"
|
258
|
+
example.run
|
259
|
+
puts "first around hook after"
|
260
|
+
end
|
261
|
+
|
262
|
+
around(:example) do |example|
|
263
|
+
puts "second around hook before"
|
264
|
+
example.run
|
265
|
+
puts "second around hook after"
|
266
|
+
end
|
267
|
+
|
268
|
+
it "they should all be run" do
|
269
|
+
puts "in the example"
|
270
|
+
expect(1).to eq(1)
|
271
|
+
end
|
272
|
+
end
|
273
|
+
"""
|
274
|
+
When I run `rspec example_spec.rb`
|
275
|
+
Then the output should contain "1 example, 0 failure"
|
276
|
+
And the output should contain:
|
277
|
+
"""
|
278
|
+
first around hook before
|
279
|
+
second around hook before
|
280
|
+
in the example
|
281
|
+
second around hook after
|
282
|
+
first around hook after
|
283
|
+
"""
|
284
|
+
|
285
|
+
Scenario: `around` hooks in multiple scopes
|
286
|
+
Given a file named "example_spec.rb" with:
|
287
|
+
"""ruby
|
288
|
+
RSpec.describe "if there are around hooks in an outer scope" do
|
289
|
+
around(:example) do |example|
|
290
|
+
puts "first outermost around hook before"
|
291
|
+
example.run
|
292
|
+
puts "first outermost around hook after"
|
293
|
+
end
|
294
|
+
|
295
|
+
around(:example) do |example|
|
296
|
+
puts "second outermost around hook before"
|
297
|
+
example.run
|
298
|
+
puts "second outermost around hook after"
|
299
|
+
end
|
300
|
+
|
301
|
+
describe "outer scope" do
|
302
|
+
around(:example) do |example|
|
303
|
+
puts "first outer around hook before"
|
304
|
+
example.run
|
305
|
+
puts "first outer around hook after"
|
306
|
+
end
|
307
|
+
|
308
|
+
around(:example) do |example|
|
309
|
+
puts "second outer around hook before"
|
310
|
+
example.run
|
311
|
+
puts "second outer around hook after"
|
312
|
+
end
|
313
|
+
|
314
|
+
describe "inner scope" do
|
315
|
+
around(:example) do |example|
|
316
|
+
puts "first inner around hook before"
|
317
|
+
example.run
|
318
|
+
puts "first inner around hook after"
|
319
|
+
end
|
320
|
+
|
321
|
+
around(:example) do |example|
|
322
|
+
puts "second inner around hook before"
|
323
|
+
example.run
|
324
|
+
puts "second inner around hook after"
|
325
|
+
end
|
326
|
+
|
327
|
+
it "they should all be run" do
|
328
|
+
puts "in the example"
|
329
|
+
end
|
330
|
+
end
|
331
|
+
end
|
332
|
+
end
|
333
|
+
"""
|
334
|
+
When I run `rspec example_spec.rb`
|
335
|
+
Then the output should contain "1 example, 0 failure"
|
336
|
+
And the output should contain:
|
337
|
+
"""
|
338
|
+
first outermost around hook before
|
339
|
+
second outermost around hook before
|
340
|
+
first outer around hook before
|
341
|
+
second outer around hook before
|
342
|
+
first inner around hook before
|
343
|
+
second inner around hook before
|
344
|
+
in the example
|
345
|
+
second inner around hook after
|
346
|
+
first inner around hook after
|
347
|
+
second outer around hook after
|
348
|
+
first outer around hook after
|
349
|
+
second outermost around hook after
|
350
|
+
first outermost around hook after
|
351
|
+
"""
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
3
|
+
Given(/^a file named "(.*?)" with:$/) do |filename, content|
|
4
|
+
write_test_file(filename, content)
|
5
|
+
end
|
6
|
+
|
7
|
+
When(/^I run `rspec.*?(\S+)`$/) do |filename|
|
8
|
+
path = path_for(filename)
|
9
|
+
@output = `ruby #{path}`
|
10
|
+
end
|
11
|
+
|
12
|
+
Then(/^the output should contain:$/) do |content|
|
13
|
+
assert_includes @output, content
|
14
|
+
end
|
15
|
+
|
16
|
+
Then(/^the output should contain "(.*?)"$/) do |content|
|
17
|
+
# 1 runs, 0 assertions, 0 failures, 0 errors, 0 skips
|
18
|
+
runs = $1 if content =~ /(\d+) examples?/
|
19
|
+
failures = $1 if content =~ /(\d+) failures?/
|
20
|
+
skips = $1 if content =~ /(\d+) pending/
|
21
|
+
content = /#{runs} runs, \d+ assertions, #{failures} failures, 0 errors, #{skips || 0} skips/
|
22
|
+
assert_match content, @output
|
23
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'minitest/spec'
|
2
|
+
|
3
|
+
class MyWorld
|
4
|
+
include Minitest::Assertions
|
5
|
+
|
6
|
+
attr_accessor :assertions
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
self.assertions = 0
|
10
|
+
@temp_pathes = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def write_test_file(filename, content)
|
14
|
+
# RSpec.describe -> describe
|
15
|
+
content.gsub!("RSpec.describe", "describe")
|
16
|
+
# example.run -> example.call
|
17
|
+
content.gsub!("example.run", "example.call")
|
18
|
+
|
19
|
+
content = <<-RUBY + content
|
20
|
+
require 'minitest/autorun'
|
21
|
+
require "#{File.expand_path("../../../lib/minitest/around/spec", __FILE__)}"
|
22
|
+
|
23
|
+
require 'rspec/expectations/minitest_integration'
|
24
|
+
RUBY
|
25
|
+
write_file(filename, content)
|
26
|
+
end
|
27
|
+
|
28
|
+
def write_file(filename, content)
|
29
|
+
Tempfile.open(filename) do |file|
|
30
|
+
file.write content
|
31
|
+
assoc_tempfile filename, file.path
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def path_for(filename)
|
36
|
+
@temp_pathes.fetch(filename)
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def assoc_tempfile(filename, temp_path)
|
42
|
+
@temp_pathes[filename] = temp_path
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
World do
|
47
|
+
MyWorld.new
|
48
|
+
end
|
data/lib/minitest/around.rb
CHANGED
data/lib/minitest/around/spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'minitest'
|
1
|
+
require 'minitest/spec'
|
2
2
|
|
3
3
|
require 'minitest/around/version'
|
4
4
|
require 'minitest/around/unit'
|
@@ -7,7 +7,7 @@ Minitest::Spec::DSL.class_eval do
|
|
7
7
|
# - resume to call first part
|
8
8
|
# - execute test
|
9
9
|
# - resume fiber to execute last part
|
10
|
-
def around(&block)
|
10
|
+
def around(*args, &block)
|
11
11
|
fib = nil
|
12
12
|
before do
|
13
13
|
fib = Fiber.new do |context, resume|
|
data/lib/minitest/around/unit.rb
CHANGED
data/minitest-around.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require './lib/minitest/around/version'
|
2
2
|
|
3
|
-
Gem::Specification.new "minitest-around",
|
3
|
+
Gem::Specification.new "minitest-around", MinitestAround::VERSION do |s|
|
4
4
|
s.authors = ["Peter Suschlik"]
|
5
5
|
s.email = ["peter-minitest-around@suschlik.de"]
|
6
6
|
s.homepage = "https://github.com/splattael/minitest-around"
|
@@ -13,5 +13,6 @@ Gem::Specification.new "minitest-around", Minitest::Around::VERSION do |s|
|
|
13
13
|
|
14
14
|
s.add_development_dependency 'rdoc'
|
15
15
|
s.add_development_dependency 'rake'
|
16
|
-
s.add_development_dependency '
|
16
|
+
s.add_development_dependency 'cucumber'
|
17
|
+
s.add_development_dependency 'rspec-expectations'
|
17
18
|
end
|
data/test/helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-around
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Suschlik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -53,7 +53,21 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: cucumber
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec-expectations
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - ">="
|
@@ -79,7 +93,11 @@ files:
|
|
79
93
|
- LICENSE
|
80
94
|
- README.md
|
81
95
|
- Rakefile
|
96
|
+
- config/cucumber.yml
|
82
97
|
- examples/chdir_spec.rb
|
98
|
+
- features/around_spec.feature
|
99
|
+
- features/step_definitions/around_steps.rb
|
100
|
+
- features/support/env.rb
|
83
101
|
- lib/minitest/around.rb
|
84
102
|
- lib/minitest/around/spec.rb
|
85
103
|
- lib/minitest/around/unit.rb
|
@@ -110,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
128
|
version: '0'
|
111
129
|
requirements: []
|
112
130
|
rubyforge_project:
|
113
|
-
rubygems_version: 2.4.
|
131
|
+
rubygems_version: 2.4.5
|
114
132
|
signing_key:
|
115
133
|
specification_version: 4
|
116
134
|
summary: Around block for minitest.
|