Skip to content

Commit

Permalink
Fix for when step fails in scenario that already failed in background
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwynne committed Sep 21, 2009
1 parent 1b556dc commit ae286fa
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
8 changes: 5 additions & 3 deletions lib/cucumber/formatter/html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ def visit_background_name(keyword, name, file_colon_line, source_indent)

def before_visit_feature_element(feature_element)
start_buffering :feature_element
@exceptions = []
end

def after_visit_feature_element(feature_element)
Expand Down Expand Up @@ -198,9 +197,11 @@ def before_visit_step_result(keyword, step_match, multiline_arg, status, excepti
start_buffering :step_result
@hide_this_step = false
if exception
@hide_this_step = true if @exceptions.index(exception)
if @exceptions.include?(exception)
@hide_this_step = true
return
end
@exceptions << exception
return
end
if status != :failed && @in_background ^ background
@hide_this_step = true
Expand Down Expand Up @@ -229,6 +230,7 @@ def visit_step_name(keyword, step_match, status, source_indent, background)
end

def visit_exception(exception, status)
return if @hide_this_step
builder.pre(format_exception(exception), :class => status)
end

Expand Down
28 changes: 22 additions & 6 deletions spec/cucumber/formatter/html_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,36 @@ def define_steps
it { @doc.should have_css_node('.feature .scenario table td', /foo/) }
end

describe "with a step that fails" do
describe "with a step that fails in the scenario" do
define_steps do
Given /boo/ do
raise 'eek'
end
Given(/boo/) { raise 'eek' }
end

define_feature(<<-FEATURE)
Scenario: Monkey get a fright
Scenario: Monkey gets a fright
Given boo
FEATURE

it { @doc.should have_css_node('.feature .scenario .step.failed', /eek/) }
end

describe "with a step that fails in the backgound" do
define_steps do
Given(/boo/) { raise 'eek' }
end

define_feature(<<-FEATURE)
Background:
Given boo
Scenario:
Given yay
FEATURE

it { @doc.should have_css_node('.feature .background .step.failed', /eek/) }
it { @doc.should_not have_css_node('.feature .scenario .step.failed', //) }
it { @doc.should have_css_node('.feature .scenario .step.undefined', /yay/) }
end

end
end
end
Expand Down

0 comments on commit ae286fa

Please sign in to comment.