spec/integration_spec.rb in parallel_tests-0.7.1 vs spec/integration_spec.rb in parallel_tests-0.7.2
- old
+ new
@@ -18,10 +18,14 @@
ensure_folder File.dirname(path)
File.open(path, 'w'){|f| f.write content }
path
end
+ def read(file)
+ File.read "#{folder}/#{file}"
+ end
+
def bin_folder
"#{File.expand_path(File.dirname(__FILE__))}/../bin"
end
def executable(options={})
@@ -181,10 +185,17 @@
results.should include("Took")
end
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"
write "features/b.feature", "Feature: xxx\n Scenario: xxx\n Given I FAIL"
write "features/steps/a.rb", "Given('I print TEST_ENV_NUMBER'){ puts \"YOUR TEST ENV IS \#{ENV['TEST_ENV_NUMBER']}!\" }"
@@ -194,11 +205,24 @@
result.should include('YOUR TEST ENV IS 2!')
result.should include('YOUR TEST ENV IS !')
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"
}
result = run_tests "features", :type => "cucumber", :add => '-n 3'
result.scan(/YOUR TEST ENV IS \d?!/).sort.should == ["YOUR TEST ENV IS !", "YOUR TEST ENV IS 2!"]