rspec-steps 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/doc/README +34 -27
- data/lib/rspec-steps/stepwise.rb +17 -3
- data/spec/{example_group.rb → example_group_spec.rb} +0 -0
- metadata +54 -103
data/doc/README
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
## ( or: why would I want to relearn how to write specs? )
|
3
3
|
|
4
4
|
RSpec Steps allows you to chain examples into a series of steps that run
|
5
|
-
in sequence and which stop when a step fails. It's often incredibly
|
6
|
-
useful to be able to aseemble a series of tests that should all pass,
|
5
|
+
in sequence and which stop when a step fails. It's often incredibly
|
6
|
+
useful to be able to aseemble a series of tests that should all pass,
|
7
7
|
but where completely isolating them is less than sensible.
|
8
8
|
|
9
|
-
One excellent example is web site integration tests. With RSpec steps you can
|
9
|
+
One excellent example is web site integration tests. With RSpec steps you can
|
10
10
|
do:
|
11
11
|
|
12
12
|
steps "Login and change password" do
|
@@ -14,42 +14,42 @@ do:
|
|
14
14
|
visit root
|
15
15
|
page.should have_text "Login"
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
it "should successfully log in" do
|
19
19
|
fill_in :name, "Johnny User"
|
20
20
|
click "Login"
|
21
21
|
page.should have_text "Welcome, Johnny!"
|
22
22
|
end
|
23
|
-
|
24
|
-
it "should load the password change form" do
|
23
|
+
|
24
|
+
it "should load the password change form" do
|
25
25
|
click "My Settings"
|
26
26
|
click "Update Password"
|
27
27
|
page.should have_selector("form#update_password")
|
28
|
-
end
|
29
|
-
|
28
|
+
end
|
29
|
+
|
30
30
|
it "should change the user's password successfully" do
|
31
31
|
fill_in :password, "foobar"
|
32
32
|
fill_in :password_confirmation, "foobar"
|
33
33
|
click "Change Password"
|
34
34
|
page.should have_text "Password changed successfully!"
|
35
|
-
User.find_by_name("Johnny User").valid_password?("foobar").should be_true
|
35
|
+
User.find_by_name("Johnny User").valid_password?("foobar").should be_true
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
end
|
39
39
|
|
40
40
|
The examples above will be run in order. State is preserved between examples
|
41
|
-
inside a "steps" block: any DB transactions will not roll back until the entire
|
42
|
-
sequence has been complete.
|
41
|
+
inside a "steps" block: any DB transactions will not roll back until the entire
|
42
|
+
sequence has been complete.
|
43
43
|
|
44
|
-
If any example inside the "steps" block fails, all remaining steps will be marked
|
45
|
-
pending and therefore skipped.
|
44
|
+
If any example inside the "steps" block fails, all remaining steps will be marked
|
45
|
+
pending and therefore skipped.
|
46
46
|
|
47
47
|
## Rationale
|
48
48
|
|
49
49
|
RSpec's philosophy is that all examples should be completely independent. This
|
50
|
-
is a great philosophy for most purposes, and we recommend you stick to it in
|
51
|
-
almost all cases. BUT, that complete separation of examples really sucks when
|
52
|
-
you're trying to write long stories involving many requests. You are usually
|
50
|
+
is a great philosophy for most purposes, and we recommend you stick to it in
|
51
|
+
almost all cases. BUT, that complete separation of examples really sucks when
|
52
|
+
you're trying to write long stories involving many requests. You are usually
|
53
53
|
stuck with three choices:
|
54
54
|
|
55
55
|
1. Write a sequence of examples, each of which repeats the behavior of all previous examples. Downside: horrendously inefficient.
|
@@ -62,13 +62,13 @@ and skip subsequent steps after a failure.
|
|
62
62
|
|
63
63
|
## Caveats and cautions
|
64
64
|
|
65
|
-
Don't call "describe" inside of "steps". The behavior is undefined and probably bad. It's
|
66
|
-
hard to imagine what this should actually mean in any case. Future versions of rspec-steps
|
65
|
+
Don't call "describe" inside of "steps". The behavior is undefined and probably bad. It's
|
66
|
+
hard to imagine what this should actually mean in any case. Future versions of rspec-steps
|
67
67
|
will consider this an error.
|
68
68
|
|
69
69
|
Any call to "before" inside a steps block is treated like before(:all) and is run only
|
70
|
-
once before the first step. Or perhaps more accurately, any call to before() is treated
|
71
|
-
like before(:each) ... but for these purposes the entire steps block is treated like a
|
70
|
+
once before the first step. Or perhaps more accurately, any call to before() is treated
|
71
|
+
like before(:each) ... but for these purposes the entire steps block is treated like a
|
72
72
|
single example.
|
73
73
|
|
74
74
|
## Advanced stuff: shared steps
|
@@ -89,8 +89,8 @@ diverge, you can DRY your code out with shared_steps blocks, like so:
|
|
89
89
|
end
|
90
90
|
|
91
91
|
steps "updating password" do
|
92
|
-
perform_steps "For a logged-in user"
|
93
|
-
|
92
|
+
perform_steps "For a logged-in user"
|
93
|
+
|
94
94
|
it "should update the password" do
|
95
95
|
...
|
96
96
|
end
|
@@ -98,17 +98,24 @@ diverge, you can DRY your code out with shared_steps blocks, like so:
|
|
98
98
|
|
99
99
|
steps "uploading a profile picture" do
|
100
100
|
perform_steps "For a logged-in user"
|
101
|
-
|
101
|
+
|
102
102
|
it "should upload a picture" do
|
103
103
|
...
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
+
## Versions and Dependencies
|
108
|
+
|
109
|
+
0.0.8: Released Jan 11, 2012.
|
110
|
+
NOTES: Will not work with rspec > 2.9.
|
111
|
+
|
112
|
+
CURRENT UNRELEASED Jan 31 2013:
|
113
|
+
Specs pass with rspec-core 2.6.0, 2.7.0, 2.8.0, 2.9.0, 2.10.1
|
114
|
+
Specs fail with rspec-core 2.11.x
|
115
|
+
|
116
|
+
|
107
117
|
|
108
|
-
|
109
118
|
|
110
|
-
|
111
|
-
|
112
119
|
|
113
120
|
|
114
121
|
|
data/lib/rspec-steps/stepwise.rb
CHANGED
@@ -49,7 +49,12 @@ module RSpecStepwise
|
|
49
49
|
|
50
50
|
def stepped_before_hooks(example_group_instance)
|
51
51
|
example_group_instance.example = whole_list_example
|
52
|
-
|
52
|
+
|
53
|
+
if world.respond_to?(:run_hook_filtered) # Rspec < 2.10
|
54
|
+
world.run_hook_filtered(:before, :each, self, example_group_instance, whole_list_example)
|
55
|
+
else # Rspec >= 2.10
|
56
|
+
run_hook(:before, :each, whole_list_example)
|
57
|
+
end
|
53
58
|
ancestors.reverse.each { |ancestor| ancestor.run_hook(:before, :each, example_group_instance) }
|
54
59
|
store_before_all_ivars(example_group_instance)
|
55
60
|
end
|
@@ -79,7 +84,11 @@ module RSpecStepwise
|
|
79
84
|
def stepped_after_hooks(example_group_instance)
|
80
85
|
example_group_instance.example = whole_list_example
|
81
86
|
ancestors.each { |ancestor| ancestor.run_hook(:after, :each, example_group_instance) }
|
82
|
-
world.
|
87
|
+
if world.respond_to?(:run_hook_filtered) # Rspec < 2.10
|
88
|
+
world.run_hook_filtered(:before, :each, self, example_group_instance, whole_list_example)
|
89
|
+
else # Rspec >= 2.10
|
90
|
+
run_hook(:before, :each, whole_list_example)
|
91
|
+
end
|
83
92
|
end
|
84
93
|
|
85
94
|
def whole_list_example
|
@@ -89,7 +98,12 @@ module RSpecStepwise
|
|
89
98
|
end
|
90
99
|
|
91
100
|
def with_around_hooks(instance, &block)
|
92
|
-
|
101
|
+
if self.respond_to?(:around_hooks_for) # rSpec < 2.10.0
|
102
|
+
hooks = around_hooks_for(self)
|
103
|
+
else
|
104
|
+
hooks = around_each_hooks_for(self) # rSpec >= 2.10.0
|
105
|
+
end
|
106
|
+
|
93
107
|
if hooks.empty?
|
94
108
|
yield
|
95
109
|
else
|
File without changes
|
metadata
CHANGED
@@ -1,104 +1,52 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-steps
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.9
|
4
5
|
prerelease:
|
5
|
-
version: 0.0.8
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Judson Lester
|
9
9
|
- Evan Dorn
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
prerelease: false
|
19
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
-
none: false
|
21
|
-
requirements:
|
22
|
-
- - ">="
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: 0.2.0
|
25
|
-
type: :development
|
26
|
-
version_requirements: *id001
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: hanna
|
29
|
-
prerelease: false
|
30
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
-
none: false
|
32
|
-
requirements:
|
33
|
-
- - ~>
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: 0.1.0
|
36
|
-
type: :development
|
37
|
-
version_requirements: *id002
|
38
|
-
- !ruby/object:Gem::Dependency
|
39
|
-
name: mailfactory
|
40
|
-
prerelease: false
|
41
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
|
-
requirements:
|
44
|
-
- - ~>
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 1.4.0
|
47
|
-
type: :development
|
48
|
-
version_requirements: *id003
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: rspec
|
51
|
-
prerelease: false
|
52
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
-
none: false
|
54
|
-
requirements:
|
55
|
-
- - ">="
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version: "2.0"
|
58
|
-
type: :development
|
59
|
-
version_requirements: *id004
|
60
|
-
- !ruby/object:Gem::Dependency
|
61
|
-
name: bundler
|
62
|
-
prerelease: false
|
63
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
13
|
+
date: 2013-02-22 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: corundum
|
17
|
+
requirement: &90293470 !ruby/object:Gem::Requirement
|
64
18
|
none: false
|
65
|
-
requirements:
|
66
|
-
- -
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version:
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.0.25
|
69
23
|
type: :development
|
70
|
-
version_requirements: *id005
|
71
|
-
- !ruby/object:Gem::Dependency
|
72
|
-
name: rcov
|
73
24
|
prerelease: false
|
74
|
-
|
75
|
-
|
76
|
-
requirements:
|
77
|
-
- - ">="
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
version: "0"
|
80
|
-
type: :development
|
81
|
-
version_requirements: *id006
|
82
|
-
- !ruby/object:Gem::Dependency
|
25
|
+
version_requirements: *90293470
|
26
|
+
- !ruby/object:Gem::Dependency
|
83
27
|
name: rspec
|
84
|
-
|
85
|
-
requirement: &id007 !ruby/object:Gem::Requirement
|
28
|
+
requirement: &90291650 !ruby/object:Gem::Requirement
|
86
29
|
none: false
|
87
|
-
requirements:
|
88
|
-
- -
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
version:
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.6'
|
34
|
+
segments:
|
35
|
+
- 2
|
36
|
+
- 6
|
91
37
|
type: :runtime
|
92
|
-
|
93
|
-
|
94
|
-
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: *90291650
|
40
|
+
description: ! " I don't like Cucumber. I don't need plain text stories. My clients
|
41
|
+
either\n read code or don't read any test documents, so Cucumber is mostly useless.\n
|
42
|
+
\ But often, especially in full integration tests, it would be nice to have\n steps
|
43
|
+
in a test.\n"
|
44
|
+
email:
|
95
45
|
- judson@lrdesign.com
|
96
46
|
- evan@lrdesign.com
|
97
47
|
executables: []
|
98
|
-
|
99
48
|
extensions: []
|
100
|
-
|
101
|
-
extra_rdoc_files:
|
49
|
+
extra_rdoc_files:
|
102
50
|
- doc/README
|
103
51
|
- doc/Specifications
|
104
52
|
- doc/coverage/rcov-ruby-1_8-gems-rspec-expectations-2_5_0-lib-rspec-matchers-include_rb.html
|
@@ -217,14 +165,14 @@ extra_rdoc_files:
|
|
217
165
|
- doc/coverage/print.css
|
218
166
|
- doc/coverage/rcov-ruby-1_8-gems-rspec-expectations-2_5_0-lib-rspec-matchers-satisfy_rb.html
|
219
167
|
- doc/coverage/lib-rspec-steps-duckpunch-object-extensions_rb.html
|
220
|
-
files:
|
168
|
+
files:
|
221
169
|
- lib/rspec-steps.rb
|
222
170
|
- lib/rspec-steps/stepwise.rb
|
223
171
|
- lib/rspec-steps/duckpunch/example-group.rb
|
224
172
|
- lib/rspec-steps/duckpunch/object-extensions.rb
|
225
173
|
- doc/README
|
226
174
|
- doc/Specifications
|
227
|
-
- spec/
|
175
|
+
- spec/example_group_spec.rb
|
228
176
|
- spec_help/spec_helper.rb
|
229
177
|
- spec_help/gem_test_suite.rb
|
230
178
|
- spec_help/rspec-sandbox.rb
|
@@ -347,35 +295,38 @@ files:
|
|
347
295
|
- doc/coverage/rcov-ruby-1_8-gems-rspec-expectations-2_5_0-lib-rspec-matchers-satisfy_rb.html
|
348
296
|
- doc/coverage/lib-rspec-steps-duckpunch-object-extensions_rb.html
|
349
297
|
homepage: https://github.com/LRDesign/rspec-steps
|
350
|
-
licenses:
|
298
|
+
licenses:
|
351
299
|
- MIT
|
352
|
-
post_install_message: Another tidy package brought to you by Judson Lester of Logical
|
353
|
-
|
300
|
+
post_install_message: Another tidy package brought to you by Judson Lester of Logical
|
301
|
+
Reality Design
|
302
|
+
rdoc_options:
|
354
303
|
- --inline-source
|
355
304
|
- --main
|
356
305
|
- doc/README
|
357
306
|
- --title
|
358
|
-
- rspec-steps-0.0.
|
359
|
-
require_paths:
|
307
|
+
- rspec-steps-0.0.9 RDoc
|
308
|
+
require_paths:
|
360
309
|
- lib/
|
361
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
310
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
362
311
|
none: false
|
363
|
-
requirements:
|
364
|
-
- -
|
365
|
-
- !ruby/object:Gem::Version
|
366
|
-
version:
|
367
|
-
|
312
|
+
requirements:
|
313
|
+
- - ! '>='
|
314
|
+
- !ruby/object:Gem::Version
|
315
|
+
version: '0'
|
316
|
+
segments:
|
317
|
+
- 0
|
318
|
+
hash: 472080701
|
319
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
368
320
|
none: false
|
369
|
-
requirements:
|
370
|
-
- -
|
371
|
-
- !ruby/object:Gem::Version
|
372
|
-
version:
|
321
|
+
requirements:
|
322
|
+
- - ! '>='
|
323
|
+
- !ruby/object:Gem::Version
|
324
|
+
version: '0'
|
373
325
|
requirements: []
|
374
|
-
|
375
326
|
rubyforge_project: rspec-steps
|
376
|
-
rubygems_version: 1.8.
|
327
|
+
rubygems_version: 1.8.15
|
377
328
|
signing_key:
|
378
329
|
specification_version: 3
|
379
330
|
summary: I want steps in RSpec
|
380
|
-
test_files:
|
331
|
+
test_files:
|
381
332
|
- spec_help/gem_test_suite.rb
|