rspec 1.1.4 → 1.1.5
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/{CHANGES → History.txt} +116 -64
- data/Manifest.txt +403 -0
- data/{MIT-LICENSE → README.txt} +43 -0
- data/Rakefile +39 -212
- data/{TODO → TODO.txt} +0 -0
- data/bin/autospec +4 -0
- data/bin/spec +1 -1
- data/examples/pure/yielding_example.rb +33 -0
- data/examples/stories/game-of-life/.loadpath +5 -0
- data/examples/stories/game-of-life/behaviour/everything.rb +1 -1
- data/examples/stories/game-of-life/behaviour/stories/CellsWithMoreThanThreeNeighboursDie.story +17 -17
- data/init.rb +9 -0
- data/lib/autotest/discover.rb +1 -1
- data/lib/autotest/rspec.rb +3 -29
- data/lib/spec.rb +10 -12
- data/lib/spec/adapters.rb +1 -0
- data/lib/spec/adapters/ruby_engine.rb +26 -0
- data/lib/spec/adapters/ruby_engine/mri.rb +8 -0
- data/lib/spec/adapters/ruby_engine/rubinius.rb +8 -0
- data/lib/spec/example/errors.rb +6 -0
- data/lib/spec/example/example_group_methods.rb +17 -14
- data/lib/spec/example/example_matcher.rb +2 -0
- data/lib/spec/example/example_methods.rb +4 -9
- data/lib/spec/example/module_inclusion_warnings.rb +2 -1
- data/lib/spec/expectations/extensions/object.rb +2 -2
- data/lib/spec/expectations/handler.rb +8 -16
- data/lib/spec/extensions/main.rb +2 -17
- data/lib/spec/matchers.rb +8 -2
- data/lib/spec/matchers/be.rb +0 -3
- data/lib/spec/matchers/change.rb +44 -40
- data/lib/spec/matchers/has.rb +1 -1
- data/lib/spec/matchers/have.rb +17 -12
- data/lib/spec/matchers/operator_matcher.rb +10 -4
- data/lib/spec/matchers/simple_matcher.rb +113 -10
- data/lib/spec/mocks.rb +1 -1
- data/lib/spec/mocks/argument_constraints.rb +185 -0
- data/lib/spec/mocks/argument_expectation.rb +35 -173
- data/lib/spec/mocks/framework.rb +1 -1
- data/lib/spec/mocks/message_expectation.rb +30 -5
- data/lib/spec/mocks/methods.rb +14 -2
- data/lib/spec/mocks/mock.rb +4 -0
- data/lib/spec/mocks/proxy.rb +46 -5
- data/lib/spec/mocks/spec_methods.rb +9 -1
- data/lib/spec/rake/spectask.rb +14 -22
- data/lib/spec/rake/verify_rcov.rb +3 -3
- data/lib/spec/runner.rb +18 -6
- data/lib/spec/runner/backtrace_tweaker.rb +6 -7
- data/lib/spec/runner/command_line.rb +6 -17
- data/lib/spec/runner/drb_command_line.rb +1 -1
- data/lib/spec/runner/formatter/base_formatter.rb +3 -1
- data/lib/spec/runner/formatter/base_text_formatter.rb +5 -9
- data/lib/spec/runner/formatter/html_formatter.rb +1 -1
- data/lib/spec/runner/formatter/nested_text_formatter.rb +1 -1
- data/lib/spec/runner/formatter/progress_bar_formatter.rb +2 -2
- data/lib/spec/runner/formatter/specdoc_formatter.rb +1 -1
- data/lib/spec/runner/formatter/story/html_formatter.rb +62 -16
- data/lib/spec/runner/formatter/story/plain_text_formatter.rb +68 -16
- data/lib/spec/runner/formatter/story/progress_bar_formatter.rb +42 -0
- data/lib/spec/runner/heckle_runner.rb +2 -2
- data/lib/spec/runner/option_parser.rb +2 -1
- data/lib/spec/runner/options.rb +18 -9
- data/lib/spec/runner/reporter.rb +24 -4
- data/lib/spec/runner/spec_parser.rb +1 -1
- data/lib/spec/story/runner.rb +1 -2
- data/lib/spec/story/runner/story_mediator.rb +14 -0
- data/lib/spec/story/runner/story_parser.rb +20 -0
- data/lib/spec/story/step.rb +40 -28
- data/lib/spec/story/step_mother.rb +2 -1
- data/lib/spec/story/world.rb +6 -2
- data/lib/spec/version.rb +13 -22
- data/rake_tasks/failing_examples_with_html.rake +1 -1
- data/rake_tasks/verify_rcov.rake +2 -2
- data/rspec.gemspec +33 -0
- data/spec/autotest/rspec_spec.rb +90 -141
- data/spec/spec/adapters/ruby_engine_spec.rb +16 -0
- data/spec/spec/example/base_formatter_spec.rb +112 -0
- data/spec/spec/example/example_group_factory_spec.rb +2 -2
- data/spec/spec/example/example_group_methods_spec.rb +55 -4
- data/spec/spec/example/example_group_spec.rb +4 -3
- data/spec/spec/example/example_methods_spec.rb +18 -14
- data/spec/spec/example/pending_module_spec.rb +38 -0
- data/spec/spec/example/shared_example_group_spec.rb +1 -1
- data/spec/spec/expectations/extensions/object_spec.rb +0 -12
- data/spec/spec/extensions/main_spec.rb +3 -8
- data/spec/spec/matchers/change_spec.rb +16 -6
- data/spec/spec/matchers/handler_spec.rb +58 -37
- data/spec/spec/matchers/has_spec.rb +10 -0
- data/spec/spec/matchers/have_spec.rb +105 -2
- data/spec/spec/matchers/operator_matcher_spec.rb +35 -2
- data/spec/spec/matchers/simple_matcher_spec.rb +64 -2
- data/spec/spec/mocks/any_number_of_times_spec.rb +7 -0
- data/spec/spec/mocks/bug_report_496.rb +17 -0
- data/spec/spec/mocks/failing_mock_argument_constraints_spec.rb +7 -1
- data/spec/spec/mocks/hash_including_matcher_spec.rb +45 -24
- data/spec/spec/mocks/mock_spec.rb +55 -10
- data/spec/spec/mocks/nil_expectation_warning_spec.rb +54 -0
- data/spec/spec/mocks/null_object_mock_spec.rb +14 -0
- data/spec/spec/mocks/options_hash_spec.rb +18 -28
- data/spec/spec/mocks/partial_mock_spec.rb +2 -0
- data/spec/spec/mocks/passing_mock_argument_constraints_spec.rb +20 -6
- data/spec/spec/mocks/stub_spec.rb +7 -0
- data/spec/spec/runner/command_line_spec.rb +5 -12
- data/spec/spec/runner/drb_command_line_spec.rb +13 -6
- data/spec/spec/runner/formatter/html_formatter_spec.rb +2 -1
- data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +3 -3
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +20 -2
- data/spec/spec/runner/formatter/spec_mate_formatter_spec.rb +2 -1
- data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +3 -3
- data/spec/spec/runner/formatter/story/html_formatter_spec.rb +76 -2
- data/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb +161 -0
- data/spec/spec/runner/formatter/story/progress_bar_formatter_spec.rb +82 -0
- data/spec/spec/runner/heckle_runner_spec.rb +8 -8
- data/spec/spec/runner/option_parser_spec.rb +21 -6
- data/spec/spec/runner/output_one_time_fixture_runner.rb +1 -1
- data/spec/spec/runner/quiet_backtrace_tweaker_spec.rb +6 -0
- data/spec/spec/runner/reporter_spec.rb +51 -5
- data/spec/spec/runner/spec_parser_spec.rb +4 -4
- data/spec/spec/story/runner/plain_text_story_runner_spec.rb +2 -5
- data/spec/spec/story/runner/story_mediator_spec.rb +10 -0
- data/spec/spec/story/runner/story_parser_spec.rb +23 -6
- data/spec/spec/story/scenario_spec.rb +1 -3
- data/spec/spec/story/step_mother_spec.rb +12 -0
- data/spec/spec/story/step_spec.rb +57 -4
- data/spec/spec/story/story_spec.rb +1 -3
- data/spec/spec/story/world_spec.rb +1 -1
- data/spec/spec_helper.rb +21 -68
- data/stories/all.rb +1 -1
- data/stories/configuration/before_blocks.story +21 -0
- data/stories/configuration/stories.rb +7 -0
- data/stories/example_groups/stories.rb +3 -4
- data/stories/resources/spec/before_blocks_example.rb +32 -0
- data/stories/stories/multiline_steps.story +23 -0
- data/stories/stories/steps/multiline_steps.rb +13 -0
- data/stories/stories/stories.rb +6 -0
- data/story_server/prototype/javascripts/builder.js +136 -0
- data/story_server/prototype/javascripts/controls.js +972 -0
- data/story_server/prototype/javascripts/dragdrop.js +976 -0
- data/story_server/prototype/javascripts/effects.js +1117 -0
- data/story_server/prototype/javascripts/prototype.js +4140 -0
- data/story_server/prototype/javascripts/rspec.js +149 -0
- data/story_server/prototype/javascripts/scriptaculous.js +58 -0
- data/story_server/prototype/javascripts/slider.js +276 -0
- data/story_server/prototype/javascripts/sound.js +55 -0
- data/story_server/prototype/javascripts/unittest.js +568 -0
- data/story_server/prototype/lib/server.rb +24 -0
- data/story_server/prototype/stories.html +176 -0
- data/story_server/prototype/stylesheets/rspec.css +136 -0
- data/story_server/prototype/stylesheets/test.css +90 -0
- metadata +166 -166
- data/README +0 -36
- data/UPGRADE +0 -7
- data/bin/spec_translator +0 -8
- data/lib/spec/mocks/argument_constraint_matchers.rb +0 -31
- data/lib/spec/translator.rb +0 -114
- data/spec/spec/example/example_spec.rb +0 -53
- data/spec/spec/runner/execution_context_spec.rb +0 -37
- data/spec/spec/translator_spec.rb +0 -265
|
@@ -9,9 +9,22 @@ module Spec
|
|
|
9
9
|
super
|
|
10
10
|
@successful_scenario_count = 0
|
|
11
11
|
@pending_scenario_count = 0
|
|
12
|
+
|
|
13
|
+
@pre_story_pending_count = 0
|
|
14
|
+
@pre_story_successful_count = 0
|
|
15
|
+
|
|
12
16
|
@failed_scenarios = []
|
|
13
17
|
@pending_steps = []
|
|
14
|
-
@previous_type = nil
|
|
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
|
|
15
28
|
end
|
|
16
29
|
|
|
17
30
|
def run_started(count)
|
|
@@ -20,15 +33,30 @@ module Spec
|
|
|
20
33
|
end
|
|
21
34
|
|
|
22
35
|
def story_started(title, narrative)
|
|
36
|
+
@pre_story_pending_count = @pending_scenario_count
|
|
37
|
+
@pre_story_successful_count = @successful_scenario_count
|
|
38
|
+
|
|
23
39
|
@current_story_title = title
|
|
24
|
-
@
|
|
40
|
+
@story_failed = false
|
|
41
|
+
@story_body_text = ""
|
|
42
|
+
@story_head_text = "Story: #{title}\n\n"
|
|
43
|
+
|
|
25
44
|
narrative.each_line do |line|
|
|
26
|
-
@
|
|
27
|
-
@
|
|
45
|
+
@story_head_text += " "
|
|
46
|
+
@story_head_text += line
|
|
28
47
|
end
|
|
29
48
|
end
|
|
30
49
|
|
|
31
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
|
|
32
60
|
@output.puts
|
|
33
61
|
@output.puts
|
|
34
62
|
end
|
|
@@ -36,29 +64,54 @@ module Spec
|
|
|
36
64
|
def scenario_started(story_title, scenario_name)
|
|
37
65
|
@current_scenario_name = scenario_name
|
|
38
66
|
@scenario_already_failed = false
|
|
39
|
-
@
|
|
67
|
+
@scenario_head_text = "\n\n Scenario: #{scenario_name}"
|
|
68
|
+
@scenario_body_text = ""
|
|
40
69
|
@scenario_ok = true
|
|
41
70
|
@scenario_pending = false
|
|
71
|
+
@scenario_failed = false
|
|
42
72
|
end
|
|
43
73
|
|
|
44
74
|
def scenario_succeeded(story_title, scenario_name)
|
|
45
75
|
@successful_scenario_count += 1
|
|
76
|
+
scenario_ended
|
|
46
77
|
end
|
|
47
78
|
|
|
48
79
|
def scenario_failed(story_title, scenario_name, err)
|
|
49
80
|
@options.backtrace_tweaker.tweak_backtrace(err)
|
|
50
81
|
@failed_scenarios << [story_title, scenario_name, err] unless @scenario_already_failed
|
|
51
82
|
@scenario_already_failed = true
|
|
83
|
+
@story_failed = true
|
|
84
|
+
@scenario_failed = true
|
|
85
|
+
scenario_ended
|
|
52
86
|
end
|
|
53
87
|
|
|
54
88
|
def scenario_pending(story_title, scenario_name, msg)
|
|
55
89
|
@pending_scenario_count += 1 unless @scenario_already_failed
|
|
56
90
|
@scenario_pending = true
|
|
57
91
|
@scenario_already_failed = true
|
|
92
|
+
scenario_ended
|
|
58
93
|
end
|
|
59
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
|
+
|
|
60
106
|
def run_ended
|
|
61
|
-
|
|
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
|
|
62
115
|
unless @pending_steps.empty?
|
|
63
116
|
@output.puts "\nPending Steps:"
|
|
64
117
|
@pending_steps.each_with_index do |pending, i|
|
|
@@ -70,11 +123,10 @@ module Spec
|
|
|
70
123
|
@output.print "\nFAILURES:"
|
|
71
124
|
@failed_scenarios.each_with_index do |failure, i|
|
|
72
125
|
title, scenario_name, err = failure
|
|
73
|
-
@output.print
|
|
74
|
-
|
|
75
|
-
#{err.class}: #{err.message}
|
|
76
|
-
#{err.backtrace.join("\n")}
|
|
77
|
-
]
|
|
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"
|
|
78
130
|
end
|
|
79
131
|
end
|
|
80
132
|
end
|
|
@@ -89,7 +141,7 @@ module Spec
|
|
|
89
141
|
def step_pending(type, description, *args)
|
|
90
142
|
found_step(type, description, false, true, *args)
|
|
91
143
|
@pending_steps << [@current_story_title, @current_scenario_name, description]
|
|
92
|
-
@
|
|
144
|
+
@scenario_body_text += yellow(" (PENDING)")
|
|
93
145
|
@scenario_pending = true
|
|
94
146
|
@scenario_ok = false
|
|
95
147
|
end
|
|
@@ -97,9 +149,9 @@ module Spec
|
|
|
97
149
|
def step_failed(type, description, *args)
|
|
98
150
|
found_step(type, description, true, @scenario_pending, *args)
|
|
99
151
|
if @scenario_pending
|
|
100
|
-
@
|
|
152
|
+
@scenario_body_text += yellow(" (SKIPPED)")
|
|
101
153
|
else
|
|
102
|
-
@
|
|
154
|
+
@scenario_body_text += red(@scenario_ok ? " (FAILED)" : " (SKIPPED)")
|
|
103
155
|
end
|
|
104
156
|
@scenario_ok = false
|
|
105
157
|
end
|
|
@@ -124,9 +176,9 @@ module Spec
|
|
|
124
176
|
i = -1
|
|
125
177
|
text << desc_string.gsub(arg_regexp) { |param| args[i+=1] }
|
|
126
178
|
if pending
|
|
127
|
-
@
|
|
179
|
+
@scenario_body_text += yellow(text)
|
|
128
180
|
else
|
|
129
|
-
@
|
|
181
|
+
@scenario_body_text += (failed ? red(text) : green(text))
|
|
130
182
|
end
|
|
131
183
|
|
|
132
184
|
if type == :'given scenario'
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require 'spec/runner/formatter/story/plain_text_formatter'
|
|
2
|
+
|
|
3
|
+
module Spec
|
|
4
|
+
module Runner
|
|
5
|
+
module Formatter
|
|
6
|
+
module Story
|
|
7
|
+
class ProgressBarFormatter < PlainTextFormatter
|
|
8
|
+
|
|
9
|
+
def story_started(title, narrative) end
|
|
10
|
+
def story_ended(title, narrative) end
|
|
11
|
+
|
|
12
|
+
def run_started(count)
|
|
13
|
+
@start_time = Time.now
|
|
14
|
+
super
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def run_ended
|
|
18
|
+
@output.puts
|
|
19
|
+
@output.puts
|
|
20
|
+
@output.puts "Finished in %f seconds" % (Time.now - @start_time)
|
|
21
|
+
@output.puts
|
|
22
|
+
super
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def scenario_ended
|
|
26
|
+
if @scenario_failed
|
|
27
|
+
@output.print red('F')
|
|
28
|
+
@output.flush
|
|
29
|
+
elsif @scenario_pending
|
|
30
|
+
@output.print yellow('P')
|
|
31
|
+
@output.flush
|
|
32
|
+
else
|
|
33
|
+
@output.print green('.')
|
|
34
|
+
@output.flush
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -25,7 +25,7 @@ module Spec
|
|
|
25
25
|
|
|
26
26
|
def heckle_method(class_name, method_name)
|
|
27
27
|
verify_constant(class_name)
|
|
28
|
-
heckle = @heckle_class.new(class_name, method_name,
|
|
28
|
+
heckle = @heckle_class.new(class_name, method_name, Spec::Runner.options)
|
|
29
29
|
heckle.validate
|
|
30
30
|
end
|
|
31
31
|
|
|
@@ -39,7 +39,7 @@ module Spec
|
|
|
39
39
|
|
|
40
40
|
classes.each do |klass|
|
|
41
41
|
klass.instance_methods(false).each do |method_name|
|
|
42
|
-
heckle = @heckle_class.new(klass.name, method_name,
|
|
42
|
+
heckle = @heckle_class.new(klass.name, method_name, Spec::Runner.options)
|
|
43
43
|
heckle.validate
|
|
44
44
|
end
|
|
45
45
|
end
|
|
@@ -54,6 +54,7 @@ module Spec
|
|
|
54
54
|
"Builtin formats for stories: ",
|
|
55
55
|
"plain|p : Plain Text",
|
|
56
56
|
"html|h : A nice HTML report",
|
|
57
|
+
"progress|r : Text progress",
|
|
57
58
|
" ",
|
|
58
59
|
"FORMAT can also be the name of a custom formatter class",
|
|
59
60
|
"(in which case you should also specify --require to load it)"],
|
|
@@ -186,7 +187,7 @@ module Spec
|
|
|
186
187
|
end
|
|
187
188
|
|
|
188
189
|
def parse_version
|
|
189
|
-
@out_stream.puts ::Spec::VERSION::
|
|
190
|
+
@out_stream.puts ::Spec::VERSION::SUMMARY
|
|
190
191
|
exit if stdout?
|
|
191
192
|
end
|
|
192
193
|
|
data/lib/spec/runner/options.rb
CHANGED
|
@@ -24,10 +24,13 @@ module Spec
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
STORY_FORMATTERS = {
|
|
27
|
-
'plain' => ['spec/runner/formatter/story/plain_text_formatter',
|
|
28
|
-
'p' => ['spec/runner/formatter/story/plain_text_formatter',
|
|
29
|
-
'html' => ['spec/runner/formatter/story/html_formatter',
|
|
30
|
-
'h' => ['spec/runner/formatter/story/html_formatter',
|
|
27
|
+
'plain' => ['spec/runner/formatter/story/plain_text_formatter', 'Formatter::Story::PlainTextFormatter'],
|
|
28
|
+
'p' => ['spec/runner/formatter/story/plain_text_formatter', 'Formatter::Story::PlainTextFormatter'],
|
|
29
|
+
'html' => ['spec/runner/formatter/story/html_formatter', 'Formatter::Story::HtmlFormatter'],
|
|
30
|
+
'h' => ['spec/runner/formatter/story/html_formatter', 'Formatter::Story::HtmlFormatter'],
|
|
31
|
+
'progress' => ['spec/runner/formatter/story/progress_bar_formatter', 'Formatter::Story::ProgressBarFormatter'],
|
|
32
|
+
'r' => ['spec/runner/formatter/story/progress_bar_formatter', 'Formatter::Story::ProgressBarFormatter']
|
|
33
|
+
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
attr_accessor(
|
|
@@ -54,7 +57,7 @@ module Spec
|
|
|
54
57
|
:argv
|
|
55
58
|
)
|
|
56
59
|
attr_reader :colour, :differ_class, :files, :example_groups
|
|
57
|
-
|
|
60
|
+
|
|
58
61
|
def initialize(error_stream, output_stream)
|
|
59
62
|
@error_stream = error_stream
|
|
60
63
|
@output_stream = output_stream
|
|
@@ -89,9 +92,6 @@ module Spec
|
|
|
89
92
|
return true unless examples_should_be_run?
|
|
90
93
|
success = true
|
|
91
94
|
begin
|
|
92
|
-
before_suite_parts.each do |part|
|
|
93
|
-
part.call
|
|
94
|
-
end
|
|
95
95
|
runner = custom_runner || ExampleGroupRunner.new(self)
|
|
96
96
|
|
|
97
97
|
unless @files_loaded
|
|
@@ -99,6 +99,15 @@ module Spec
|
|
|
99
99
|
@files_loaded = true
|
|
100
100
|
end
|
|
101
101
|
|
|
102
|
+
# TODO - this has to happen after the files get loaded,
|
|
103
|
+
# otherwise the before_suite_parts are not populated
|
|
104
|
+
# from the configuration. There is no spec for this
|
|
105
|
+
# directly, but stories/configuration/before_blocks.story
|
|
106
|
+
# will fail if this happens before the files are loaded.
|
|
107
|
+
before_suite_parts.each do |part|
|
|
108
|
+
part.call
|
|
109
|
+
end
|
|
110
|
+
|
|
102
111
|
if example_groups.empty?
|
|
103
112
|
true
|
|
104
113
|
else
|
|
@@ -125,7 +134,7 @@ module Spec
|
|
|
125
134
|
|
|
126
135
|
def colour=(colour)
|
|
127
136
|
@colour = colour
|
|
128
|
-
if @colour && RUBY_PLATFORM =~ /
|
|
137
|
+
if @colour && RUBY_PLATFORM =~ /mswin|mingw/ ;\
|
|
129
138
|
begin ;\
|
|
130
139
|
require 'rubygems' ;\
|
|
131
140
|
require 'Win32/Console/ANSI' ;\
|
data/lib/spec/runner/reporter.rb
CHANGED
|
@@ -26,7 +26,7 @@ module Spec
|
|
|
26
26
|
if error.nil?
|
|
27
27
|
example_passed(example)
|
|
28
28
|
elsif Spec::Example::ExamplePendingError === error
|
|
29
|
-
example_pending(example, error.message)
|
|
29
|
+
example_pending(example, error.pending_caller, error.message)
|
|
30
30
|
else
|
|
31
31
|
example_failed(example, error)
|
|
32
32
|
end
|
|
@@ -103,14 +103,34 @@ module Spec
|
|
|
103
103
|
def example_passed(example)
|
|
104
104
|
formatters.each{|f| f.example_passed(example)}
|
|
105
105
|
end
|
|
106
|
+
|
|
107
|
+
EXAMPLE_PENDING_DEPRECATION_WARNING = <<-WARNING
|
|
108
|
+
DEPRECATION NOTICE: RSpec's formatters have changed example_pending
|
|
109
|
+
to accept three arguments instead of just two. Please see the rdoc
|
|
110
|
+
for Spec::Runner::Formatter::BaseFormatter#example_pending
|
|
111
|
+
for more information.
|
|
112
|
+
|
|
113
|
+
Please update any custom formatters to accept the third argument
|
|
114
|
+
to example_pending. Support for example_pending with two arguments
|
|
115
|
+
and this warning message will be removed after the RSpec 1.1.5 release.
|
|
116
|
+
WARNING
|
|
106
117
|
|
|
107
|
-
def example_pending(example, message="Not Yet Implemented")
|
|
118
|
+
def example_pending(example, pending_caller, message="Not Yet Implemented")
|
|
108
119
|
@pending_count += 1
|
|
109
|
-
formatters.each do |
|
|
110
|
-
|
|
120
|
+
formatters.each do |formatter|
|
|
121
|
+
if formatter_uses_deprecated_example_pending_method?(formatter)
|
|
122
|
+
Kernel.warn EXAMPLE_PENDING_DEPRECATION_WARNING
|
|
123
|
+
formatter.example_pending(example, message)
|
|
124
|
+
else
|
|
125
|
+
formatter.example_pending(example, message, pending_caller)
|
|
126
|
+
end
|
|
111
127
|
end
|
|
112
128
|
end
|
|
113
129
|
|
|
130
|
+
def formatter_uses_deprecated_example_pending_method?(formatter)
|
|
131
|
+
formatter.method(:example_pending).arity == 2
|
|
132
|
+
end
|
|
133
|
+
|
|
114
134
|
class Failure
|
|
115
135
|
attr_reader :example, :exception
|
|
116
136
|
|
|
@@ -11,7 +11,7 @@ module Spec
|
|
|
11
11
|
def spec_name_for(file, line_number)
|
|
12
12
|
best_match.clear
|
|
13
13
|
file = File.expand_path(file)
|
|
14
|
-
|
|
14
|
+
Spec::Runner.options.example_groups.each do |example_group|
|
|
15
15
|
consider_example_groups_for_best_match example_group, file, line_number
|
|
16
16
|
|
|
17
17
|
example_group.examples.each do |example|
|
data/lib/spec/story/runner.rb
CHANGED
|
@@ -38,6 +38,14 @@
|
|
|
38
38
|
current_scenario.add_step Step.new('Then', name)
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
+
def last_step
|
|
42
|
+
current_scenario.last_step
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def add_to_last(name)
|
|
46
|
+
last_step.name << name
|
|
47
|
+
end
|
|
48
|
+
|
|
41
49
|
def run_stories
|
|
42
50
|
stories.each { |story| @runner.instance_eval(&story) }
|
|
43
51
|
end
|
|
@@ -100,9 +108,15 @@
|
|
|
100
108
|
def add_step(step)
|
|
101
109
|
@steps << step
|
|
102
110
|
end
|
|
111
|
+
|
|
112
|
+
def last_step
|
|
113
|
+
@steps.last
|
|
114
|
+
end
|
|
103
115
|
end
|
|
104
116
|
|
|
105
117
|
class Step
|
|
118
|
+
attr_reader :name
|
|
119
|
+
|
|
106
120
|
def initialize(type, name)
|
|
107
121
|
@type = type
|
|
108
122
|
@name = name
|
|
@@ -26,6 +26,7 @@ module Spec
|
|
|
26
26
|
def process_line(line)
|
|
27
27
|
line.strip!
|
|
28
28
|
case line
|
|
29
|
+
when /^#/ then @state.comment(line)
|
|
29
30
|
when /^Story: / then @state.story(line)
|
|
30
31
|
when /^Scenario: / then @state.scenario(line)
|
|
31
32
|
when /^Given:? / then @state.given(line)
|
|
@@ -72,6 +73,10 @@ module Spec
|
|
|
72
73
|
def create_then(name)
|
|
73
74
|
@story_mediator.create_then(name)
|
|
74
75
|
end
|
|
76
|
+
|
|
77
|
+
def add_to_last(line)
|
|
78
|
+
@story_mediator.add_to_last("\n#{line}")
|
|
79
|
+
end
|
|
75
80
|
|
|
76
81
|
def transition_to(key)
|
|
77
82
|
@state = states[key]
|
|
@@ -136,6 +141,9 @@ module Spec
|
|
|
136
141
|
def other(line)
|
|
137
142
|
# no-op - supports header text before the first story in a file
|
|
138
143
|
end
|
|
144
|
+
|
|
145
|
+
def comment(line)
|
|
146
|
+
end
|
|
139
147
|
end
|
|
140
148
|
|
|
141
149
|
class StartingState < State
|
|
@@ -199,6 +207,10 @@ module Spec
|
|
|
199
207
|
def given(line)
|
|
200
208
|
@parser.create_given(remove_tag_from(:given, line))
|
|
201
209
|
end
|
|
210
|
+
|
|
211
|
+
def other(line)
|
|
212
|
+
@parser.add_to_last(line)
|
|
213
|
+
end
|
|
202
214
|
end
|
|
203
215
|
|
|
204
216
|
class WhenState < State
|
|
@@ -209,6 +221,10 @@ module Spec
|
|
|
209
221
|
def event(line)
|
|
210
222
|
@parser.create_when(remove_tag_from(:when ,line))
|
|
211
223
|
end
|
|
224
|
+
|
|
225
|
+
def other(line)
|
|
226
|
+
@parser.add_to_last(line)
|
|
227
|
+
end
|
|
212
228
|
end
|
|
213
229
|
|
|
214
230
|
class ThenState < State
|
|
@@ -219,6 +235,10 @@ module Spec
|
|
|
219
235
|
def outcome(line)
|
|
220
236
|
@parser.create_then(remove_tag_from(:then ,line))
|
|
221
237
|
end
|
|
238
|
+
|
|
239
|
+
def other(line)
|
|
240
|
+
@parser.add_to_last(line)
|
|
241
|
+
end
|
|
222
242
|
end
|
|
223
243
|
|
|
224
244
|
end
|