Removed spec_path printing in errors because it is misleading on top of the stack trace. Its possible to get a stack track to the definition of the Example. Reporter::Failure takes an Example, instead of a description.
git-svn-id: http://rspec.rubyforge.org/svn/trunk@3306 410327ef-2207-0410-a325-f78bbcb22a5a
| |   |
| 6 | 6 | class FailingExamplesFormatter < BaseTextFormatter |
| 7 | 7 | def example_failed(example, counter, failure) |
| 8 | 8 | @output.puts "#{example_group.description} #{example.description}" |
| 9 | | @output.puts example_group.spec_path if example_group.spec_path |
| 10 | 9 | @output.flush |
| 11 | 10 | end |
| 12 | 11 | |
| toggle raw diff |
--- a/rspec/lib/spec/runner/formatter/failing_examples_formatter.rb
+++ b/rspec/lib/spec/runner/formatter/failing_examples_formatter.rb
@@ -6,7 +6,6 @@ module Spec
class FailingExamplesFormatter < BaseTextFormatter
def example_failed(example, counter, failure)
@output.puts "#{example_group.description} #{example.description}"
- @output.puts example_group.spec_path if example_group.spec_path
@output.flush
end
|
| |   |
| 34 | 34 | |
| 35 | 35 | def failure(example, error) |
| 36 | 36 | backtrace_tweaker.tweak_backtrace(error) |
| 37 | | failure = Failure.new(example.__full_description, error) |
| 37 | failure = Failure.new(example, error) |
| 38 | 38 | @failures << failure |
| 39 | 39 | formatters.each do |f| |
| 40 | 40 | f.example_failed(example, @failures.length, failure) |
| … | … | |
| 90 | 90 | index + 1 |
| 91 | 91 | end |
| 92 | 92 | end |
| 93 | |
| 93 | 94 | def dump_pending |
| 94 | 95 | formatters.each{|f| f.dump_pending} |
| 95 | 96 | end |
| … | … | |
| 112 | 112 | end |
| 113 | 113 | |
| 114 | 114 | class Failure |
| 115 | | attr_reader :exception |
| 115 | attr_reader :example, :exception |
| 116 | 116 | |
| 117 | | def initialize(example_name, exception) |
| 118 | | @example_name = example_name |
| 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 | | "'#{@example_name}' FAILED" |
| 124 | "'#{example_name}' FAILED" |
| 125 | 125 | elsif pending_fixed? |
| 126 | | "'#{@example_name}' FIXED" |
| 126 | "'#{example_name}' FIXED" |
| 127 | 127 | else |
| 128 | | "#{@exception.class.name} in '#{@example_name}'" |
| 128 | "#{@exception.class.name} in '#{example_name}'" |
| 129 | 129 | end |
| 130 | 130 | end |
| 131 | 131 | |
| … | … | |
| 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 |
| toggle raw diff |
--- a/rspec/lib/spec/runner/reporter.rb
+++ b/rspec/lib/spec/runner/reporter.rb
@@ -34,7 +34,7 @@ module Spec
def failure(example, error)
backtrace_tweaker.tweak_backtrace(error)
- failure = Failure.new(example.__full_description, error)
+ failure = Failure.new(example, error)
@failures << failure
formatters.each do |f|
f.example_failed(example, @failures.length, failure)
@@ -90,6 +90,7 @@ module Spec
index + 1
end
end
+
def dump_pending
formatters.each{|f| f.dump_pending}
end
@@ -111,20 +112,20 @@ module Spec
end
class Failure
- attr_reader :exception
+ attr_reader :example, :exception
- def initialize(example_name, exception)
- @example_name = example_name
+ def initialize(example, exception)
+ @example = example
@exception = exception
end
def header
if expectation_not_met?
- "'#{@example_name}' FAILED"
+ "'#{example_name}' FAILED"
elsif pending_fixed?
- "'#{@example_name}' FIXED"
+ "'#{example_name}' FIXED"
else
- "#{@exception.class.name} in '#{@example_name}'"
+ "#{@exception.class.name} in '#{example_name}'"
end
end
@@ -136,6 +137,10 @@ module Spec
@exception.is_a?(Spec::Expectations::ExpectationNotMetError)
end
+ protected
+ def example_name
+ @example.__full_description
+ end
end
end
end |
| |   |
| 6 | 6 | TINY = 3 |
| 7 | 7 | RELEASE_CANDIDATE = nil |
| 8 | 8 | |
| 9 | | BUILD_TIME_UTC = 20080213084613 |
| 9 | BUILD_TIME_UTC = 20080213090704 |
| 10 | 10 | |
| 11 | 11 | STRING = [MAJOR, MINOR, TINY].join('.') |
| 12 | 12 | TAG = "REL_#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('_')}".upcase.gsub(/\.|-/, '_') |
| toggle raw diff |
--- a/rspec/lib/spec/version.rb
+++ b/rspec/lib/spec/version.rb
@@ -6,7 +6,7 @@ module Spec
TINY = 3
RELEASE_CANDIDATE = nil
- BUILD_TIME_UTC = 20080213084613
+ BUILD_TIME_UTC = 20080213090704
STRING = [MAJOR, MINOR, TINY].join('.')
TAG = "REL_#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('_')}".upcase.gsub(/\.|-/, '_')
|
| |   |
| 24 | 24 | io.string.should include("b 2") |
| 25 | 25 | end |
| 26 | 26 | |
| 27 | | it "should add the spec path for each failure" do |
| 28 | | example_group_1 = Class.new(ExampleGroup).describe("b 1", :spec_path => "/path/to/b/1") |
| 29 | | example_group_2 = Class.new(ExampleGroup).describe("b 2", :spec_path => "/path/to/b/2") |
| 30 | | formatter.add_example_group(example_group_1) |
| 31 | | formatter.example_failed("e 1", nil, Reporter::Failure.new(nil, RuntimeError.new)) |
| 32 | | formatter.add_example_group(example_group_2) |
| 33 | | formatter.example_failed("e 2", nil, Reporter::Failure.new(nil, RuntimeError.new)) |
| 34 | | io.string.should include("/path/to/b/1") |
| 35 | | io.string.should include("/path/to/b/2") |
| 36 | | end |
| 37 | | |
| 38 | 27 | it "should delimit ExampleGroup superclass descriptions with :" do |
| 39 | 28 | parent_example_group = Class.new(example_group).describe("Parent") |
| 40 | 29 | child_example_group = Class.new(parent_example_group).describe("#child_method") |
| toggle raw diff |
--- a/rspec/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb
+++ b/rspec/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb
@@ -24,17 +24,6 @@ module Spec
io.string.should include("b 2")
end
- it "should add the spec path for each failure" do
- example_group_1 = Class.new(ExampleGroup).describe("b 1", :spec_path => "/path/to/b/1")
- example_group_2 = Class.new(ExampleGroup).describe("b 2", :spec_path => "/path/to/b/2")
- formatter.add_example_group(example_group_1)
- formatter.example_failed("e 1", nil, Reporter::Failure.new(nil, RuntimeError.new))
- formatter.add_example_group(example_group_2)
- formatter.example_failed("e 2", nil, Reporter::Failure.new(nil, RuntimeError.new))
- io.string.should include("/path/to/b/1")
- io.string.should include("/path/to/b/2")
- end
-
it "should delimit ExampleGroup superclass descriptions with :" do
parent_example_group = Class.new(example_group).describe("Parent")
child_example_group = Class.new(parent_example_group).describe("#child_method") |
| |   |
| 27 | 27 | EOF |
| 28 | 28 | ) |
| 29 | 29 | end |
| 30 | | |
| 31 | | it "should add spec path for each failing Example that has a spec_path" do |
| 32 | | example_group_1 = Class.new(ExampleGroup).describe("A", :spec_path => "/path/to/a") |
| 33 | | example_group_2 = Class.new(example_group_1).describe("B", :spec_path => "/path/to/b") |
| 34 | | |
| 35 | | @formatter.add_example_group(example_group_1) |
| 36 | | @formatter.example_failed(example_group_1.it("a1"){}, nil, Reporter::Failure.new(nil, RuntimeError.new)) |
| 37 | | @formatter.add_example_group(example_group_2) |
| 38 | | @formatter.example_failed(example_group_2.it("b2"){}, nil, Reporter::Failure.new(nil, RuntimeError.new)) |
| 39 | | @formatter.example_failed(example_group_2.it("b3"){}, nil, Reporter::Failure.new(nil, RuntimeError.new)) |
| 40 | | @io.string.should eql(<<-EOF |
| 41 | | A a1 |
| 42 | | /path/to/a |
| 43 | | A B b2 |
| 44 | | /path/to/b |
| 45 | | A B b3 |
| 46 | | /path/to/b |
| 47 | | EOF |
| 48 | | ) |
| 49 | | end |
| 50 | 30 | end |
| 51 | 31 | end |
| 52 | 32 | end |
| toggle raw diff |
--- a/rspec/spec/spec/runner/formatter/failing_examples_formatter_spec.rb
+++ b/rspec/spec/spec/runner/formatter/failing_examples_formatter_spec.rb
@@ -27,26 +27,6 @@ A B b3
EOF
)
end
-
- it "should add spec path for each failing Example that has a spec_path" do
- example_group_1 = Class.new(ExampleGroup).describe("A", :spec_path => "/path/to/a")
- example_group_2 = Class.new(example_group_1).describe("B", :spec_path => "/path/to/b")
-
- @formatter.add_example_group(example_group_1)
- @formatter.example_failed(example_group_1.it("a1"){}, nil, Reporter::Failure.new(nil, RuntimeError.new))
- @formatter.add_example_group(example_group_2)
- @formatter.example_failed(example_group_2.it("b2"){}, nil, Reporter::Failure.new(nil, RuntimeError.new))
- @formatter.example_failed(example_group_2.it("b3"){}, nil, Reporter::Failure.new(nil, RuntimeError.new))
- @io.string.should eql(<<-EOF
-A a1
-/path/to/a
-A B b2
-/path/to/b
-A B b3
-/path/to/b
-EOF
-)
- end
end
end
end |