samstokes-rspec-stories 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. data/History.txt +9 -0
  2. data/License.txt +22 -0
  3. data/Manifest.txt +79 -0
  4. data/README.txt +23 -0
  5. data/Rakefile +87 -0
  6. data/init.rb +4 -0
  7. data/lib/spec/runner/formatter/story/html_formatter.rb +174 -0
  8. data/lib/spec/runner/formatter/story/plain_text_formatter.rb +194 -0
  9. data/lib/spec/runner/formatter/story/progress_bar_formatter.rb +42 -0
  10. data/lib/spec/runner/options_extensions.rb +25 -0
  11. data/lib/spec/stories.rb +11 -0
  12. data/lib/spec/story/extensions.rb +3 -0
  13. data/lib/spec/story/extensions/main.rb +86 -0
  14. data/lib/spec/story/extensions/regexp.rb +9 -0
  15. data/lib/spec/story/extensions/string.rb +9 -0
  16. data/lib/spec/story/given_scenario.rb +14 -0
  17. data/lib/spec/story/runner.rb +57 -0
  18. data/lib/spec/story/runner/plain_text_story_runner.rb +48 -0
  19. data/lib/spec/story/runner/scenario_collector.rb +18 -0
  20. data/lib/spec/story/runner/scenario_runner.rb +54 -0
  21. data/lib/spec/story/runner/story_mediator.rb +137 -0
  22. data/lib/spec/story/runner/story_parser.rb +247 -0
  23. data/lib/spec/story/runner/story_runner.rb +74 -0
  24. data/lib/spec/story/scenario.rb +14 -0
  25. data/lib/spec/story/step.rb +70 -0
  26. data/lib/spec/story/step_group.rb +89 -0
  27. data/lib/spec/story/step_mother.rb +38 -0
  28. data/lib/spec/story/story.rb +39 -0
  29. data/lib/spec/story/version.rb +15 -0
  30. data/lib/spec/story/world.rb +124 -0
  31. data/resources/rake/verify_rcov.rake +7 -0
  32. data/rspec-stories.gemspec +35 -0
  33. data/spec/spec.opts +6 -0
  34. data/spec/spec/runner/formatter/story/html_formatter_spec.rb +135 -0
  35. data/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb +600 -0
  36. data/spec/spec/runner/formatter/story/progress_bar_formatter_spec.rb +82 -0
  37. data/spec/spec/runner/most_recent_spec.rb +0 -0
  38. data/spec/spec/runner/options_extensions_spec.rb +31 -0
  39. data/spec/spec/runner/resources/a_bar.rb +0 -0
  40. data/spec/spec/runner/resources/a_foo.rb +0 -0
  41. data/spec/spec/runner/resources/a_spec.rb +1 -0
  42. data/spec/spec/runner/resources/custom_example_group_runner.rb +14 -0
  43. data/spec/spec/runner/resources/utf8_encoded.rb +7 -0
  44. data/spec/spec/runner_spec.rb +11 -0
  45. data/spec/spec/spec_classes.rb +133 -0
  46. data/spec/spec/story/builders.rb +46 -0
  47. data/spec/spec/story/extensions/main_spec.rb +161 -0
  48. data/spec/spec/story/extensions_spec.rb +14 -0
  49. data/spec/spec/story/given_scenario_spec.rb +27 -0
  50. data/spec/spec/story/runner/plain_text_story_runner_spec.rb +90 -0
  51. data/spec/spec/story/runner/scenario_collector_spec.rb +27 -0
  52. data/spec/spec/story/runner/scenario_runner_spec.rb +214 -0
  53. data/spec/spec/story/runner/story_mediator_spec.rb +143 -0
  54. data/spec/spec/story/runner/story_parser_spec.rb +401 -0
  55. data/spec/spec/story/runner/story_runner_spec.rb +294 -0
  56. data/spec/spec/story/runner_spec.rb +93 -0
  57. data/spec/spec/story/scenario_spec.rb +18 -0
  58. data/spec/spec/story/step_group_spec.rb +157 -0
  59. data/spec/spec/story/step_mother_spec.rb +84 -0
  60. data/spec/spec/story/step_spec.rb +272 -0
  61. data/spec/spec/story/story_helper.rb +2 -0
  62. data/spec/spec/story/story_spec.rb +84 -0
  63. data/spec/spec/story/world_spec.rb +423 -0
  64. data/spec/spec_helper.rb +84 -0
  65. data/story_server/prototype/javascripts/builder.js +136 -0
  66. data/story_server/prototype/javascripts/controls.js +972 -0
  67. data/story_server/prototype/javascripts/dragdrop.js +976 -0
  68. data/story_server/prototype/javascripts/effects.js +1117 -0
  69. data/story_server/prototype/javascripts/prototype.js +4140 -0
  70. data/story_server/prototype/javascripts/rspec.js +149 -0
  71. data/story_server/prototype/javascripts/scriptaculous.js +58 -0
  72. data/story_server/prototype/javascripts/slider.js +276 -0
  73. data/story_server/prototype/javascripts/sound.js +55 -0
  74. data/story_server/prototype/javascripts/unittest.js +568 -0
  75. data/story_server/prototype/lib/server.rb +24 -0
  76. data/story_server/prototype/stories.html +176 -0
  77. data/story_server/prototype/stylesheets/rspec.css +136 -0
  78. data/story_server/prototype/stylesheets/test.css +90 -0
  79. metadata +154 -0
data/History.txt ADDED
@@ -0,0 +1,9 @@
1
+ === Version 1.0.1 / 2009-05-11
2
+
3
+ * A couple of ad-hoc fixes, documented on wiki.
4
+
5
+ === Version 0.9.0.0 / 2009-01-09
6
+
7
+ * Major enhancements
8
+
9
+ * Extracted RSpec's Story Runner into it's own gem.
data/License.txt ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2005-2008 The RSpec Development Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,79 @@
1
+ History.txt
2
+ License.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ init.rb
7
+ lib/spec/rails/story_adapter.rb
8
+ lib/spec/runner/formatter/story/html_formatter.rb
9
+ lib/spec/runner/formatter/story/plain_text_formatter.rb
10
+ lib/spec/runner/formatter/story/progress_bar_formatter.rb
11
+ lib/spec/runner/options_extensions.rb
12
+ lib/spec/stories.rb
13
+ lib/spec/story/extensions.rb
14
+ lib/spec/story/extensions/main.rb
15
+ lib/spec/story/extensions/regexp.rb
16
+ lib/spec/story/extensions/string.rb
17
+ lib/spec/story/given_scenario.rb
18
+ lib/spec/story/runner.rb
19
+ lib/spec/story/runner/plain_text_story_runner.rb
20
+ lib/spec/story/runner/scenario_collector.rb
21
+ lib/spec/story/runner/scenario_runner.rb
22
+ lib/spec/story/runner/story_mediator.rb
23
+ lib/spec/story/runner/story_parser.rb
24
+ lib/spec/story/runner/story_runner.rb
25
+ lib/spec/story/scenario.rb
26
+ lib/spec/story/step.rb
27
+ lib/spec/story/step_group.rb
28
+ lib/spec/story/step_mother.rb
29
+ lib/spec/story/story.rb
30
+ lib/spec/story/version.rb
31
+ lib/spec/story/world.rb
32
+ resources/rake/verify_rcov.rake
33
+ rspec-stories.gemspec
34
+ spec/spec.opts
35
+ spec/spec/runner/formatter/story/html_formatter_spec.rb
36
+ spec/spec/runner/formatter/story/plain_text_formatter_spec.rb
37
+ spec/spec/runner/formatter/story/progress_bar_formatter_spec.rb
38
+ spec/spec/runner/most_recent_spec.rb
39
+ spec/spec/runner/options_extensions_spec.rb
40
+ spec/spec/runner/resources/a_bar.rb
41
+ spec/spec/runner/resources/a_foo.rb
42
+ spec/spec/runner/resources/a_spec.rb
43
+ spec/spec/runner/resources/custom_example_group_runner.rb
44
+ spec/spec/runner/resources/utf8_encoded.rb
45
+ spec/spec/runner_spec.rb
46
+ spec/spec/spec_classes.rb
47
+ spec/spec/story/builders.rb
48
+ spec/spec/story/extensions/main_spec.rb
49
+ spec/spec/story/extensions_spec.rb
50
+ spec/spec/story/given_scenario_spec.rb
51
+ spec/spec/story/runner/plain_text_story_runner_spec.rb
52
+ spec/spec/story/runner/scenario_collector_spec.rb
53
+ spec/spec/story/runner/scenario_runner_spec.rb
54
+ spec/spec/story/runner/story_mediator_spec.rb
55
+ spec/spec/story/runner/story_parser_spec.rb
56
+ spec/spec/story/runner/story_runner_spec.rb
57
+ spec/spec/story/runner_spec.rb
58
+ spec/spec/story/scenario_spec.rb
59
+ spec/spec/story/step_group_spec.rb
60
+ spec/spec/story/step_mother_spec.rb
61
+ spec/spec/story/step_spec.rb
62
+ spec/spec/story/story_helper.rb
63
+ spec/spec/story/story_spec.rb
64
+ spec/spec/story/world_spec.rb
65
+ spec/spec_helper.rb
66
+ story_server/prototype/javascripts/builder.js
67
+ story_server/prototype/javascripts/controls.js
68
+ story_server/prototype/javascripts/dragdrop.js
69
+ story_server/prototype/javascripts/effects.js
70
+ story_server/prototype/javascripts/prototype.js
71
+ story_server/prototype/javascripts/rspec.js
72
+ story_server/prototype/javascripts/scriptaculous.js
73
+ story_server/prototype/javascripts/slider.js
74
+ story_server/prototype/javascripts/sound.js
75
+ story_server/prototype/javascripts/unittest.js
76
+ story_server/prototype/lib/server.rb
77
+ story_server/prototype/stories.html
78
+ story_server/prototype/stylesheets/rspec.css
79
+ story_server/prototype/stylesheets/test.css
data/README.txt ADDED
@@ -0,0 +1,23 @@
1
+ = RSpec Story Runner
2
+
3
+ * http://rspec.info
4
+ * http://rubyforge.org/projects/rspec-stories
5
+ * http://github.com/dchelimsky/rspec/wikis
6
+ * mailto:rspec-devel@rubyforge.org
7
+
8
+ == DESCRIPTION:
9
+
10
+ This is the RSpec Story Runner (formerly RBehave) extracted from RSpec. We extracted it because Cucumber (http://github.com/aslakhellesoy/cucumber) is the new Story Runner, so we don't plan to maintain the original Story Runner any longer, but we don't want to force you to migrate to Cucumber in order to upgrade RSpec (which will no longer ship with the Story Runner).
11
+
12
+ Many thanks to Chad Humphries for extracting this out from RSpec and untangling a few dependencies so this could stand on its own as a gem.
13
+
14
+ == INSTALL:
15
+
16
+ [sudo] gem install dchelimsky-rspec-stories
17
+
18
+ or
19
+
20
+ git clone git://github.com/dchelimsky/rspec-stories.git
21
+ cd rspec-stories
22
+ rake gem
23
+ rake install_gem
data/Rakefile ADDED
@@ -0,0 +1,87 @@
1
+ # -*- ruby -*-
2
+
3
+ $:.unshift(File.join(File.dirname(__FILE__), 'lib'))
4
+ require 'rubygems'
5
+ require 'hoe'
6
+ require 'spec/story/version'
7
+ require 'spec/rake/spectask'
8
+
9
+ class Hoe
10
+ def extra_deps
11
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
12
+ @extra_deps
13
+ end
14
+ end
15
+
16
+ Hoe.new('rspec-stories', Spec::Story::VERSION::STRING) do |p|
17
+ p.summary = Spec::Story::VERSION::SUMMARY
18
+ p.url = 'http://rspec.info/'
19
+ p.description = "Behaviour Driven Development for Ruby."
20
+ p.rubyforge_name = 'rspec-stories'
21
+ p.developer('RSpec Development Team', 'rspec-devel@rubyforge.org')
22
+ p.extra_deps = [["rspec",">= 1.1.11"]]
23
+ p.remote_rdoc_dir = "rspec-stories/#{Spec::Story::VERSION::STRING}"
24
+ end
25
+
26
+ ['audit','test','test_deps','default','post_blog'].each do |task|
27
+ Rake.application.instance_variable_get('@tasks').delete(task)
28
+ end
29
+
30
+ task :verify_rcov => :spec
31
+ task :default => :verify_rcov
32
+
33
+ load File.dirname(__FILE__) + '/resources/rake/verify_rcov.rake'
34
+
35
+ desc "Run all specs"
36
+ Spec::Rake::SpecTask.new do |t|
37
+ t.spec_files = FileList['spec/**/*_spec.rb']
38
+ t.spec_opts = ['--options', 'spec/spec.opts']
39
+ unless ENV['NO_RCOV']
40
+ t.rcov = true
41
+ t.rcov_dir = 'coverage'
42
+ t.rcov_opts = ['--exclude', "lib/spec.rb,lib/spec/runner.rb,spec\/spec,bin\/spec,examples,\/gems,\/Library\/Ruby,\.autotest,#{ENV['GEM_HOME']}"]
43
+ end
44
+ end
45
+
46
+ def egrep(pattern)
47
+ Dir['**/*.rb'].each do |fn|
48
+ count = 0
49
+ open(fn) do |f|
50
+ while line = f.gets
51
+ count += 1
52
+ if line =~ pattern
53
+ puts "#{fn}:#{count}:#{line}"
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ desc "Look for TODO and FIXME tags in the code"
61
+ task :todo do
62
+ egrep /(FIXME|TODO|TBD)/
63
+ end
64
+
65
+ desc "verify_committed, verify_rcov, post_news, release"
66
+ task :complete_release => [:verify_committed, :verify_rcov, :post_news, :release]
67
+
68
+ desc "Verifies that there is no uncommitted code"
69
+ task :verify_committed do
70
+ IO.popen('git status') do |io|
71
+ io.each_line do |line|
72
+ raise "\n!!! Do a git commit first !!!\n\n" if line =~ /^#\s*modified:/
73
+ end
74
+ end
75
+ end
76
+
77
+ namespace :update do
78
+ desc "update the manfest"
79
+ task :manifest do
80
+ system %q[touch Manifest.txt; rake check_manifest | grep -v "(in " | patch]
81
+ end
82
+
83
+ desc "update the gemspec"
84
+ task :gemspec do
85
+ system %q[rake debug_gem | grep -v "(in " | grep -v "s.add_dependency(%q<hoe" > `basename \\`pwd\\``.gemspec]
86
+ end
87
+ end
data/init.rb ADDED
@@ -0,0 +1,4 @@
1
+ # Placeholder to satisfy Rails.
2
+ #
3
+ # Do NOT add any require statements to this file. Doing
4
+ # so will cause Rails to load this plugin all of the time.
@@ -0,0 +1,174 @@
1
+ require 'erb'
2
+ require 'spec/runner/formatter/base_text_formatter'
3
+
4
+ module Spec
5
+ module Runner
6
+ module Formatter
7
+ module Story
8
+ class HtmlFormatter < BaseTextFormatter
9
+ include ERB::Util
10
+
11
+ def initialize(options, where)
12
+ super
13
+ @previous_type = nil
14
+ @scenario_text = ""
15
+ @story_text = ""
16
+ @scenario_failed = false
17
+ @story_failed = false
18
+ end
19
+
20
+ def run_started(count)
21
+ @output.puts <<-EOF
22
+ <?xml version="1.0" encoding="UTF-8"?>
23
+ <!DOCTYPE html
24
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
25
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
26
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
27
+ <head>
28
+ <title>Stories</title>
29
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
30
+ <meta http-equiv="Expires" content="-1" />
31
+ <meta http-equiv="Pragma" content="no-cache" />
32
+ <script src="javascripts/prototype.js" type="text/javascript"></script>
33
+ <script src="javascripts/scriptaculous.js" type="text/javascript"></script>
34
+ <script src="javascripts/rspec.js" type="text/javascript"></script>
35
+ <link href="stylesheets/rspec.css" rel="stylesheet" type="text/css" />
36
+ </head>
37
+ <body>
38
+ <div id="container">
39
+ EOF
40
+ end
41
+
42
+ def collected_steps(steps)
43
+ unless steps.empty?
44
+ @output.puts " <ul id=\"stock_steps\" style=\"display: none;\">"
45
+ steps.each do |step|
46
+ @output.puts " <li>#{step}</li>"
47
+ end
48
+ @output.puts " </ul>"
49
+ end
50
+ end
51
+
52
+ def run_ended
53
+ @output.puts <<-EOF
54
+ </div>
55
+ </body>
56
+ </head>
57
+ EOF
58
+ end
59
+
60
+ def story_started(title, narrative)
61
+ @story_failed = false
62
+ @story_text = <<-EOF
63
+ <dt>Story: #{h title}</dt>
64
+ <dd>
65
+ <p>
66
+ #{h(narrative).split("\n").join("<br />")}
67
+ </p>
68
+ EOF
69
+ end
70
+
71
+ def story_ended(title, narrative)
72
+ if @story_failed
73
+ @output.puts <<-EOF
74
+ <dl class="story failed">
75
+ EOF
76
+ else
77
+ @output.puts <<-EOF
78
+ <dl class="story passed">
79
+ EOF
80
+ end
81
+ @output.puts <<-EOF
82
+ #{@story_text}
83
+ </dd>
84
+ </dl>
85
+ EOF
86
+ end
87
+
88
+ def scenario_started(story_title, scenario_name)
89
+ @previous_type = nil
90
+ @scenario_failed = false
91
+ @scenario_text = <<-EOF
92
+ <dt>Scenario: #{h scenario_name}</dt>
93
+ <dd>
94
+ <ul class="steps">
95
+ EOF
96
+ end
97
+
98
+ def scenario_ended
99
+ if @scenario_failed
100
+ @story_text += <<-EOF
101
+ <dl class="failed">
102
+ EOF
103
+ else
104
+ @story_text += <<-EOF
105
+ <dl class="passed">
106
+ EOF
107
+ end
108
+
109
+ @story_text += <<-EOF
110
+ #{@scenario_text}
111
+ </ul>
112
+ </dd>
113
+ </dl>
114
+ EOF
115
+ end
116
+
117
+ def found_scenario(type, description)
118
+ end
119
+
120
+ def scenario_succeeded(story_title, scenario_name)
121
+ scenario_ended
122
+ end
123
+
124
+ def scenario_pending(story_title, scenario_name, reason)
125
+ scenario_ended
126
+ end
127
+
128
+ def scenario_failed(story_title, scenario_name, err)
129
+ @scenario_failed = true
130
+ @story_failed = true
131
+ scenario_ended
132
+ end
133
+
134
+ def step_upcoming(type, description, *args)
135
+ end
136
+
137
+ def step_succeeded(type, description, *args)
138
+ print_step('passed', type, description, *args) # TODO: uses succeeded CSS class
139
+ end
140
+
141
+ def step_pending(type, description, *args)
142
+ print_step('pending', type, description, *args)
143
+ end
144
+
145
+ def step_failed(type, description, *args)
146
+ print_step('failed', type, description, *args)
147
+ end
148
+
149
+ def print_step(klass, type, description, *args)
150
+ spans = args.map { |arg| "<span class=\"param\">#{arg}</span>" }
151
+ desc_string = description.step_name
152
+ arg_regexp = description.arg_regexp
153
+ inner = if(type == @previous_type)
154
+ "And "
155
+ else
156
+ "#{type.to_s.capitalize} "
157
+ end
158
+ i = -1
159
+ inner += desc_string.gsub(arg_regexp) { |param| spans[i+=1] }
160
+
161
+ @scenario_text += " <li class=\"#{klass}\">#{inner}</li>\n"
162
+
163
+ if type == :'given scenario'
164
+ @previous_type = :given
165
+ else
166
+ @previous_type = type
167
+ end
168
+
169
+ end
170
+ end
171
+ end
172
+ end
173
+ end
174
+ end
@@ -0,0 +1,194 @@
1
+ require 'spec/runner/formatter/base_text_formatter'
2
+
3
+ module Spec
4
+ module Runner
5
+ module Formatter
6
+ module Story
7
+ class PlainTextFormatter < ::Spec::Runner::Formatter::BaseTextFormatter
8
+ def initialize(options, where)
9
+ super
10
+ @successful_scenario_count = 0
11
+ @pending_scenario_count = 0
12
+
13
+ @pre_story_pending_count = 0
14
+ @pre_story_successful_count = 0
15
+
16
+ @failed_scenarios = []
17
+ @pending_steps = []
18
+ @previous_type = nil
19
+
20
+ @scenario_body_text = ""
21
+ @story_body_text = ""
22
+
23
+ @scenario_head_text = ""
24
+ @story_head_text = ""
25
+
26
+ @scenario_failed = false
27
+ @story_failed = false
28
+ end
29
+
30
+ def run_started(count)
31
+ @count = count
32
+ @output.puts "Running #@count scenarios\n\n"
33
+ end
34
+
35
+ def story_started(title, narrative)
36
+ @pre_story_pending_count = @pending_scenario_count
37
+ @pre_story_successful_count = @successful_scenario_count
38
+
39
+ @current_story_title = title
40
+ @story_failed = false
41
+ @story_body_text = ""
42
+ @story_head_text = "Story: #{title}\n\n"
43
+
44
+ narrative.each_line do |line|
45
+ @story_head_text += " "
46
+ @story_head_text += line
47
+ end
48
+ end
49
+
50
+ def story_ended(title, narrative)
51
+ if @story_failed
52
+ @output.print red(@story_head_text)
53
+ elsif @pre_story_successful_count == @successful_scenario_count &&
54
+ @pending_scenario_count >= @pre_story_pending_count
55
+ @output.print yellow(@story_head_text)
56
+ else
57
+ @output.print green(@story_head_text)
58
+ end
59
+ @output.print @story_body_text
60
+ @output.puts
61
+ @output.puts
62
+ end
63
+
64
+ def scenario_started(story_title, scenario_name)
65
+ @current_scenario_name = scenario_name
66
+ @scenario_already_failed = false
67
+ @scenario_head_text = "\n\n Scenario: #{scenario_name}"
68
+ @scenario_body_text = ""
69
+ @scenario_ok = true
70
+ @scenario_pending = false
71
+ @scenario_failed = false
72
+ end
73
+
74
+ def scenario_succeeded(story_title, scenario_name)
75
+ @successful_scenario_count += 1
76
+ scenario_ended
77
+ end
78
+
79
+ def scenario_failed(story_title, scenario_name, err)
80
+ @options.backtrace_tweaker.tweak_backtrace(err) if @options.backtrace_tweaker
81
+ @failed_scenarios << [story_title, scenario_name, err] unless @scenario_already_failed
82
+ @scenario_already_failed = true
83
+ @story_failed = true
84
+ @scenario_failed = true
85
+ scenario_ended
86
+ end
87
+
88
+ def scenario_pending(story_title, scenario_name, msg)
89
+ @pending_scenario_count += 1 unless @scenario_already_failed
90
+ @scenario_pending = true
91
+ @scenario_already_failed = true
92
+ scenario_ended
93
+ end
94
+
95
+ def scenario_ended
96
+ if @scenario_failed
97
+ @story_body_text += red(@scenario_head_text)
98
+ elsif @scenario_pending
99
+ @story_body_text += yellow(@scenario_head_text)
100
+ else
101
+ @story_body_text += green(@scenario_head_text)
102
+ end
103
+ @story_body_text += @scenario_body_text
104
+ end
105
+
106
+ def run_ended
107
+ summary_text = "#@count scenarios: #@successful_scenario_count succeeded, #{@failed_scenarios.size} failed, #@pending_scenario_count pending"
108
+ if !@failed_scenarios.empty?
109
+ @output.puts red(summary_text)
110
+ elsif !@pending_steps.empty?
111
+ @output.puts yellow(summary_text)
112
+ else
113
+ @output.puts green(summary_text)
114
+ end
115
+ unless @pending_steps.empty?
116
+ @output.puts "\nPending Steps:"
117
+ @pending_steps.each_with_index do |pending, i|
118
+ story_name, scenario_name, msg = pending
119
+ @output.puts "#{i+1}) #{story_name} (#{scenario_name}): #{msg}"
120
+ end
121
+ end
122
+ unless @failed_scenarios.empty?
123
+ @output.print "\nFAILURES:"
124
+ @failed_scenarios.each_with_index do |failure, i|
125
+ title, scenario_name, err = failure
126
+ @output.print "\n #{i+1}) "
127
+ @output.print red("#{title} (#{scenario_name}) FAILED")
128
+ @output.print red("\n #{err.class}: #{err.message}")
129
+ @output.print "\n #{err.backtrace.join("\n")}\n"
130
+ end
131
+ end
132
+ end
133
+
134
+ def step_upcoming(type, description, *args)
135
+ end
136
+
137
+ def step_succeeded(type, description, *args)
138
+ found_step(type, description, false, false, *args)
139
+ end
140
+
141
+ def step_pending(type, description, *args)
142
+ found_step(type, description, false, true, *args)
143
+ @pending_steps << [@current_story_title, @current_scenario_name, description]
144
+ @scenario_body_text += yellow(" (PENDING)")
145
+ @scenario_pending = true
146
+ @scenario_ok = false
147
+ end
148
+
149
+ def step_failed(type, description, *args)
150
+ found_step(type, description, true, @scenario_pending, *args)
151
+ if @scenario_pending
152
+ @scenario_body_text += yellow(" (SKIPPED)")
153
+ else
154
+ @scenario_body_text += red(@scenario_ok ? " (FAILED)" : " (SKIPPED)")
155
+ end
156
+ @scenario_ok = false
157
+ end
158
+
159
+ def collected_steps(steps)
160
+ end
161
+
162
+ def method_missing(sym, *args, &block) #:nodoc:
163
+ # noop - ignore unknown messages
164
+ end
165
+
166
+ private
167
+
168
+ def found_step(type, description, failed, pending, *args)
169
+ desc_string = description.step_name
170
+ arg_regexp = description.arg_regexp
171
+ text = if(type == @previous_type)
172
+ "\n And "
173
+ else
174
+ "\n\n #{type.to_s.capitalize} "
175
+ end
176
+ i = -1
177
+ text << desc_string.gsub(arg_regexp) { |param| args[i+=1] }
178
+ if pending
179
+ @scenario_body_text += yellow(text)
180
+ else
181
+ @scenario_body_text += (failed ? red(text) : green(text))
182
+ end
183
+
184
+ if type == :'given scenario'
185
+ @previous_type = :given
186
+ else
187
+ @previous_type = type
188
+ end
189
+ end
190
+ end
191
+ end
192
+ end
193
+ end
194
+ end