Permalink
Browse files

a little more duck typing and a little less dependency on class

  • Loading branch information...
1 parent b5d10cc commit 7fa264f31e5429e53f17ac915b4c454d76fd0283 @dchelimsky dchelimsky committed Dec 12, 2011
@@ -181,8 +181,13 @@ def start(reporter)
record :started_at => Time.now
end
+ module NotPendingExampleFixed
+ def pending_fixed?; false; end
+ end
+
def finish(reporter)
if @exception
+ @exception.extend(NotPendingExampleFixed) unless @exception.respond_to?(:pending_fixed?)
record_finished 'failed', :exception => @exception
reporter.example_failed self
false
@@ -159,7 +159,7 @@ def dump_backtrace(example)
end
def dump_pending_example_fixed(example, index)
- if RSpec::Core::Pending::PendingExampleFixedError === example.execution_result[:exception]
+ if example.execution_result[:exception].pending_fixed?
output.puts "#{short_padding}#{index.next}) #{example.full_description} FIXED"
output.puts blue("#{long_padding}Expected pending '#{example.metadata[:execution_result][:pending_message]}' to fail. No Error was raised.")
true
@@ -75,14 +75,13 @@ def example_failed(example)
super(example)
exception = example.metadata[:execution_result][:exception]
extra = extra_failure_content(exception)
- failure_style = RSpec::Core::Pending::PendingExampleFixedError === exception ? 'pending_fixed' : 'failed'
@output.puts " <script type=\"text/javascript\">makeRed('rspec-header');</script>" unless @header_red
@header_red = true
@output.puts " <script type=\"text/javascript\">makeRed('div_group_#{example_group_number}');</script>" unless @example_group_red
@output.puts " <script type=\"text/javascript\">makeRed('example_group_#{example_group_number}');</script>" unless @example_group_red
@example_group_red = true
move_progress
- @output.puts " <dd class=\"example #{failure_style}\">"
+ @output.puts " <dd class=\"example #{exception.pending_fixed? ? 'pending_fixed' : 'failed'}\">"
@output.puts " <span class=\"failed_spec_name\">#{h(example.description)}</span>"
@output.puts " <span class=\"duration\">#{sprintf('%.5f', example.execution_result[:run_time])}s</span>"
@output.puts " <div class=\"failure\" id=\"failure_#{@failed_examples.size}\">"
@@ -11,6 +11,10 @@ class PendingExampleFixedError < Test::Unit::AssertionFailedError; end
class PendingExampleFixedError < StandardError; end
end
+ class PendingExampleFixedError
+ def pending_fixed?; true; end
+ end
+
DEFAULT_MESSAGE = 'No reason given'
# @overload pending()
@@ -29,6 +29,36 @@ def metadata_hash(*args)
example_group.run
example.exception.should be_nil
end
+
+ it "returns false for pending_fixed? if not pending fixed" do
+ example = example_group.example { fail }
+ example_group.run
+ example.exception.should_not be_pending_fixed
+ end
+
+ it "returns true for pending_fixed? if pending fixed" do
+ example = example_group.example do
+ pending("fixed") do
+ true
+ end
+ end
+ example_group.run
+ example.exception.should be_pending_fixed
+ end
+ end
+
+ describe "#failure_type" do
+ it "returns 'pending_fixed' for a PendingExampleFixedError" do
+ example = example_group.example do
+ pending("this message") do
+ true
+ end
+ end
+ example_group.run
+ example.exception.should be_pending_fixed
+ end
+
+
end
describe "auto-generated example descriptions" do

0 comments on commit 7fa264f

Please sign in to comment.