rspec 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +35 -0
- data/MIT-LICENSE +1 -1
- data/README +9 -44
- data/Rakefile +34 -51
- data/TODO +0 -1
- data/UPGRADE +0 -24
- data/bin/spec +0 -0
- data/bin/spec_translator +0 -0
- data/examples/pure/behave_as_example.rb +0 -0
- data/examples/pure/partial_mock_example.rb +1 -0
- data/examples/stories/calculator.rb +1 -1
- data/lib/autotest/rspec.rb +7 -9
- data/lib/spec/example.rb +1 -1
- data/lib/spec/example/configuration.rb +30 -16
- data/lib/spec/example/example_group.rb +2 -1
- data/lib/spec/example/example_group_factory.rb +23 -21
- data/lib/spec/example/example_group_methods.rb +18 -5
- data/lib/spec/example/example_matcher.rb +0 -0
- data/lib/spec/example/example_methods.rb +6 -0
- data/lib/spec/example/module_inclusion_warnings.rb +37 -0
- data/lib/spec/expectations/differs/default.rb +1 -1
- data/lib/spec/expectations/extensions/object.rb +4 -12
- data/lib/spec/expectations/handler.rb +8 -0
- data/lib/spec/extensions.rb +1 -0
- data/lib/spec/extensions/metaclass.rb +7 -0
- data/lib/spec/extensions/object.rb +0 -4
- data/lib/spec/matchers/change.rb +1 -1
- data/lib/spec/matchers/has.rb +1 -11
- data/lib/spec/matchers/operator_matcher.rb +0 -0
- data/lib/spec/matchers/raise_error.rb +53 -30
- data/lib/spec/mocks.rb +1 -1
- data/lib/spec/mocks/argument_constraint_matchers.rb +5 -1
- data/lib/spec/mocks/argument_expectation.rb +26 -0
- data/lib/spec/mocks/extensions.rb +1 -0
- data/lib/spec/mocks/framework.rb +15 -0
- data/lib/spec/mocks/message_expectation.rb +29 -5
- data/lib/spec/mocks/mock.rb +9 -7
- data/lib/spec/mocks/proxy.rb +26 -12
- data/lib/spec/rake/spectask.rb +5 -5
- data/lib/spec/runner/backtrace_tweaker.rb +1 -1
- data/lib/spec/runner/formatter/base_formatter.rb +2 -3
- data/lib/spec/runner/formatter/base_text_formatter.rb +2 -2
- data/lib/spec/runner/formatter/failing_example_groups_formatter.rb +4 -8
- data/lib/spec/runner/formatter/html_formatter.rb +18 -14
- data/lib/spec/runner/formatter/nested_text_formatter.rb +65 -0
- data/lib/spec/runner/formatter/profile_formatter.rb +4 -0
- data/lib/spec/runner/formatter/progress_bar_formatter.rb +5 -1
- data/lib/spec/runner/formatter/specdoc_formatter.rb +1 -1
- data/lib/spec/runner/formatter/story/plain_text_formatter.rb +18 -7
- data/lib/spec/runner/option_parser.rb +17 -15
- data/lib/spec/runner/options.rb +37 -14
- data/lib/spec/runner/reporter.rb +15 -11
- data/lib/spec/story/extensions/regexp.rb +2 -2
- data/lib/spec/story/extensions/string.rb +2 -2
- data/lib/spec/story/runner.rb +9 -5
- data/lib/spec/story/runner/plain_text_story_runner.rb +2 -2
- data/lib/spec/story/runner/scenario_runner.rb +8 -0
- data/lib/spec/story/runner/story_mediator.rb +1 -1
- data/lib/spec/story/runner/story_runner.rb +3 -1
- data/lib/spec/story/step.rb +4 -4
- data/lib/spec/story/story.rb +8 -11
- data/lib/spec/story/world.rb +0 -1
- data/lib/spec/version.rb +2 -2
- data/plugins/mock_frameworks/rspec.rb +2 -0
- data/spec/autotest/rspec_spec.rb +12 -10
- data/spec/spec/example/configuration_spec.rb +0 -0
- data/spec/spec/example/example_group/described_module_spec.rb +20 -0
- data/spec/spec/example/example_group/warning_messages_spec.rb +76 -0
- data/spec/spec/example/example_group_factory_spec.rb +117 -102
- data/spec/spec/example/example_group_methods_spec.rb +51 -17
- data/spec/spec/example/example_group_spec.rb +13 -1
- data/spec/spec/example/example_methods_spec.rb +28 -6
- data/spec/spec/example/nested_example_group_spec.rb +12 -0
- data/spec/spec/example/predicate_matcher_spec.rb +0 -0
- data/spec/spec/expectations/differs/default_spec.rb +27 -9
- data/spec/spec/matchers/be_spec.rb +24 -0
- data/spec/spec/matchers/has_spec.rb +16 -0
- data/spec/spec/matchers/raise_error_spec.rb +124 -0
- data/spec/spec/mocks/{bug_report_10263.rb → bug_report_10263_spec.rb} +0 -0
- data/spec/spec/mocks/bug_report_11545_spec.rb +2 -0
- data/spec/spec/mocks/failing_mock_argument_constraints_spec.rb +8 -0
- data/spec/spec/mocks/hash_including_matcher_spec.rb +32 -0
- data/spec/spec/mocks/mock_spec.rb +56 -37
- data/spec/spec/mocks/partial_mock_spec.rb +41 -5
- data/spec/spec/mocks/passing_mock_argument_constraints_spec.rb +6 -0
- data/spec/spec/runner/execution_context_spec.rb +7 -1
- data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +3 -2
- data/spec/spec/runner/formatter/html_formatted-1.8.6.html +30 -25
- data/spec/spec/runner/formatter/html_formatter_spec.rb +0 -3
- data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +333 -0
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +12 -2
- data/spec/spec/runner/formatter/spec_mate_formatter_spec.rb +2 -2
- data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +110 -78
- data/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb +105 -1
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +33 -28
- data/spec/spec/runner/option_parser_spec.rb +65 -49
- data/spec/spec/runner/options_spec.rb +103 -17
- data/spec/spec/runner/reporter_spec.rb +10 -7
- data/spec/spec/runner/spec_drb.opts +1 -0
- data/spec/spec/runner/spec_parser_spec.rb +10 -4
- data/spec/spec/story/runner/plain_text_story_runner_spec.rb +14 -13
- data/spec/spec/story/runner/scenario_runner_spec.rb +124 -52
- data/spec/spec/story/runner/story_mediator_spec.rb +2 -2
- data/spec/spec/story/runner/story_runner_spec.rb +40 -2
- data/spec/spec/story/runner_spec.rb +59 -72
- data/spec/spec/story/step_spec.rb +20 -1
- data/spec/spec/story/story_spec.rb +2 -2
- data/stories/all.rb +1 -1
- data/stories/example_groups/stories.rb +4 -3
- data/stories/mock_framework_integration/stories.rb +7 -0
- data/stories/mock_framework_integration/use_flexmock.story +9 -0
- data/stories/resources/spec/spec_with_flexmock.rb +18 -0
- metadata +21 -18
- data/pre_commit/lib/pre_commit.rb +0 -4
- data/pre_commit/lib/pre_commit/core.rb +0 -50
- data/pre_commit/lib/pre_commit/pre_commit.rb +0 -54
- data/pre_commit/lib/pre_commit/rspec.rb +0 -111
- data/pre_commit/lib/pre_commit/rspec_on_rails.rb +0 -313
- data/pre_commit/spec/pre_commit/pre_commit_spec.rb +0 -15
- data/pre_commit/spec/pre_commit/rspec_on_rails_spec.rb +0 -36
- data/pre_commit/spec/spec_helper.rb +0 -3
- data/pre_commit/spec/spec_suite.rb +0 -11
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec/runner/formatter/base_text_formatter'
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Runner
|
5
|
+
module Formatter
|
6
|
+
class NestedTextFormatter < BaseTextFormatter
|
7
|
+
attr_reader :previous_nested_example_groups
|
8
|
+
def initialize(options, where)
|
9
|
+
super
|
10
|
+
@previous_nested_example_groups = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_example_group(example_group)
|
14
|
+
super
|
15
|
+
|
16
|
+
current_nested_example_groups = described_example_group_chain
|
17
|
+
current_nested_example_groups.each_with_index do |nested_example_group, i|
|
18
|
+
unless nested_example_group == previous_nested_example_groups[i]
|
19
|
+
output.puts "#{' ' * i}#{nested_example_group.description_args}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
@previous_nested_example_groups = described_example_group_chain
|
24
|
+
end
|
25
|
+
|
26
|
+
def example_failed(example, counter, failure)
|
27
|
+
message = if failure.expectation_not_met?
|
28
|
+
"#{current_indentation}#{example.description} (FAILED - #{counter})"
|
29
|
+
else
|
30
|
+
"#{current_indentation}#{example.description} (ERROR - #{counter})"
|
31
|
+
end
|
32
|
+
|
33
|
+
output.puts(failure.expectation_not_met? ? red(message) : magenta(message))
|
34
|
+
output.flush
|
35
|
+
end
|
36
|
+
|
37
|
+
def example_passed(example)
|
38
|
+
message = "#{current_indentation}#{example.description}"
|
39
|
+
output.puts green(message)
|
40
|
+
output.flush
|
41
|
+
end
|
42
|
+
|
43
|
+
def example_pending(example, message)
|
44
|
+
super
|
45
|
+
output.puts yellow("#{current_indentation}#{example.description} (PENDING: #{message})")
|
46
|
+
output.flush
|
47
|
+
end
|
48
|
+
|
49
|
+
def current_indentation
|
50
|
+
' ' * previous_nested_example_groups.length
|
51
|
+
end
|
52
|
+
|
53
|
+
def described_example_group_chain
|
54
|
+
example_group_chain = []
|
55
|
+
example_group.send(:execute_in_class_hierarchy) do |parent_example_group|
|
56
|
+
if parent_example_group.description_args && !parent_example_group.description_args.empty?
|
57
|
+
example_group_chain << parent_example_group
|
58
|
+
end
|
59
|
+
end
|
60
|
+
example_group_chain
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -14,7 +14,7 @@ module Spec
|
|
14
14
|
@output.flush
|
15
15
|
end
|
16
16
|
|
17
|
-
def example_pending(
|
17
|
+
def example_pending(example, message)
|
18
18
|
super
|
19
19
|
@output.print yellow('P')
|
20
20
|
@output.flush
|
@@ -24,6 +24,10 @@ module Spec
|
|
24
24
|
@output.puts
|
25
25
|
@output.flush
|
26
26
|
end
|
27
|
+
|
28
|
+
def method_missing(sym, *args)
|
29
|
+
# ignore
|
30
|
+
end
|
27
31
|
end
|
28
32
|
end
|
29
33
|
end
|
@@ -38,6 +38,7 @@ module Spec
|
|
38
38
|
@scenario_already_failed = false
|
39
39
|
@output.print "\n\n Scenario: #{scenario_name}"
|
40
40
|
@scenario_ok = true
|
41
|
+
@scenario_pending = false
|
41
42
|
end
|
42
43
|
|
43
44
|
def scenario_succeeded(story_title, scenario_name)
|
@@ -52,6 +53,7 @@ module Spec
|
|
52
53
|
|
53
54
|
def scenario_pending(story_title, scenario_name, msg)
|
54
55
|
@pending_scenario_count += 1 unless @scenario_already_failed
|
56
|
+
@scenario_pending = true
|
55
57
|
@scenario_already_failed = true
|
56
58
|
end
|
57
59
|
|
@@ -81,19 +83,24 @@ module Spec
|
|
81
83
|
end
|
82
84
|
|
83
85
|
def step_succeeded(type, description, *args)
|
84
|
-
found_step(type, description, false, *args)
|
86
|
+
found_step(type, description, false, false, *args)
|
85
87
|
end
|
86
88
|
|
87
89
|
def step_pending(type, description, *args)
|
88
|
-
found_step(type, description, false, *args)
|
90
|
+
found_step(type, description, false, true, *args)
|
89
91
|
@pending_steps << [@current_story_title, @current_scenario_name, description]
|
90
|
-
@output.print " (PENDING)"
|
92
|
+
@output.print yellow(" (PENDING)")
|
93
|
+
@scenario_pending = true
|
91
94
|
@scenario_ok = false
|
92
95
|
end
|
93
96
|
|
94
97
|
def step_failed(type, description, *args)
|
95
|
-
found_step(type, description, true, *args)
|
96
|
-
|
98
|
+
found_step(type, description, true, @scenario_pending, *args)
|
99
|
+
if @scenario_pending
|
100
|
+
@output.print yellow(" (SKIPPED)")
|
101
|
+
else
|
102
|
+
@output.print red(@scenario_ok ? " (FAILED)" : " (SKIPPED)")
|
103
|
+
end
|
97
104
|
@scenario_ok = false
|
98
105
|
end
|
99
106
|
|
@@ -106,7 +113,7 @@ module Spec
|
|
106
113
|
|
107
114
|
private
|
108
115
|
|
109
|
-
def found_step(type, description, failed, *args)
|
116
|
+
def found_step(type, description, failed, pending, *args)
|
110
117
|
desc_string = description.step_name
|
111
118
|
arg_regexp = description.arg_regexp
|
112
119
|
text = if(type == @previous_type)
|
@@ -116,7 +123,11 @@ module Spec
|
|
116
123
|
end
|
117
124
|
i = -1
|
118
125
|
text << desc_string.gsub(arg_regexp) { |param| args[i+=1] }
|
119
|
-
|
126
|
+
if pending
|
127
|
+
@output.print yellow(text)
|
128
|
+
else
|
129
|
+
@output.print(failed ? red(text) : green(text))
|
130
|
+
end
|
120
131
|
|
121
132
|
if type == :'given scenario'
|
122
133
|
@previous_type = :given
|
@@ -19,7 +19,7 @@ module Spec
|
|
19
19
|
"Separate multiple patterns with commas.",
|
20
20
|
"Applies only to directories named on the command line (files",
|
21
21
|
"named explicitly on the command line will be loaded regardless)."],
|
22
|
-
:diff => ["-D", "--diff [FORMAT]",
|
22
|
+
:diff => ["-D", "--diff [FORMAT]","Show diff of objects that are expected to be equal when they are not",
|
23
23
|
"Builtin formats: unified|u|context|c",
|
24
24
|
"You can also specify a custom differ class",
|
25
25
|
"(in which case you should also specify --require)"],
|
@@ -36,7 +36,7 @@ module Spec
|
|
36
36
|
:specification => ["-s", "--specification [NAME]", "DEPRECATED - use -e instead", "(This will be removed when autotest works with -e)"],
|
37
37
|
:line => ["-l", "--line LINE_NUMBER", Integer, "Execute behaviout or specification at given line.",
|
38
38
|
"(does not work for dynamically generated specs)"],
|
39
|
-
:format => ["-f", "--format FORMAT[:WHERE]",
|
39
|
+
:format => ["-f", "--format FORMAT[:WHERE]","Specifies what format to use for output. Specify WHERE to tell",
|
40
40
|
"the formatter where to write the output. All built-in formats",
|
41
41
|
"expect WHERE to be a file name, and will write to STDOUT if it's",
|
42
42
|
"not specified. The --format option may be specified several times",
|
@@ -46,6 +46,7 @@ module Spec
|
|
46
46
|
"progress|p : Text progress",
|
47
47
|
"profile|o : Text progress with profiling of 10 slowest examples",
|
48
48
|
"specdoc|s : Example doc as text",
|
49
|
+
"indented|i : Example doc as indented text",
|
49
50
|
"html|h : A nice HTML report",
|
50
51
|
"failing_examples|e : Write all failing examples - input for --example",
|
51
52
|
"failing_example_groups|g : Write all failing example groups - input for --example",
|
@@ -57,13 +58,13 @@ module Spec
|
|
57
58
|
"FORMAT can also be the name of a custom formatter class",
|
58
59
|
"(in which case you should also specify --require to load it)"],
|
59
60
|
:require => ["-r", "--require FILE", "Require FILE before running specs",
|
60
|
-
|
61
|
-
|
61
|
+
"Useful for loading custom formatters or other extensions.",
|
62
|
+
"If this option is used it must come before the others"],
|
62
63
|
:backtrace => ["-b", "--backtrace", "Output full backtrace"],
|
63
64
|
:loadby => ["-L", "--loadby STRATEGY", "Specify the strategy by which spec files should be loaded.",
|
64
|
-
|
65
|
-
|
66
|
-
|
65
|
+
"STRATEGY can currently only be 'mtime' (File modification time)",
|
66
|
+
"By default, spec files are loaded in alphabetical order if --loadby",
|
67
|
+
"is not specified."],
|
67
68
|
:reverse => ["-R", "--reverse", "Run examples in reverse order"],
|
68
69
|
:timeout => ["-t", "--timeout FLOAT", "Interrupt and fail each example that doesn't complete in the",
|
69
70
|
"specified time"],
|
@@ -107,11 +108,8 @@ module Spec
|
|
107
108
|
on(*OPTIONS[:heckle]) {|heckle| @options.load_heckle_runner(heckle)}
|
108
109
|
on(*OPTIONS[:dry_run]) {@options.dry_run = true}
|
109
110
|
on(*OPTIONS[:options_file]) {|options_file| parse_options_file(options_file)}
|
110
|
-
on(*OPTIONS[:generate_options])
|
111
|
-
|
112
|
-
on(*OPTIONS[:runner]) do |runner|
|
113
|
-
@options.user_input_for_runner = runner
|
114
|
-
end
|
111
|
+
on(*OPTIONS[:generate_options]) {|options_file|}
|
112
|
+
on(*OPTIONS[:runner]) {|runner| @options.user_input_for_runner = runner}
|
115
113
|
on(*OPTIONS[:drb]) {}
|
116
114
|
on(*OPTIONS[:version]) {parse_version}
|
117
115
|
on_tail(*OPTIONS[:help]) {parse_help}
|
@@ -141,6 +139,10 @@ module Spec
|
|
141
139
|
def parse_options_file(options_file)
|
142
140
|
option_file_args = IO.readlines(options_file).map {|l| l.chomp.split " "}.flatten
|
143
141
|
@argv.push(*option_file_args)
|
142
|
+
# TODO - this is a brute force solution to http://rspec.lighthouseapp.com/projects/5645/tickets/293.
|
143
|
+
# Let's look for a cleaner way. Might not be one. But let's look. If not, perhaps
|
144
|
+
# this can be moved to a different method to indicate the special handling for drb?
|
145
|
+
parse_drb(@argv)
|
144
146
|
end
|
145
147
|
|
146
148
|
def parse_generate_options
|
@@ -170,12 +172,12 @@ module Spec
|
|
170
172
|
@options.examples_should_not_be_run
|
171
173
|
end
|
172
174
|
|
173
|
-
def parse_drb
|
175
|
+
def parse_drb(argv = nil)
|
176
|
+
argv ||= @options.argv # TODO - see note about about http://rspec.lighthouseapp.com/projects/5645/tickets/293
|
174
177
|
is_drb = false
|
175
|
-
argv = @options.argv
|
176
178
|
is_drb ||= argv.delete(OPTIONS[:drb][0])
|
177
179
|
is_drb ||= argv.delete(OPTIONS[:drb][1])
|
178
|
-
return
|
180
|
+
return false unless is_drb
|
179
181
|
@options.examples_should_not_be_run
|
180
182
|
DrbCommandLine.run(
|
181
183
|
self.class.parse(argv, @error_stream, @out_stream)
|
data/lib/spec/runner/options.rb
CHANGED
@@ -8,6 +8,8 @@ module Spec
|
|
8
8
|
EXAMPLE_FORMATTERS = { # Load these lazily for better speed
|
9
9
|
'specdoc' => ['spec/runner/formatter/specdoc_formatter', 'Formatter::SpecdocFormatter'],
|
10
10
|
's' => ['spec/runner/formatter/specdoc_formatter', 'Formatter::SpecdocFormatter'],
|
11
|
+
'nested' => ['spec/runner/formatter/nested_text_formatter', 'Formatter::NestedTextFormatter'],
|
12
|
+
'n' => ['spec/runner/formatter/nested_text_formatter', 'Formatter::NestedTextFormatter'],
|
11
13
|
'html' => ['spec/runner/formatter/html_formatter', 'Formatter::HtmlFormatter'],
|
12
14
|
'h' => ['spec/runner/formatter/html_formatter', 'Formatter::HtmlFormatter'],
|
13
15
|
'progress' => ['spec/runner/formatter/progress_bar_formatter', 'Formatter::ProgressBarFormatter'],
|
@@ -46,6 +48,8 @@ module Spec
|
|
46
48
|
:user_input_for_runner,
|
47
49
|
:error_stream,
|
48
50
|
:output_stream,
|
51
|
+
:before_suite_parts,
|
52
|
+
:after_suite_parts,
|
49
53
|
# TODO: BT - Figure out a better name
|
50
54
|
:argv
|
51
55
|
)
|
@@ -65,9 +69,12 @@ module Spec
|
|
65
69
|
@diff_format = :unified
|
66
70
|
@files = []
|
67
71
|
@example_groups = []
|
72
|
+
@result = nil
|
68
73
|
@examples_run = false
|
69
74
|
@examples_should_be_run = nil
|
70
75
|
@user_input_for_runner = nil
|
76
|
+
@before_suite_parts = []
|
77
|
+
@after_suite_parts = []
|
71
78
|
end
|
72
79
|
|
73
80
|
def add_example_group(example_group)
|
@@ -80,17 +87,31 @@ module Spec
|
|
80
87
|
|
81
88
|
def run_examples
|
82
89
|
return true unless examples_should_be_run?
|
83
|
-
|
90
|
+
success = true
|
91
|
+
begin
|
92
|
+
before_suite_parts.each do |part|
|
93
|
+
part.call
|
94
|
+
end
|
95
|
+
runner = custom_runner || ExampleGroupRunner.new(self)
|
84
96
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
97
|
+
unless @files_loaded
|
98
|
+
runner.load_files(files_to_load)
|
99
|
+
@files_loaded = true
|
100
|
+
end
|
101
|
+
|
102
|
+
if example_groups.empty?
|
103
|
+
true
|
104
|
+
else
|
105
|
+
set_spec_from_line_number if line_number
|
106
|
+
success = runner.run
|
107
|
+
@examples_run = true
|
108
|
+
heckle if heckle_runner
|
109
|
+
success
|
110
|
+
end
|
111
|
+
ensure
|
112
|
+
after_suite_parts.each do |part|
|
113
|
+
part.call(success)
|
114
|
+
end
|
94
115
|
end
|
95
116
|
end
|
96
117
|
|
@@ -177,9 +198,11 @@ module Spec
|
|
177
198
|
end
|
178
199
|
|
179
200
|
def number_of_examples
|
180
|
-
|
181
|
-
|
201
|
+
total = 0
|
202
|
+
@example_groups.each do |example_group|
|
203
|
+
total += example_group.number_of_examples
|
182
204
|
end
|
205
|
+
total
|
183
206
|
end
|
184
207
|
|
185
208
|
def files_to_load
|
@@ -240,9 +263,9 @@ module Spec
|
|
240
263
|
end
|
241
264
|
|
242
265
|
def heckle
|
243
|
-
|
266
|
+
heckle_runner = self.heckle_runner
|
244
267
|
self.heckle_runner = nil
|
245
|
-
|
268
|
+
heckle_runner.heckle_with
|
246
269
|
end
|
247
270
|
|
248
271
|
def sorted_files
|
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(
|
29
|
+
example_pending(example, error.message)
|
30
30
|
else
|
31
31
|
example_failed(example, error)
|
32
32
|
end
|
@@ -34,8 +34,7 @@ module Spec
|
|
34
34
|
|
35
35
|
def failure(example, error)
|
36
36
|
backtrace_tweaker.tweak_backtrace(error)
|
37
|
-
|
38
|
-
failure = Failure.new(example_name, error)
|
37
|
+
failure = Failure.new(example, error)
|
39
38
|
@failures << failure
|
40
39
|
formatters.each do |f|
|
41
40
|
f.example_failed(example, @failures.length, failure)
|
@@ -91,6 +90,7 @@ module Spec
|
|
91
90
|
index + 1
|
92
91
|
end
|
93
92
|
end
|
93
|
+
|
94
94
|
def dump_pending
|
95
95
|
formatters.each{|f| f.dump_pending}
|
96
96
|
end
|
@@ -104,28 +104,28 @@ module Spec
|
|
104
104
|
formatters.each{|f| f.example_passed(example)}
|
105
105
|
end
|
106
106
|
|
107
|
-
def example_pending(
|
107
|
+
def example_pending(example, message="Not Yet Implemented")
|
108
108
|
@pending_count += 1
|
109
109
|
formatters.each do |f|
|
110
|
-
f.example_pending(
|
110
|
+
f.example_pending(example, message)
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
114
|
class Failure
|
115
|
-
attr_reader :exception
|
115
|
+
attr_reader :example, :exception
|
116
116
|
|
117
|
-
def initialize(
|
118
|
-
@
|
117
|
+
def initialize(example, exception)
|
118
|
+
@example = example
|
119
119
|
@exception = exception
|
120
120
|
end
|
121
121
|
|
122
122
|
def header
|
123
123
|
if expectation_not_met?
|
124
|
-
"'#{
|
124
|
+
"'#{example_name}' FAILED"
|
125
125
|
elsif pending_fixed?
|
126
|
-
"'#{
|
126
|
+
"'#{example_name}' FIXED"
|
127
127
|
else
|
128
|
-
"#{@exception.class.name} in '#{
|
128
|
+
"#{@exception.class.name} in '#{example_name}'"
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
@@ -137,6 +137,10 @@ module Spec
|
|
137
137
|
@exception.is_a?(Spec::Expectations::ExpectationNotMetError)
|
138
138
|
end
|
139
139
|
|
140
|
+
protected
|
141
|
+
def example_name
|
142
|
+
@example.__full_description
|
143
|
+
end
|
140
144
|
end
|
141
145
|
end
|
142
146
|
end
|