spinach 0.1.2.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,9 @@
1
+ Feature: Display run summary
2
+ As a developer
3
+ I want spinach to display a summary of steps statuses
4
+ So I can easyly know general features status
5
+
6
+ Scenario: Display run summary at the end of features run
7
+ Given I have a feature that has some successful, undefined, failed and error steps
8
+ When I run it
9
+ Then I should see a summary with steps status information
@@ -0,0 +1,62 @@
1
+ require 'aruba/api'
2
+
3
+ Feature "Display run summary" do
4
+ include Integration::SpinachRunner
5
+
6
+ Given "I have a feature that has some successful, undefined, failed and error steps" do
7
+ write_file('features/test_feature.feature',
8
+ 'Feature: A test feature
9
+
10
+ Scenario: Undefined scenario
11
+ Given I am a fool
12
+ When I jump from Codegrams roof
13
+ Then I must be pwned by floor
14
+
15
+ # Scenario: Failed scenario
16
+ # Given I love risk
17
+ # When I jump from Codegrams roof
18
+ # Then my parachute must open
19
+ # Then I must not pwned by floor
20
+
21
+ # Scenario: Error scenario
22
+ # Given I am not a fool
23
+ # When I go downstairs
24
+ # Then I must succeed
25
+ ')
26
+ write_file('features/steps/test_feature.rb',
27
+ 'Feature "A test feature" do
28
+ Given "I am a fool" do
29
+ end
30
+ When "I jump from Codegrams roof" do
31
+ end
32
+ # Given "I love risk" do
33
+ # end
34
+ # And "my parachute must open" do
35
+ # false
36
+ # end
37
+ # Given I am a fool
38
+ # djkadlaksaldkajd
39
+ # end
40
+ # Given I am not a fool
41
+ # end
42
+ # When I go downstairs
43
+ # end
44
+ # Then I must succeed
45
+ # true
46
+ # end
47
+ end')
48
+ @feature = "features/test_feature.feature"
49
+ end
50
+
51
+ When "I run it" do
52
+ run_feature @feature
53
+ end
54
+
55
+ Then "I should see a summary with steps status information" do
56
+ all_stdout.must_match(
57
+ /Summary:.*2.*Successful.*1.*Undefined.*0.*Failed.*0.*Error/
58
+ )
59
+ end
60
+ end
61
+
62
+
@@ -8,10 +8,10 @@ module Integration
8
8
  base.class_eval do
9
9
  before_scenario do
10
10
  in_current_dir do
11
- FileUtils.rmdir('features')
11
+ run "rm -fR features"
12
12
  end
13
13
  end
14
- before do
14
+ before_scenario do
15
15
  @aruba_timeout_seconds = 6
16
16
  end
17
17
  end
data/lib/spinach/dsl.rb CHANGED
@@ -15,8 +15,6 @@ module Spinach
15
15
  extend ClassMethods
16
16
  include Hooks
17
17
 
18
- define_hook :before
19
- define_hook :after
20
18
  define_hook :before_scenario
21
19
  define_hook :after_scenario
22
20
  define_hook :before_step
@@ -11,6 +11,7 @@ module Spinach
11
11
  @errors = []
12
12
  @options = options
13
13
  @undefined_features = []
14
+ @successful_steps = []
14
15
  @undefined_steps = []
15
16
  @failed_steps = []
16
17
  @error_steps = []
@@ -22,7 +23,7 @@ module Spinach
22
23
 
23
24
  attr_accessor :current_feature, :current_scenario
24
25
 
25
- attr_reader :undefined_steps, :failed_steps, :error_steps, :undefined_features
26
+ attr_reader :undefined_steps, :failed_steps, :error_steps, :undefined_features, :successful_steps
26
27
 
27
28
  def bind
28
29
  runner.after_run method(:after_run)
@@ -11,6 +11,7 @@ module Spinach
11
11
 
12
12
  # The last scenario error
13
13
  attr_accessor :scenario_error
14
+ attr_accessor :scenario
14
15
 
15
16
  # Initialitzes the runner
16
17
  #
@@ -65,6 +66,8 @@ module Spinach
65
66
  #
66
67
  def on_successful_step(step, step_location)
67
68
  output_step('✔', step, :green, step_location)
69
+ self.scenario = [current_feature, current_scenario, step]
70
+ successful_steps << scenario
68
71
  end
69
72
 
70
73
  # Adds a failing step to the output buffer.
@@ -167,12 +170,25 @@ module Spinach
167
170
  end
168
171
 
169
172
  # It prints the error summary if the run has failed
173
+ # It always print feature success summary
170
174
  #
171
175
  # @param [True,False] success
172
176
  # whether the run has succeed or not
173
177
  #
174
178
  def after_run(success)
175
179
  error_summary unless success
180
+ out.puts ""
181
+ run_summary
182
+ end
183
+
184
+ # Prints the feature success summaryfor ths run.
185
+ #
186
+ def run_summary
187
+ successful_summary = "(".colorize(:green)+successful_steps.length.to_s.colorize(:light_green)+") Successful".colorize(:green)
188
+ undefined_summary = "(".colorize(:yellow)+undefined_steps.length.to_s.colorize(:light_yellow)+") Undefined".colorize(:yellow)
189
+ failed_summary = "(".colorize(:red)+failed_steps.length.to_s.colorize(:light_red)+") Failed".colorize(:red)
190
+ error_summary = "(".colorize(:red)+error_steps.length.to_s.colorize(:light_red)+") Error".colorize(:red)
191
+ out.puts "Steps Summary: #{successful_summary}, #{undefined_summary}, #{failed_summary}, #{error_summary}\n\n"
176
192
  end
177
193
 
178
194
  # Prints the errors for ths run.
@@ -31,14 +31,6 @@ module Spinach
31
31
  #
32
32
  attr_reader :filename
33
33
 
34
- # @return [Feature]
35
- # The feature object used to run this scenario.
36
- #
37
- # @api public
38
- def feature
39
- @feature ||= Spinach.find_feature(feature_name).new
40
- end
41
-
42
34
  # @return [Hash]
43
35
  # The parsed data for this feature.
44
36
  #
@@ -71,15 +63,13 @@ module Spinach
71
63
  # @api public
72
64
  def run
73
65
  run_hook :before_run, data
74
- feature.run_hook :before, data
75
66
 
76
67
  scenarios.each do |scenario|
77
68
  if !@scenario_line || scenario['line'].to_s == @scenario_line
78
- @success = Scenario.new(feature_name, feature, scenario).run
69
+ @success = Scenario.new(feature_name, scenario).run
79
70
  end
80
71
  end
81
72
 
82
- feature.run_hook :after, data
83
73
  run_hook :after_run, data
84
74
 
85
75
  rescue Spinach::FeatureStepsNotFoundException => e
@@ -24,16 +24,23 @@ module Spinach
24
24
  # The parsed feature data.
25
25
  #
26
26
  # @api public
27
- def initialize(feature_name, feature, data)
27
+ def initialize(feature_name, data)
28
28
  @feature_name = feature_name
29
29
  @data = data
30
- @feature = feature
31
30
  end
32
31
 
33
32
  def steps
34
33
  @steps ||= data['steps']
35
34
  end
36
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
+
37
44
  # Runs this scenario
38
45
  # @return [True, False]
39
46
  # true if this scenario succeeded, false if not
@@ -1,4 +1,4 @@
1
1
  module Spinach
2
2
  # Spinach version.
3
- VERSION = "0.1.2.1"
3
+ VERSION = "0.1.3"
4
4
  end
@@ -48,7 +48,8 @@ describe Spinach::FeatureSteps::Capybara do
48
48
  Then Goodbye
49
49
  ').at_least_once
50
50
 
51
- @feature_runner.stubs(feature: @feature).at_least_once
51
+ Spinach::Runner::Scenario.any_instance.stubs(feature: @feature)
52
+
52
53
  Capybara.current_session.expects(:reset!).twice
53
54
 
54
55
  @feature_runner.run
@@ -207,16 +207,20 @@ describe Spinach::Reporter::Stdout do
207
207
 
208
208
  describe '#after_run' do
209
209
  describe 'when the run has succeed' do
210
- it 'does nothing' do
211
- @reporter.after_run(true).must_equal nil
210
+ it 'display run summary' do
211
+ @reporter.expects(:error_summary).never
212
+ @reporter.expects(:run_summary)
213
+
214
+ @reporter.after_run(true)
212
215
  end
213
216
  end
214
217
 
215
- describe 'when the run has succeed' do
216
- it 'does nothing' do
217
- @reporter.stubs(:error_summary).returns('Error summary')
218
+ describe 'when the run has failed' do
219
+ it 'display run and error summaries' do
220
+ @reporter.expects(:error_summary)
221
+ @reporter.expects(:run_summary)
218
222
 
219
- @reporter.after_run(false).must_equal 'Error summary'
223
+ @reporter.after_run(false)
220
224
  end
221
225
  end
222
226
  end
@@ -17,16 +17,6 @@ describe Spinach::Runner::Feature do
17
17
  end
18
18
  end
19
19
 
20
- describe '#feature' do
21
- it 'finds the feature given a feature name' do
22
- @feature = stub_everything
23
- feature.stubs(feature_name: 'A cool feature')
24
-
25
- Spinach.expects(:find_feature).with('A cool feature').returns(@feature)
26
- feature.feature
27
- end
28
- end
29
-
30
20
  describe '#data' do
31
21
  it 'returns the parsed data' do
32
22
  parsed_data = {name: 'A cool feature'}
@@ -56,14 +46,12 @@ describe Spinach::Runner::Feature do
56
46
 
57
47
  it 'calls the steps as expected' do
58
48
  seq = sequence('feature')
59
- feature.feature.expects(:run_hook).with(:before, kind_of(Hash))
60
49
  3.times do
61
50
  Spinach::Runner::Scenario.
62
51
  expects(:new).
63
52
  returns(stub_everything).
64
53
  in_sequence(seq)
65
54
  end
66
- feature.feature.expects(:run_hook).with(:after, kind_of(Hash))
67
55
  feature.run
68
56
  end
69
57
 
@@ -90,7 +78,7 @@ describe Spinach::Runner::Feature do
90
78
  })
91
79
  @feature.stubs(feature: stub_everything)
92
80
 
93
- Spinach::Runner::Scenario.expects(:new).with(anything, anything, @feature.scenarios[1], anything).once.returns(stub_everything)
81
+ Spinach::Runner::Scenario.expects(:new).with(anything, @feature.scenarios[1], anything).once.returns(stub_everything)
94
82
  @feature.run
95
83
  end
96
84
 
@@ -98,7 +86,7 @@ describe Spinach::Runner::Feature do
98
86
  feature = Spinach::Runner::Feature.new(filename)
99
87
  data = mock
100
88
  exception = Spinach::FeatureStepsNotFoundException.new([anything, anything])
101
- feature.stubs(:feature).raises(exception)
89
+ feature.stubs(:scenarios).raises(exception)
102
90
  feature.stubs(:data).returns(data)
103
91
  not_found_called = false
104
92
  feature.class.when_not_found do |data, exception|
@@ -14,7 +14,11 @@ describe Spinach::Runner::Scenario do
14
14
 
15
15
  let(:feature) { stub_everything }
16
16
  let(:feature_name) { 'My feature' }
17
- let(:scenario) { Spinach::Runner::Scenario.new(feature_name, feature, data) }
17
+ let(:scenario) {
18
+ scenario = Spinach::Runner::Scenario.new(feature_name, data)
19
+ scenario.stubs(feature: feature)
20
+ scenario
21
+ }
18
22
 
19
23
  describe '#initialize' do
20
24
  it 'lists all the steps' do
@@ -26,6 +30,16 @@ describe Spinach::Runner::Scenario do
26
30
  end
27
31
  end
28
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
+
29
43
  describe '#run' do
30
44
  it 'calls the appropiate feature steps' do
31
45
  feature.expects(:execute_step).with('I herd you like steps')
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.2.1
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -16,7 +16,7 @@ date: 2011-10-10 00:00:00.000000000Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: gherkin
19
- requirement: &2164889160 !ruby/object:Gem::Requirement
19
+ requirement: &2158625180 !ruby/object:Gem::Requirement
20
20
  none: false
21
21
  requirements:
22
22
  - - ! '>='
@@ -24,10 +24,10 @@ dependencies:
24
24
  version: '0'
25
25
  type: :runtime
26
26
  prerelease: false
27
- version_requirements: *2164889160
27
+ version_requirements: *2158625180
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: minitest
30
- requirement: &2164888740 !ruby/object:Gem::Requirement
30
+ requirement: &2158624760 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ! '>='
@@ -35,10 +35,10 @@ dependencies:
35
35
  version: '0'
36
36
  type: :runtime
37
37
  prerelease: false
38
- version_requirements: *2164888740
38
+ version_requirements: *2158624760
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: colorize
41
- requirement: &2164888320 !ruby/object:Gem::Requirement
41
+ requirement: &2158624340 !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
44
  - - ! '>='
@@ -46,10 +46,10 @@ dependencies:
46
46
  version: '0'
47
47
  type: :runtime
48
48
  prerelease: false
49
- version_requirements: *2164888320
49
+ version_requirements: *2158624340
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: hooks
52
- requirement: &2164887900 !ruby/object:Gem::Requirement
52
+ requirement: &2158623920 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
55
  - - ! '>='
@@ -57,10 +57,10 @@ dependencies:
57
57
  version: '0'
58
58
  type: :runtime
59
59
  prerelease: false
60
- version_requirements: *2164887900
60
+ version_requirements: *2158623920
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: purdytest
63
- requirement: &2164887480 !ruby/object:Gem::Requirement
63
+ requirement: &2158623500 !ruby/object:Gem::Requirement
64
64
  none: false
65
65
  requirements:
66
66
  - - ! '>='
@@ -68,10 +68,10 @@ dependencies:
68
68
  version: '0'
69
69
  type: :development
70
70
  prerelease: false
71
- version_requirements: *2164887480
71
+ version_requirements: *2158623500
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: rake
74
- requirement: &2164887060 !ruby/object:Gem::Requirement
74
+ requirement: &2158623080 !ruby/object:Gem::Requirement
75
75
  none: false
76
76
  requirements:
77
77
  - - ! '>='
@@ -79,10 +79,10 @@ dependencies:
79
79
  version: '0'
80
80
  type: :development
81
81
  prerelease: false
82
- version_requirements: *2164887060
82
+ version_requirements: *2158623080
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: mocha
85
- requirement: &2164886640 !ruby/object:Gem::Requirement
85
+ requirement: &2158622660 !ruby/object:Gem::Requirement
86
86
  none: false
87
87
  requirements:
88
88
  - - ! '>='
@@ -90,10 +90,10 @@ dependencies:
90
90
  version: '0'
91
91
  type: :development
92
92
  prerelease: false
93
- version_requirements: *2164886640
93
+ version_requirements: *2158622660
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: sinatra
96
- requirement: &2164886220 !ruby/object:Gem::Requirement
96
+ requirement: &2158622240 !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
99
99
  - - ! '>='
@@ -101,10 +101,10 @@ dependencies:
101
101
  version: '0'
102
102
  type: :development
103
103
  prerelease: false
104
- version_requirements: *2164886220
104
+ version_requirements: *2158622240
105
105
  - !ruby/object:Gem::Dependency
106
106
  name: capybara
107
- requirement: &2164885800 !ruby/object:Gem::Requirement
107
+ requirement: &2158621820 !ruby/object:Gem::Requirement
108
108
  none: false
109
109
  requirements:
110
110
  - - ! '>='
@@ -112,10 +112,10 @@ dependencies:
112
112
  version: '0'
113
113
  type: :development
114
114
  prerelease: false
115
- version_requirements: *2164885800
115
+ version_requirements: *2158621820
116
116
  - !ruby/object:Gem::Dependency
117
117
  name: aruba
118
- requirement: &2164885380 !ruby/object:Gem::Requirement
118
+ requirement: &2158621400 !ruby/object:Gem::Requirement
119
119
  none: false
120
120
  requirements:
121
121
  - - ! '>='
@@ -123,10 +123,10 @@ dependencies:
123
123
  version: '0'
124
124
  type: :development
125
125
  prerelease: false
126
- version_requirements: *2164885380
126
+ version_requirements: *2158621400
127
127
  - !ruby/object:Gem::Dependency
128
128
  name: pry
129
- requirement: &2164884960 !ruby/object:Gem::Requirement
129
+ requirement: &2158620960 !ruby/object:Gem::Requirement
130
130
  none: false
131
131
  requirements:
132
132
  - - ! '>='
@@ -134,10 +134,10 @@ dependencies:
134
134
  version: '0'
135
135
  type: :development
136
136
  prerelease: false
137
- version_requirements: *2164884960
137
+ version_requirements: *2158620960
138
138
  - !ruby/object:Gem::Dependency
139
139
  name: simplecov
140
- requirement: &2164884540 !ruby/object:Gem::Requirement
140
+ requirement: &2158620540 !ruby/object:Gem::Requirement
141
141
  none: false
142
142
  requirements:
143
143
  - - ! '>='
@@ -145,10 +145,10 @@ dependencies:
145
145
  version: '0'
146
146
  type: :development
147
147
  prerelease: false
148
- version_requirements: *2164884540
148
+ version_requirements: *2158620540
149
149
  - !ruby/object:Gem::Dependency
150
150
  name: rspec
151
- requirement: &2164884120 !ruby/object:Gem::Requirement
151
+ requirement: &2158620120 !ruby/object:Gem::Requirement
152
152
  none: false
153
153
  requirements:
154
154
  - - ! '>='
@@ -156,7 +156,7 @@ dependencies:
156
156
  version: '0'
157
157
  type: :development
158
158
  prerelease: false
159
- version_requirements: *2164884120
159
+ version_requirements: *2158620120
160
160
  description: Spinach is a BDD framework on top of gherkin
161
161
  email:
162
162
  - info@codegram.com
@@ -179,12 +179,14 @@ files:
179
179
  - bin/spinach
180
180
  - features/exit_status.feature
181
181
  - features/feature_name_guessing.feature
182
+ - features/reporting/display_run_summary.feature
182
183
  - features/reporting/error_reporting.feature
183
184
  - features/reporting/show_step_source_location.feature
184
185
  - features/reporting/undefined_feature_reporting.feature
185
186
  - features/rspec_compatibility.feature
186
187
  - features/steps/exit_status.rb
187
188
  - features/steps/feature_name_guessing.rb
189
+ - features/steps/reporting/display_run_summary.rb
188
190
  - features/steps/reporting/error_reporting.rb
189
191
  - features/steps/reporting/show_step_source_location.rb
190
192
  - features/steps/reporting/undefined_feature_reporting.rb
@@ -241,7 +243,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
241
243
  version: '0'
242
244
  segments:
243
245
  - 0
244
- hash: -1175741634638937209
246
+ hash: 317238591053879963
245
247
  required_rubygems_version: !ruby/object:Gem::Requirement
246
248
  none: false
247
249
  requirements:
@@ -250,7 +252,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
250
252
  version: '0'
251
253
  segments:
252
254
  - 0
253
- hash: -1175741634638937209
255
+ hash: 317238591053879963
254
256
  requirements: []
255
257
  rubyforge_project:
256
258
  rubygems_version: 1.8.6
@@ -260,12 +262,14 @@ summary: Spinach is a BDD framework on top of gherkin
260
262
  test_files:
261
263
  - features/exit_status.feature
262
264
  - features/feature_name_guessing.feature
265
+ - features/reporting/display_run_summary.feature
263
266
  - features/reporting/error_reporting.feature
264
267
  - features/reporting/show_step_source_location.feature
265
268
  - features/reporting/undefined_feature_reporting.feature
266
269
  - features/rspec_compatibility.feature
267
270
  - features/steps/exit_status.rb
268
271
  - features/steps/feature_name_guessing.rb
272
+ - features/steps/reporting/display_run_summary.rb
269
273
  - features/steps/reporting/error_reporting.rb
270
274
  - features/steps/reporting/show_step_source_location.rb
271
275
  - features/steps/reporting/undefined_feature_reporting.rb