Skip to content

Commit

Permalink
add integration test for cucumber runner, so this does not happen again
Browse files Browse the repository at this point in the history
  • Loading branch information
grosser committed Mar 7, 2012
1 parent 9ca3afd commit 37e6914
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion spec/integration_spec.rb
Expand Up @@ -20,6 +20,10 @@ def write(file, content)
path
end

def read(file)
File.read "#{folder}/#{file}"
end

def bin_folder
"#{File.expand_path(File.dirname(__FILE__))}/../bin"
end
Expand Down Expand Up @@ -183,6 +187,13 @@ def run_tests(test_folder, options={})
end

context "Cucumber" do
before do
write "features/steps/a.rb", "
Given('I print TEST_ENV_NUMBER'){ puts \"YOUR TEST ENV IS \#{ENV['TEST_ENV_NUMBER']}!\" }
And('I sleep a bit'){ sleep 0.2 }
"
end

it "passes TEST_ENV_NUMBER when running with pattern (issue #86)" do
write "features/good1.feature", "Feature: xxx\n Scenario: xxx\n Given I print TEST_ENV_NUMBER"
write "features/good2.feature", "Feature: xxx\n Scenario: xxx\n Given I print TEST_ENV_NUMBER"
Expand All @@ -196,8 +207,21 @@ def run_tests(test_folder, options={})
result.should_not include('I FAIL')
end

it "writes a runtime log" do
log = "tmp/parallel_runtime_cucumber.log"
write(log, "x")
2.times{|i|
# needs sleep so that runtime loggers dont overwrite each other initially
write "features/good#{i}.feature", "Feature: xxx\n Scenario: xxx\n Given I print TEST_ENV_NUMBER\n And I sleep a bit"
}
run_tests "features", :type => "cucumber"
read(log).gsub(/\.\d+/,'').split("\n").should =~ [
"features/good0.feature:0",
"features/good1.feature:0"
]
end

it "runs each feature once when there are more processes then features (issue #89)" do
write "features/steps/a.rb", "Given('I print TEST_ENV_NUMBER'){ puts \"YOUR TEST ENV IS \#{ENV['TEST_ENV_NUMBER']}!\" }"
2.times{|i|
write "features/good#{i}.feature", "Feature: xxx\n Scenario: xxx\n Given I print TEST_ENV_NUMBER"
}
Expand Down

0 comments on commit 37e6914

Please sign in to comment.