rspec-steps 0.0.9 → 0.1.0
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.
- data/doc/README +6 -11
- data/lib/rspec-steps/duckpunch/example-group.rb +6 -1
- data/lib/rspec-steps/stepwise.rb +59 -105
- metadata +36 -9
data/doc/README
CHANGED
@@ -106,16 +106,11 @@ diverge, you can DRY your code out with shared_steps blocks, like so:
|
|
106
106
|
|
107
107
|
## Versions and Dependencies
|
108
108
|
|
109
|
-
0.0
|
110
|
-
|
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
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
109
|
+
0.1.0: Released Mar 12, 2013.
|
110
|
+
Compatible with RSpec 2.10-2.13 - probably works with earlier versions
|
120
111
|
|
112
|
+
0.0.9: Released Feb 22, 2013.
|
113
|
+
NOTES: works with rspec 2.6 through 2.10. Does not work with rspec >= 2.11
|
121
114
|
|
115
|
+
0.0.8: Released Jan 11, 2012.
|
116
|
+
NOTES: Will not work with rspec > 2.9.
|
@@ -4,7 +4,12 @@ require 'rspec-steps/stepwise'
|
|
4
4
|
module RSpec::Steps
|
5
5
|
module ClassMethods
|
6
6
|
def steps(*args, &block)
|
7
|
-
options =
|
7
|
+
options =
|
8
|
+
if args.last.is_a?(Hash)
|
9
|
+
args.pop
|
10
|
+
else
|
11
|
+
{}
|
12
|
+
end
|
8
13
|
options[:stepwise] = true
|
9
14
|
options[:caller] ||= caller
|
10
15
|
args.push(options)
|
data/lib/rspec-steps/stepwise.rb
CHANGED
@@ -1,15 +1,63 @@
|
|
1
1
|
module RSpecStepwise
|
2
|
+
class WholeListExample < RSpec::Core::Example
|
3
|
+
def initialize(example_group_class, descriptions, metadata)
|
4
|
+
super
|
5
|
+
build_example_block
|
6
|
+
end
|
7
|
+
|
8
|
+
def start(reporter)
|
9
|
+
end
|
10
|
+
|
11
|
+
def finish(reporter)
|
12
|
+
end
|
13
|
+
|
14
|
+
def build_example_block
|
15
|
+
#variables of concern: reporter, instance
|
16
|
+
@example_block = proc do
|
17
|
+
begin
|
18
|
+
self.class.filtered_examples.inject(true) do |success, example|
|
19
|
+
break if RSpec.wants_to_quit
|
20
|
+
example.extend StepExample
|
21
|
+
unless success
|
22
|
+
example.metadata[:pending] = true
|
23
|
+
example.metadata[:execution_result][:pending_message] = "Previous step failed"
|
24
|
+
end
|
25
|
+
succeeded = with_indelible_ivars do
|
26
|
+
example.run(self, reporter)
|
27
|
+
end
|
28
|
+
RSpec.wants_to_quit = true if self.class.fail_fast? && !succeeded
|
29
|
+
success && succeeded
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
module StepExample
|
37
|
+
def run_before_each
|
38
|
+
end
|
39
|
+
|
40
|
+
def run_after_each
|
41
|
+
end
|
42
|
+
|
43
|
+
def with_around_hooks
|
44
|
+
yield
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
2
48
|
module ClassMethods
|
3
49
|
#TODO: This is hacky and needs a more general solution
|
4
50
|
#Something like cloning the current conf and having RSpec::Stepwise::config ?
|
5
51
|
def suspend_transactional_fixtures
|
6
52
|
if self.respond_to? :use_transactional_fixtures
|
7
|
-
|
8
|
-
|
53
|
+
begin
|
54
|
+
old_val = self.use_transactional_fixtures
|
55
|
+
self.use_transactional_fixtures = false
|
9
56
|
|
10
|
-
|
11
|
-
|
12
|
-
|
57
|
+
yield
|
58
|
+
ensure
|
59
|
+
self.use_transactional_fixtures = old_val
|
60
|
+
end
|
13
61
|
else
|
14
62
|
yield
|
15
63
|
end
|
@@ -36,85 +84,6 @@ module RSpecStepwise
|
|
36
84
|
super
|
37
85
|
end
|
38
86
|
|
39
|
-
|
40
|
-
def eval_before_alls(example_group_instance)
|
41
|
-
super
|
42
|
-
stepped_before_hooks(example_group_instance)
|
43
|
-
end
|
44
|
-
|
45
|
-
def run_before_all_hooks(example_group_instance)
|
46
|
-
super
|
47
|
-
stepped_before_hooks(example_group_instance)
|
48
|
-
end
|
49
|
-
|
50
|
-
def stepped_before_hooks(example_group_instance)
|
51
|
-
example_group_instance.example = whole_list_example
|
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
|
58
|
-
ancestors.reverse.each { |ancestor| ancestor.run_hook(:before, :each, example_group_instance) }
|
59
|
-
store_before_all_ivars(example_group_instance)
|
60
|
-
end
|
61
|
-
|
62
|
-
def eval_around_eachs(example)
|
63
|
-
end
|
64
|
-
alias run_around_each_hooks eval_around_eachs
|
65
|
-
|
66
|
-
def eval_before_eachs(example)
|
67
|
-
end
|
68
|
-
alias run_before_each_hooks eval_before_eachs
|
69
|
-
|
70
|
-
def eval_after_eachs(example)
|
71
|
-
end
|
72
|
-
alias run_after_each_hooks eval_after_eachs
|
73
|
-
|
74
|
-
def eval_after_alls(example_group_instance)
|
75
|
-
stepped_after_hooks(example_group_instance)
|
76
|
-
super
|
77
|
-
end
|
78
|
-
|
79
|
-
def run_after_all_hooks(example_group_instance)
|
80
|
-
stepped_after_hooks(example_group_instance)
|
81
|
-
super
|
82
|
-
end
|
83
|
-
|
84
|
-
def stepped_after_hooks(example_group_instance)
|
85
|
-
example_group_instance.example = whole_list_example
|
86
|
-
ancestors.each { |ancestor| ancestor.run_hook(:after, :each, example_group_instance) }
|
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
|
92
|
-
end
|
93
|
-
|
94
|
-
def whole_list_example
|
95
|
-
@whole_list_example ||= begin
|
96
|
-
RSpec::Core::Example.new(self, "step list", {})
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def with_around_hooks(instance, &block)
|
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
|
-
|
107
|
-
if hooks.empty?
|
108
|
-
yield
|
109
|
-
else
|
110
|
-
hooks.reverse.inject(Example.procsy(metadata)) do |procsy, around_hook|
|
111
|
-
Example.procsy(procsy.metadata) do
|
112
|
-
instance.instance_eval_with_args(procsy, &around_hook)
|
113
|
-
end
|
114
|
-
end.call
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
87
|
def perform_steps(name, *args, &customization_block)
|
119
88
|
shared_block = world.shared_example_groups[name]
|
120
89
|
raise "Could not find shared example group named \#{name.inspect}" unless shared_block
|
@@ -124,36 +93,21 @@ module RSpecStepwise
|
|
124
93
|
end
|
125
94
|
|
126
95
|
def run_examples(reporter)
|
127
|
-
|
96
|
+
whole_list_example = WholeListExample.new(self, "step list", {})
|
128
97
|
|
98
|
+
instance = new
|
129
99
|
set_ivars(instance, before_all_ivars)
|
130
|
-
|
131
100
|
instance.example = whole_list_example
|
101
|
+
instance.reporter = reporter
|
132
102
|
|
133
103
|
suspend_transactional_fixtures do
|
134
|
-
|
135
|
-
filtered_examples.inject(true) do |success, example|
|
136
|
-
break if RSpec.wants_to_quit
|
137
|
-
unless success
|
138
|
-
reporter.example_started(example)
|
139
|
-
example.metadata[:pending] = true
|
140
|
-
example.metadata[:execution_result][:pending_message] = "Previous step failed"
|
141
|
-
example.metadata[:execution_result][:started_at] = Time.now
|
142
|
-
example.instance_eval{ record_finished :pending, :pending_message => "Previous step failed" }
|
143
|
-
reporter.example_pending(example)
|
144
|
-
next
|
145
|
-
end
|
146
|
-
succeeded = instance.with_indelible_ivars do
|
147
|
-
example.run(instance, reporter)
|
148
|
-
end
|
149
|
-
RSpec.wants_to_quit = true if fail_fast? && !succeeded
|
150
|
-
success && succeeded
|
151
|
-
end
|
152
|
-
end
|
104
|
+
whole_list_example.run(instance, reporter)
|
153
105
|
end
|
154
106
|
end
|
155
107
|
end
|
156
108
|
|
109
|
+
attr_accessor :reporter
|
110
|
+
|
157
111
|
def with_indelible_ivars
|
158
112
|
old_value, @ivars_indelible = @ivars_indelible, true
|
159
113
|
result = yield
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-steps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-03-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: corundum
|
17
|
-
requirement:
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,15 @@ dependencies:
|
|
22
22
|
version: 0.0.25
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements:
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 0.0.25
|
26
31
|
- !ruby/object:Gem::Dependency
|
27
32
|
name: rspec
|
28
|
-
requirement:
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
29
34
|
none: false
|
30
35
|
requirements:
|
31
36
|
- - ! '>='
|
@@ -34,9 +39,31 @@ dependencies:
|
|
34
39
|
segments:
|
35
40
|
- 2
|
36
41
|
- 6
|
42
|
+
- - <
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 2.14.0
|
45
|
+
segments:
|
46
|
+
- 2
|
47
|
+
- 14
|
48
|
+
- 0
|
37
49
|
type: :runtime
|
38
50
|
prerelease: false
|
39
|
-
version_requirements:
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '2.6'
|
57
|
+
segments:
|
58
|
+
- 2
|
59
|
+
- 6
|
60
|
+
- - <
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 2.14.0
|
63
|
+
segments:
|
64
|
+
- 2
|
65
|
+
- 14
|
66
|
+
- 0
|
40
67
|
description: ! " I don't like Cucumber. I don't need plain text stories. My clients
|
41
68
|
either\n read code or don't read any test documents, so Cucumber is mostly useless.\n
|
42
69
|
\ But often, especially in full integration tests, it would be nice to have\n steps
|
@@ -304,7 +331,7 @@ rdoc_options:
|
|
304
331
|
- --main
|
305
332
|
- doc/README
|
306
333
|
- --title
|
307
|
-
- rspec-steps-0.0
|
334
|
+
- rspec-steps-0.1.0 RDoc
|
308
335
|
require_paths:
|
309
336
|
- lib/
|
310
337
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -315,7 +342,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
315
342
|
version: '0'
|
316
343
|
segments:
|
317
344
|
- 0
|
318
|
-
hash:
|
345
|
+
hash: -87716783
|
319
346
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
320
347
|
none: false
|
321
348
|
requirements:
|
@@ -324,7 +351,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
324
351
|
version: '0'
|
325
352
|
requirements: []
|
326
353
|
rubyforge_project: rspec-steps
|
327
|
-
rubygems_version: 1.8.
|
354
|
+
rubygems_version: 1.8.24
|
328
355
|
signing_key:
|
329
356
|
specification_version: 3
|
330
357
|
summary: I want steps in RSpec
|