spinach 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/.gitignore +1 -0
  2. data/.yardopts +6 -0
  3. data/Gemfile +1 -0
  4. data/Guardfile +7 -0
  5. data/Rakefile +1 -0
  6. data/Readme.md +147 -10
  7. data/features/{generate_features.feature → automatic_feature_generation.feature} +0 -0
  8. data/features/steps/automatic_feature_generation.rb +5 -2
  9. data/features/steps/exit_status.rb +8 -3
  10. data/features/steps/feature_name_guessing.rb +4 -1
  11. data/features/steps/reporting/display_run_summary.rb +7 -4
  12. data/features/steps/reporting/error_reporting.rb +7 -2
  13. data/features/steps/reporting/show_step_source_location.rb +9 -5
  14. data/features/steps/reporting/undefined_feature_reporting.rb +4 -1
  15. data/features/steps/rspec_compatibility.rb +6 -2
  16. data/features/support/spinach_runner.rb +2 -9
  17. data/lib/spinach/capybara.rb +3 -4
  18. data/lib/spinach/cli.rb +0 -1
  19. data/lib/spinach/config.rb +0 -8
  20. data/lib/spinach/dsl.rb +4 -13
  21. data/lib/spinach/exceptions.rb +1 -1
  22. data/lib/spinach/feature_steps.rb +1 -9
  23. data/lib/spinach/generators/feature_generator.rb +3 -2
  24. data/lib/spinach/generators.rb +1 -1
  25. data/lib/spinach/hookable.rb +81 -0
  26. data/lib/spinach/hooks.rb +132 -0
  27. data/lib/spinach/reporter/stdout/error_reporting.rb +163 -0
  28. data/lib/spinach/reporter/stdout.rb +3 -151
  29. data/lib/spinach/reporter.rb +39 -25
  30. data/lib/spinach/runner/{feature.rb → feature_runner.rb} +5 -15
  31. data/lib/spinach/runner/scenario_runner.rb +65 -0
  32. data/lib/spinach/runner.rb +5 -11
  33. data/lib/spinach/version.rb +1 -1
  34. data/lib/spinach.rb +20 -8
  35. data/spinach.gemspec +2 -3
  36. data/test/spinach/capybara_test.rb +4 -3
  37. data/test/spinach/cli_test.rb +0 -1
  38. data/test/spinach/feature_steps_test.rb +6 -23
  39. data/test/spinach/generators/feature_generator_test.rb +2 -2
  40. data/test/spinach/generators_test.rb +2 -2
  41. data/test/spinach/hookable_test.rb +59 -0
  42. data/test/spinach/hooks_test.rb +28 -0
  43. data/test/spinach/reporter/stdout/error_reporting_test.rb +265 -0
  44. data/test/spinach/reporter/stdout_test.rb +1 -238
  45. data/test/spinach/reporter_test.rb +58 -103
  46. data/test/spinach/runner/{feature_test.rb → feature_runner_test.rb} +21 -23
  47. data/test/spinach/runner/scenario_runner_test.rb +111 -0
  48. data/test/spinach/runner_test.rb +1 -1
  49. data/test/spinach_test.rb +19 -18
  50. data/test/test_helper.rb +1 -1
  51. metadata +60 -61
  52. data/lib/spinach/runner/scenario.rb +0 -77
  53. data/test/spinach/runner/scenario_test.rb +0 -120
@@ -40,7 +40,7 @@ describe Spinach::Runner do
40
40
  before do
41
41
  @feature = stub
42
42
  filenames.each do |filename|
43
- Spinach::Runner::Feature.expects(:new).
43
+ Spinach::Runner::FeatureRunner.expects(:new).
44
44
  with(filename, anything).
45
45
  returns(@feature)
46
46
  end
data/test/spinach_test.rb CHANGED
@@ -2,47 +2,48 @@ require_relative 'test_helper'
2
2
 
3
3
  describe Spinach do
4
4
  before do
5
- @feature1 = OpenStruct.new(feature_name: 'User authentication')
6
- @feature2 = OpenStruct.new(feature_name: 'Slip management')
7
- @feature3 = OpenStruct.new(feature_name: 'File attachments')
8
- @feature4 = OpenStruct.new(name: 'UserSendsAMessage')
9
- [@feature1, @feature2, @feature3, @feature4].each do |feature|
10
- Spinach.features << feature
5
+ @feature_steps1 = OpenStruct.new(feature_name: 'User authentication')
6
+ @feature_steps2 = OpenStruct.new(feature_name: 'Slip management')
7
+ @feature_steps3 = OpenStruct.new(feature_name: 'File attachments')
8
+ @feature_steps4 = OpenStruct.new(name: 'UserSendsAMessage')
9
+ [@feature_steps1, @feature_steps2,
10
+ @feature_steps3, @feature_steps4].each do |feature|
11
+ Spinach.feature_steps << feature
11
12
  end
12
13
  end
13
14
 
14
15
  describe '#features' do
15
16
  it 'returns all the loaded features' do
16
- Spinach.features.must_include @feature1
17
- Spinach.features.must_include @feature2
18
- Spinach.features.must_include @feature3
17
+ Spinach.feature_steps.must_include @feature_steps1
18
+ Spinach.feature_steps.must_include @feature_steps2
19
+ Spinach.feature_steps.must_include @feature_steps3
19
20
  end
20
21
  end
21
22
 
22
23
  describe '#reset_features' do
23
24
  it 'resets the features to a pristine state' do
24
- Spinach.reset_features
25
- [@feature1, @feature3, @feature3].each do |feature|
26
- Spinach.features.wont_include feature
25
+ Spinach.reset_feature_steps
26
+ [@feature_steps1, @feature_steps3, @feature_steps3].each do |feature|
27
+ Spinach.feature_steps.wont_include feature
27
28
  end
28
29
  end
29
30
  end
30
31
 
31
- describe '#find_feature' do
32
+ describe '#find_feature_steps' do
32
33
  it 'finds a feature by name' do
33
- Spinach.find_feature('User authentication').must_equal @feature1
34
- Spinach.find_feature('Slip management').must_equal @feature2
35
- Spinach.find_feature('File attachments').must_equal @feature3
34
+ Spinach.find_feature_steps('User authentication').must_equal @feature_steps1
35
+ Spinach.find_feature_steps('Slip management').must_equal @feature_steps2
36
+ Spinach.find_feature_steps('File attachments').must_equal @feature_steps3
36
37
  end
37
38
 
38
39
  describe 'when a feature class does no set a feature_name' do
39
40
  it 'guesses the feature class from the feature name' do
40
- Spinach.find_feature('User sends a message').must_equal @feature4
41
+ Spinach.find_feature_steps('User sends a message').must_equal @feature_steps4
41
42
  end
42
43
 
43
44
  it 'raises when it cannot find the class' do
44
45
  exception = proc {
45
- Spinach.find_feature('This feature does not exist')
46
+ Spinach.find_feature_steps('This feature does not exist')
46
47
  }.must_raise Spinach::FeatureStepsNotFoundException
47
48
  end
48
49
  end
data/test/test_helper.rb CHANGED
@@ -13,10 +13,10 @@ require 'minitest/spec'
13
13
  require 'minitest/autorun'
14
14
  require 'mocha'
15
15
  require 'ostruct'
16
- require 'purdytest'
17
16
  require 'stringio'
18
17
  require 'pry'
19
18
  require 'fakefs/safe'
19
+ require 'turn'
20
20
 
21
21
  require 'spinach'
22
22
  require 'spinach/capybara'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spinach
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,11 +12,11 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2011-10-11 00:00:00.000000000Z
15
+ date: 2011-10-21 00:00:00.000000000Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: gherkin
19
- requirement: &2152679240 !ruby/object:Gem::Requirement
19
+ requirement: &2172783760 !ruby/object:Gem::Requirement
20
20
  none: false
21
21
  requirements:
22
22
  - - ! '>='
@@ -24,21 +24,10 @@ dependencies:
24
24
  version: '0'
25
25
  type: :runtime
26
26
  prerelease: false
27
- version_requirements: *2152679240
28
- - !ruby/object:Gem::Dependency
29
- name: minitest
30
- requirement: &2152678820 !ruby/object:Gem::Requirement
31
- none: false
32
- requirements:
33
- - - ! '>='
34
- - !ruby/object:Gem::Version
35
- version: '0'
36
- type: :runtime
37
- prerelease: false
38
- version_requirements: *2152678820
27
+ version_requirements: *2172783760
39
28
  - !ruby/object:Gem::Dependency
40
29
  name: colorize
41
- requirement: &2152678400 !ruby/object:Gem::Requirement
30
+ requirement: &2172783340 !ruby/object:Gem::Requirement
42
31
  none: false
43
32
  requirements:
44
33
  - - ! '>='
@@ -46,21 +35,21 @@ dependencies:
46
35
  version: '0'
47
36
  type: :runtime
48
37
  prerelease: false
49
- version_requirements: *2152678400
38
+ version_requirements: *2172783340
50
39
  - !ruby/object:Gem::Dependency
51
- name: hooks
52
- requirement: &2152677960 !ruby/object:Gem::Requirement
40
+ name: rake
41
+ requirement: &2172782900 !ruby/object:Gem::Requirement
53
42
  none: false
54
43
  requirements:
55
44
  - - ! '>='
56
45
  - !ruby/object:Gem::Version
57
46
  version: '0'
58
- type: :runtime
47
+ type: :development
59
48
  prerelease: false
60
- version_requirements: *2152677960
49
+ version_requirements: *2172782900
61
50
  - !ruby/object:Gem::Dependency
62
- name: purdytest
63
- requirement: &2152677520 !ruby/object:Gem::Requirement
51
+ name: mocha
52
+ requirement: &2172782480 !ruby/object:Gem::Requirement
64
53
  none: false
65
54
  requirements:
66
55
  - - ! '>='
@@ -68,10 +57,10 @@ dependencies:
68
57
  version: '0'
69
58
  type: :development
70
59
  prerelease: false
71
- version_requirements: *2152677520
60
+ version_requirements: *2172782480
72
61
  - !ruby/object:Gem::Dependency
73
- name: rake
74
- requirement: &2152677060 !ruby/object:Gem::Requirement
62
+ name: sinatra
63
+ requirement: &2172782060 !ruby/object:Gem::Requirement
75
64
  none: false
76
65
  requirements:
77
66
  - - ! '>='
@@ -79,10 +68,10 @@ dependencies:
79
68
  version: '0'
80
69
  type: :development
81
70
  prerelease: false
82
- version_requirements: *2152677060
71
+ version_requirements: *2172782060
83
72
  - !ruby/object:Gem::Dependency
84
- name: mocha
85
- requirement: &2152676620 !ruby/object:Gem::Requirement
73
+ name: capybara
74
+ requirement: &2172781640 !ruby/object:Gem::Requirement
86
75
  none: false
87
76
  requirements:
88
77
  - - ! '>='
@@ -90,10 +79,10 @@ dependencies:
90
79
  version: '0'
91
80
  type: :development
92
81
  prerelease: false
93
- version_requirements: *2152676620
82
+ version_requirements: *2172781640
94
83
  - !ruby/object:Gem::Dependency
95
- name: sinatra
96
- requirement: &2152676180 !ruby/object:Gem::Requirement
84
+ name: aruba
85
+ requirement: &2172781220 !ruby/object:Gem::Requirement
97
86
  none: false
98
87
  requirements:
99
88
  - - ! '>='
@@ -101,10 +90,10 @@ dependencies:
101
90
  version: '0'
102
91
  type: :development
103
92
  prerelease: false
104
- version_requirements: *2152676180
93
+ version_requirements: *2172781220
105
94
  - !ruby/object:Gem::Dependency
106
- name: capybara
107
- requirement: &2152675720 !ruby/object:Gem::Requirement
95
+ name: pry
96
+ requirement: &2172780800 !ruby/object:Gem::Requirement
108
97
  none: false
109
98
  requirements:
110
99
  - - ! '>='
@@ -112,10 +101,10 @@ dependencies:
112
101
  version: '0'
113
102
  type: :development
114
103
  prerelease: false
115
- version_requirements: *2152675720
104
+ version_requirements: *2172780800
116
105
  - !ruby/object:Gem::Dependency
117
- name: aruba
118
- requirement: &2152675280 !ruby/object:Gem::Requirement
106
+ name: simplecov
107
+ requirement: &2172780380 !ruby/object:Gem::Requirement
119
108
  none: false
120
109
  requirements:
121
110
  - - ! '>='
@@ -123,10 +112,10 @@ dependencies:
123
112
  version: '0'
124
113
  type: :development
125
114
  prerelease: false
126
- version_requirements: *2152675280
115
+ version_requirements: *2172780380
127
116
  - !ruby/object:Gem::Dependency
128
- name: pry
129
- requirement: &2152674840 !ruby/object:Gem::Requirement
117
+ name: rspec
118
+ requirement: &2172779940 !ruby/object:Gem::Requirement
130
119
  none: false
131
120
  requirements:
132
121
  - - ! '>='
@@ -134,10 +123,10 @@ dependencies:
134
123
  version: '0'
135
124
  type: :development
136
125
  prerelease: false
137
- version_requirements: *2152674840
126
+ version_requirements: *2172779940
138
127
  - !ruby/object:Gem::Dependency
139
- name: simplecov
140
- requirement: &2152674400 !ruby/object:Gem::Requirement
128
+ name: fakefs
129
+ requirement: &2172779520 !ruby/object:Gem::Requirement
141
130
  none: false
142
131
  requirements:
143
132
  - - ! '>='
@@ -145,10 +134,10 @@ dependencies:
145
134
  version: '0'
146
135
  type: :development
147
136
  prerelease: false
148
- version_requirements: *2152674400
137
+ version_requirements: *2172779520
149
138
  - !ruby/object:Gem::Dependency
150
- name: rspec
151
- requirement: &2152673980 !ruby/object:Gem::Requirement
139
+ name: minitest
140
+ requirement: &2172779080 !ruby/object:Gem::Requirement
152
141
  none: false
153
142
  requirements:
154
143
  - - ! '>='
@@ -156,10 +145,10 @@ dependencies:
156
145
  version: '0'
157
146
  type: :development
158
147
  prerelease: false
159
- version_requirements: *2152673980
148
+ version_requirements: *2172779080
160
149
  - !ruby/object:Gem::Dependency
161
- name: fakefs
162
- requirement: &2152673560 !ruby/object:Gem::Requirement
150
+ name: turn
151
+ requirement: &2172778580 !ruby/object:Gem::Requirement
163
152
  none: false
164
153
  requirements:
165
154
  - - ! '>='
@@ -167,7 +156,7 @@ dependencies:
167
156
  version: '0'
168
157
  type: :development
169
158
  prerelease: false
170
- version_requirements: *2152673560
159
+ version_requirements: *2172778580
171
160
  description: Spinach is a BDD framework on top of gherkin
172
161
  email:
173
162
  - info@codegram.com
@@ -183,14 +172,15 @@ files:
183
172
  - .gitignore
184
173
  - .rvmrc
185
174
  - .travis.yml
175
+ - .yardopts
186
176
  - Gemfile
187
177
  - Guardfile
188
178
  - Rakefile
189
179
  - Readme.md
190
180
  - bin/spinach
181
+ - features/automatic_feature_generation.feature
191
182
  - features/exit_status.feature
192
183
  - features/feature_name_guessing.feature
193
- - features/generate_features.feature
194
184
  - features/reporting/display_run_summary.feature
195
185
  - features/reporting/error_reporting.feature
196
186
  - features/reporting/show_step_source_location.feature
@@ -217,12 +207,15 @@ files:
217
207
  - lib/spinach/generators.rb
218
208
  - lib/spinach/generators/feature_generator.rb
219
209
  - lib/spinach/generators/step_generator.rb
210
+ - lib/spinach/hookable.rb
211
+ - lib/spinach/hooks.rb
220
212
  - lib/spinach/parser.rb
221
213
  - lib/spinach/reporter.rb
222
214
  - lib/spinach/reporter/stdout.rb
215
+ - lib/spinach/reporter/stdout/error_reporting.rb
223
216
  - lib/spinach/runner.rb
224
- - lib/spinach/runner/feature.rb
225
- - lib/spinach/runner/scenario.rb
217
+ - lib/spinach/runner/feature_runner.rb
218
+ - lib/spinach/runner/scenario_runner.rb
226
219
  - lib/spinach/suites.rb
227
220
  - lib/spinach/suites/minitest.rb
228
221
  - lib/spinach/suites/rspec.rb
@@ -238,11 +231,14 @@ files:
238
231
  - test/spinach/generators/feature_generator_test.rb
239
232
  - test/spinach/generators/step_generator_test.rb
240
233
  - test/spinach/generators_test.rb
234
+ - test/spinach/hookable_test.rb
235
+ - test/spinach/hooks_test.rb
241
236
  - test/spinach/parser_test.rb
237
+ - test/spinach/reporter/stdout/error_reporting_test.rb
242
238
  - test/spinach/reporter/stdout_test.rb
243
239
  - test/spinach/reporter_test.rb
244
- - test/spinach/runner/feature_test.rb
245
- - test/spinach/runner/scenario_test.rb
240
+ - test/spinach/runner/feature_runner_test.rb
241
+ - test/spinach/runner/scenario_runner_test.rb
246
242
  - test/spinach/runner_test.rb
247
243
  - test/spinach/suites/minitest_test.rb
248
244
  - test/spinach/support_test.rb
@@ -262,7 +258,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
262
258
  version: '0'
263
259
  segments:
264
260
  - 0
265
- hash: 3283376077311958142
261
+ hash: -818234758859156687
266
262
  required_rubygems_version: !ruby/object:Gem::Requirement
267
263
  none: false
268
264
  requirements:
@@ -271,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
271
267
  version: '0'
272
268
  segments:
273
269
  - 0
274
- hash: 3283376077311958142
270
+ hash: -818234758859156687
275
271
  requirements: []
276
272
  rubyforge_project:
277
273
  rubygems_version: 1.8.6
@@ -279,9 +275,9 @@ signing_key:
279
275
  specification_version: 3
280
276
  summary: Spinach is a BDD framework on top of gherkin
281
277
  test_files:
278
+ - features/automatic_feature_generation.feature
282
279
  - features/exit_status.feature
283
280
  - features/feature_name_guessing.feature
284
- - features/generate_features.feature
285
281
  - features/reporting/display_run_summary.feature
286
282
  - features/reporting/error_reporting.feature
287
283
  - features/reporting/show_step_source_location.feature
@@ -307,11 +303,14 @@ test_files:
307
303
  - test/spinach/generators/feature_generator_test.rb
308
304
  - test/spinach/generators/step_generator_test.rb
309
305
  - test/spinach/generators_test.rb
306
+ - test/spinach/hookable_test.rb
307
+ - test/spinach/hooks_test.rb
310
308
  - test/spinach/parser_test.rb
309
+ - test/spinach/reporter/stdout/error_reporting_test.rb
311
310
  - test/spinach/reporter/stdout_test.rb
312
311
  - test/spinach/reporter_test.rb
313
- - test/spinach/runner/feature_test.rb
314
- - test/spinach/runner/scenario_test.rb
312
+ - test/spinach/runner/feature_runner_test.rb
313
+ - test/spinach/runner/scenario_runner_test.rb
315
314
  - test/spinach/runner_test.rb
316
315
  - test/spinach/suites/minitest_test.rb
317
316
  - test/spinach/support_test.rb
@@ -1,77 +0,0 @@
1
- require 'hooks'
2
-
3
- module Spinach
4
- class Runner
5
- # A Scenario Runner handles a particular scenario run.
6
- #
7
- class Scenario
8
- attr_reader :feature, :feature_name, :data
9
-
10
- include Hooks
11
-
12
- define_hook :before_run
13
- define_hook :on_successful_step
14
- define_hook :on_failed_step
15
- define_hook :on_error_step
16
- define_hook :on_undefined_step
17
- define_hook :on_skipped_step
18
- define_hook :after_run
19
-
20
- # @param [Feature] feature
21
- # The feature that contains the steps.
22
- #
23
- # @param [Hash] data
24
- # The parsed feature data.
25
- #
26
- # @api public
27
- def initialize(feature_name, data)
28
- @feature_name = feature_name
29
- @data = data
30
- end
31
-
32
- def steps
33
- @steps ||= data['steps']
34
- end
35
-
36
- # @return [Feature]
37
- # The feature object used to run this scenario.
38
- #
39
- # @api public
40
- def feature
41
- @feature ||= Spinach.find_feature(feature_name).new
42
- end
43
-
44
- # Runs this scenario
45
- # @return [True, False]
46
- # true if this scenario succeeded, false if not
47
- def run
48
- run_hook :before_run, data
49
- feature.run_hook :before_scenario, data
50
- steps.each do |step|
51
- feature.run_hook :before_step, step
52
- unless @exception
53
- begin
54
- step_location = feature.execute_step(step['name'])
55
- run_hook :on_successful_step, step, step_location
56
- rescue *Spinach.config[:failure_exceptions] => e
57
- @exception = e
58
- run_hook :on_failed_step, step, @exception, step_location
59
- rescue Spinach::StepNotDefinedException => e
60
- @exception = e
61
- run_hook :on_undefined_step, step, @exception
62
- rescue Exception => e
63
- @exception = e
64
- run_hook :on_error_step, step, @exception, step_location
65
- end
66
- else
67
- run_hook :on_skipped_step, step
68
- end
69
- feature.run_hook :after_step, step
70
- end
71
- feature.run_hook :after_scenario, data
72
- run_hook :after_run, data
73
- !@exception
74
- end
75
- end
76
- end
77
- end
@@ -1,120 +0,0 @@
1
- require_relative '../../test_helper'
2
-
3
- describe Spinach::Runner::Scenario do
4
- let(:data) do
5
- {
6
- 'name' => 'A cool scenario',
7
- 'steps' => [
8
- {'keyword' => 'Given', 'name' => 'I herd you like steps'},
9
- {'keyword' => 'When', 'name' => 'I test steps'},
10
- {'keyword' => 'Then', 'name' => 'I go step by step'}
11
- ]
12
- }
13
- end
14
-
15
- let(:feature) { stub_everything }
16
- let(:feature_name) { 'My feature' }
17
- let(:scenario) {
18
- scenario = Spinach::Runner::Scenario.new(feature_name, data)
19
- scenario.stubs(feature: feature)
20
- scenario
21
- }
22
-
23
- describe '#initialize' do
24
- it 'lists all the steps' do
25
- scenario.steps.count.must_equal 3
26
- end
27
-
28
- it 'sets the feature' do
29
- scenario.feature.must_equal feature
30
- end
31
- end
32
-
33
- describe '#feature' do
34
- it 'finds the feature given a feature name' do
35
- scenario.unstub(:feature)
36
- @feature = stub_everything
37
- scenario.stubs(feature_name: 'A cool feature')
38
- Spinach.expects(:find_feature).with('A cool feature').returns(@feature)
39
- scenario.feature
40
- end
41
- end
42
-
43
- describe '#run' do
44
- it 'calls the appropiate feature steps' do
45
- feature.expects(:execute_step).with('I herd you like steps')
46
- feature.expects(:execute_step).with('I test steps')
47
- feature.expects(:execute_step).with('I go step by step')
48
- scenario.run
49
- end
50
-
51
- describe 'when throwing exceptions' do
52
- it 'rescues a MiniTest::Assertion' do
53
- feature.expects(:execute_step).raises(MiniTest::Assertion)
54
- scenario.expects(:run_hook).with(:before_run, has_value("A cool scenario"))
55
- scenario.expects(:run_hook).with(:after_run, has_value("A cool scenario"))
56
- scenario.expects(:run_hook).with(
57
- :on_failed_step, anything, anything, anything)
58
- scenario.expects(:run_hook).with(
59
- :on_skipped_step, anything, anything).twice
60
- scenario.run
61
- end
62
-
63
- it 'rescues a Spinach::StepNotDefinedException' do
64
- feature.expects(:execute_step).raises(
65
- Spinach::StepNotDefinedException.new('bar'))
66
- scenario.expects(:run_hook).with(:before_run, has_value("A cool scenario"))
67
- scenario.expects(:run_hook).with(:after_run, has_value("A cool scenario"))
68
- scenario.expects(:run_hook).with(
69
- :on_undefined_step, anything, anything, anything)
70
- scenario.expects(:run_hook).with(
71
- :on_skipped_step, anything, anything).twice
72
- scenario.run
73
- end
74
-
75
- it 'rescues any other error' do
76
- feature.expects(:execute_step).raises
77
- scenario.expects(:run_hook).with(:after_run, has_value("A cool scenario"))
78
- scenario.expects(:run_hook).with(:before_run, has_value("A cool scenario"))
79
- scenario.expects(:run_hook).with(
80
- :on_error_step, anything, anything, anything)
81
- scenario.expects(:run_hook).with(
82
- :on_skipped_step, anything, anything).twice
83
- scenario.run
84
- end
85
-
86
- it 'returns an failure' do
87
- feature.expects(:execute_step).raises(MiniTest::Assertion)
88
- scenario.run.wont_equal nil
89
- end
90
- end
91
-
92
- it 'runs a step' do
93
- feature.expects(:execute_step).with(anything).times(3)
94
- scenario.run.must_equal true
95
- end
96
-
97
- describe 'hooks' do
98
- it 'fires up the scenario hooks' do
99
- feature.expects(:execute_step).raises(Spinach::StepNotDefinedException.new('bar'))
100
- feature.expects(:run_hook).with(:before_scenario, has_value("A cool scenario"))
101
- feature.expects(:run_hook).with(:after_scenario, has_value("A cool scenario"))
102
- scenario.run
103
- end
104
-
105
- it 'fires up the step hooks' do
106
- feature.expects(:execute_step).raises(Spinach::StepNotDefinedException.new('bar'))
107
- %w{before_step after_step}.each do |hook|
108
- feature.expects(:run_hook).with(
109
- hook.to_sym, kind_of(Hash))
110
- feature.expects(:run_hook).with(
111
- hook.to_sym, kind_of(Hash))
112
- feature.expects(:run_hook).with(
113
- hook.to_sym, kind_of(Hash))
114
- end
115
-
116
- scenario.run
117
- end
118
- end
119
- end
120
- end