mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Merge pull request #463 from ebeigarts/master
Make sure that exit codes of tests are propagated properly when using selenium webdriver.
This commit is contained in:
commit
52dbbf6213
4 changed files with 40 additions and 0 deletions
|
@ -16,7 +16,10 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
|
|||
|
||||
main = Process.pid
|
||||
at_exit do
|
||||
# Store the exit status of the test run since it goes away after calling the at_exit proc...
|
||||
@exit_status = $!.status if $!.is_a?(SystemExit)
|
||||
quit if Process.pid == main
|
||||
exit @exit_status if @exit_status # Force exit with stored status
|
||||
end
|
||||
end
|
||||
@browser
|
||||
|
|
|
@ -26,4 +26,25 @@ describe Capybara::Selenium::Driver do
|
|||
browser.quit
|
||||
end
|
||||
end
|
||||
|
||||
describe "exit codes" do
|
||||
before do
|
||||
@current_dir = Dir.getwd
|
||||
Dir.chdir(File.join(File.dirname(__FILE__), '..', '..'))
|
||||
end
|
||||
|
||||
after do
|
||||
Dir.chdir(@current_dir)
|
||||
end
|
||||
|
||||
it "should have return code 1 when running selenium_driver_rspec_failure.rb" do
|
||||
`rspec spec/fixtures/selenium_driver_rspec_failure.rb`
|
||||
$?.exitstatus.should be 1
|
||||
end
|
||||
|
||||
it "should have return code 0 when running selenium_driver_rspec_success.rb" do
|
||||
`rspec spec/fixtures/selenium_driver_rspec_success.rb`
|
||||
$?.exitstatus.should be 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
8
spec/fixtures/selenium_driver_rspec_failure.rb
vendored
Normal file
8
spec/fixtures/selenium_driver_rspec_failure.rb
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Capybara::Selenium::Driver do
|
||||
it "should exit with a non-zero exit status" do
|
||||
browser = Capybara::Selenium::Driver.new(TestApp).browser
|
||||
true.should == false
|
||||
end
|
||||
end
|
8
spec/fixtures/selenium_driver_rspec_success.rb
vendored
Normal file
8
spec/fixtures/selenium_driver_rspec_success.rb
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Capybara::Selenium::Driver do
|
||||
it "should exit with a zero exit status" do
|
||||
browser = Capybara::Selenium::Driver.new(TestApp).browser
|
||||
true.should == true
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue