Skip to content

Commit

Permalink
Merge pull request #23 from guard/fix_22_background_failure_case
Browse files Browse the repository at this point in the history
handle background scenario failures [fix #22]
  • Loading branch information
e2 committed Mar 8, 2015
2 parents 453cf2f + 4053399 commit b52186c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/guard/cucumber/notification_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def initialize(step_mother, _path_or_io, options)
@step_mother = step_mother
end

def before_background(background)
@feature_name = background.feature.name
end

# Notification after all features have completed.
#
# @param [Array[Cucumber::Ast::Feature]] features the ran features
Expand Down
20 changes: 20 additions & 0 deletions spec/guard/cucumber/notification_formatter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,24 @@
subject.after_features(nil)
end
end

describe "#step_name" do
context "when failure is in a background step" do
let(:step_match) { instance_double(Cucumber::StepMatch) }
let(:feature) { instance_double(Cucumber::Ast::Feature, name: "feature1") }
let(:background) { instance_double(Cucumber::Ast::Background, feature: feature) }

before do
subject.before_background(background)
allow(step_match).to receive(:format_args) do |block|
block.call "step_name1"
end
end

it "notifies with a valid feature name" do
expect(Guard::Compat::UI).to receive(:notify).with("*step_name1*", hash_including(title: "feature1"))
subject.step_name(nil, step_match, :failed, nil, nil, nil)
end
end
end
end

0 comments on commit b52186c

Please sign in to comment.