Skip to content
Browse files

Acceptance tests for cucumber integration.

  • Loading branch information...
1 parent 9b8cc28 commit ebfd936498f4df40e88499b69f9a6cf070b34c0c @mathie mathie committed
View
1 Rakefile
@@ -63,6 +63,7 @@ task :generate_output do
begin
`ruby -Ilib acceptance/test_unit_example_test.rb` rescue nil
`ruby -Ilib -S spec --require ci/reporter/rake/rspec_loader --format CI::Reporter::RSpec acceptance/rspec_example_spec.rb` rescue nil
+ `ruby -Ilib -S cucumber --require ci/reporter/rake/cucumber_loader --format CI::Reporter::Cucumber acceptance/cucumber` rescue nil
ensure
ENV.delete 'CI_REPORTS'
end
View
14 acceptance/cucumber/cucumber_example.feature
@@ -0,0 +1,14 @@
+Feature: Example feature
+ As a conscientious developer who writes features
+ I want to be able to see my features passing on the CI Server
+ So that I can bask in the glow of a green bar
+
+ Scenario: Conscientious developer
+ Given that I am a conscientious developer
+ And I write cucumber features
+ Then I should see a green bar
+
+ Scenario: Lazy hacker
+ Given that I am a lazy hacker
+ And I don't bother writing cucumber features
+ Then I should be fired
View
20 acceptance/cucumber/step_definitions/development_steps.rb
@@ -0,0 +1,20 @@
+require 'spec/expectations'
+
+Given /^that I am a conscientious developer$/ do
+end
+
+Given /^I write cucumber features$/ do
+end
+
+Then /^I should see a green bar$/ do
+end
+
+Given /^that I am a lazy hacker$/ do
+end
+
+Given /^I don't bother writing cucumber features$/ do
+ false.should be_true
+end
+
+Then /^I should be fired$/ do
+end
View
35 acceptance/verification_spec.rb
@@ -62,3 +62,38 @@
doc.root.elements.to_a("/testsuite/testcase").size.should == 1
end
end
+
+describe "Cucumber acceptance" do
+ it "should generate two XML files" do
+ File.exist?(File.join(REPORTS_DIR, 'CUCUMBER-example-feature-conscientious-developer.xml')).should == true
+ File.exist?(File.join(REPORTS_DIR, 'CUCUMBER-example-feature-lazy-hacker.xml')).should == true
+ end
+
+ it "should have three tests and no failures for the conscientious developer" do
+ doc = File.open(File.join(REPORTS_DIR, 'CUCUMBER-example-feature-conscientious-developer.xml')) do |f|
+ REXML::Document.new(f)
+ end
+ doc.root.attributes["errors"].should == "0"
+ doc.root.attributes["failures"].should == "0"
+ doc.root.attributes["tests"].should == "3"
+ doc.root.elements.to_a("/testsuite/testcase").size.should == 3
+ end
+
+ it "should have three tests, one failure and one error (skipped) for the lazy hacker" do
+ doc = File.open(File.join(REPORTS_DIR, 'CUCUMBER-example-feature-lazy-hacker.xml')) do |f|
+ REXML::Document.new(f)
+ end
+ doc.root.attributes["errors"].should == "1"
+ doc.root.attributes["failures"].should == "1"
+ doc.root.attributes["tests"].should == "3"
+ doc.root.elements.to_a("/testsuite/testcase").size.should == 3
+
+ failures = doc.root.elements.to_a("/testsuite/testcase/failure")
+ failures.size.should == 1
+ failures.first.attributes["type"].should == "Spec::Expectations::ExpectationNotMetError"
+
+ error = doc.root.elements.to_a("/testsuite/testcase/error")
+ error.size.should == 1
+ error.first.attributes["type"].should == "Skipped"
+ end
+end

0 comments on commit ebfd936

Please sign in to comment.
Something went wrong with that request. Please try again.