Permalink
Browse files

Report missing steps as errors.

Spinach exits with a non-0 exit code when there are undefined steps.
  • Loading branch information...
1 parent 515588d commit c082d3fc6ba319b47749855d89b0d0315eb88bcc @spraints committed Jul 17, 2012
View
7 acceptance/spinach/features/spinach_example.feature
@@ -16,4 +16,9 @@ Feature: Example feature
Scenario: Bad coder
Given that I can't code for peanuts
And I write step definitions that throw exceptions
- Then I shouldn't be allowed out in public
+ Then I shouldn't be allowed out in public
+
+ Scenario: Missing steps
+ Given that I am a lazy hacker
+ And I don't implement steps before I commit
+ Then I should be fired
View
12 acceptance/verification_spec.rb
@@ -160,10 +160,10 @@
end
it "should have three tests and two failures" do
- @doc.root.attributes["errors"].should == "1"
+ @doc.root.attributes["errors"].should == "2"
@doc.root.attributes["failures"].should == "1"
- @doc.root.attributes["tests"].should == "3"
- @doc.root.elements.to_a("/testsuite/testcase").size.should == 3
+ @doc.root.attributes["tests"].should == "4"
+ @doc.root.elements.to_a("/testsuite/testcase").size.should == 4
end
it "should have one failure for the lazy hacker" do
@@ -172,6 +172,12 @@
failures.first.attributes["type"].should =~ /ExpectationNotMetError/
end
+ it "should have one failure for missing steps" do
+ failures = @doc.root.elements.to_a("/testsuite/testcase[@name='Missing steps']/failure")
+ failures.size.should == 1
+ failures.first.attributes["type"].should =~ /StepNotDefinedException/
+ end
+
it "should have one failure for the bad coder" do
failures = @doc.root.elements.to_a("/testsuite/testcase[@name='Bad coder']/failure")
failures.size.should == 1
View
5 lib/ci/reporter/spinach.rb
@@ -19,14 +19,11 @@ def before_scenario_run(scenario, step_definitions = nil)
end
def on_undefined_step(step, failure, step_definitions = nil)
- @test_case.name = "#{@test_case.name} (PENDING)"
+ @test_case.failures << SpinachFailure.new(:error, step, failure, nil)
end
def on_failed_step(step, failure, step_location, step_definitions = nil)
@test_case.failures << SpinachFailure.new(:failed, step, failure, step_location)
- #step['name']
- #failure
- #step_location
end
def on_error_step(step, failure, step_location, step_definitions = nil)

0 comments on commit c082d3f

Please sign in to comment.