Skip to content

Commit

Permalink
Add the feature
Browse files Browse the repository at this point in the history
  • Loading branch information
ywen committed Jun 1, 2013
1 parent 903bfee commit 42624a5
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ test/version_tmp
tmp
capybara-*.html
Gemfile.lock
tags
10 changes: 10 additions & 0 deletions features/fail_fast.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Feature: Fail fast option
In order to save running time
As a developer
I want spinach to fail fast when I so desire

Scenario: fail fast
Given I have a feature that has a failure
Given I have a feature that has no error or failure
When I run both of them with fail-fast option
Then the tests stop at the first one
29 changes: 2 additions & 27 deletions features/steps/exit_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,11 @@ class ExitStatus < Spinach::FeatureSteps
include Integration::SpinachRunner

Given "I have a feature that has no error or failure" do
write_file('features/success_feature.feature', """
Feature: A success feature
Scenario: This is scenario will succeed
Then I succeed
""")
write_file('features/steps/success_feature.rb',
'class ASuccessFeature < Spinach::FeatureSteps
feature "A success feature"
Then "I succeed" do
end
end')
@feature = "features/success_feature.feature"
@feature = Integration::FeatureGenerator.success_feature
end

Given "I have a feature that has a failure" do
write_file('features/failure_feature.feature', """
Feature: A failure feature
Scenario: This is scenario will fail
Then I fail
""")
write_file('features/steps/failure_feature.rb',
'class AFailureFeature < Spinach::FeatureSteps
feature "A failure feature"
Then "I fail" do
true.must_equal false
end
end')
@feature = "features/failure_feature.feature"
@feature = Integration::FeatureGenerator.failure_feature
end

When "I run it" do
Expand Down
21 changes: 21 additions & 0 deletions features/steps/fail_fast_option.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Spinach::Features::FailFastOption < Spinach::FeatureSteps
include Integration::SpinachRunner

step 'I have a feature that has a failure' do
@features ||= []
@features << Integration::FeatureGenerator.failure_feature
end

step 'I have a feature that has no error or failure' do
@features ||= []
@features << Integration::FeatureGenerator.success_feature
end

step 'I run both of them with fail-fast option' do
run_feature @features.join(" "), append: '--fail-fast'
end

step 'the tests stop at the first one' do
@stdout.must_match("(0) Successful")
end
end
41 changes: 41 additions & 0 deletions features/support/feature_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module Integration
class FeatureGenerator
class << self
include Filesystem

def success_feature
write_file('features/success_feature.feature', """
Feature: A success feature
Scenario: This is scenario will succeed
Then I succeed
""")
write_file('features/steps/success_feature.rb',
'class ASuccessFeature < Spinach::FeatureSteps
feature "A success feature"
Then "I succeed" do
end
end')
"features/success_feature.feature"

end

def failure_feature
write_file('features/failure_feature.feature', """
Feature: A failure feature
Scenario: This is scenario will fail
Then I fail
""")
write_file('features/steps/failure_feature.rb',
'class AFailureFeature < Spinach::FeatureSteps
feature "A failure feature"
Then "I fail" do
true.must_equal false
end
end')
"features/failure_feature.feature"
end
end
end
end

0 comments on commit 42624a5

Please sign in to comment.