mirror of
https://github.com/teampoltergeist/poltergeist.git
synced 2022-11-09 12:05:00 -05:00
Raise a better error when phantomjs returns a non-zero exit status. Fixes #23.
This commit is contained in:
parent
3645c3e295
commit
806a204697
4 changed files with 34 additions and 1 deletions
|
@ -196,6 +196,10 @@ makes debugging easier). Running `rake autocompile` will watch the
|
|||
|
||||
* Fix bug where we could end up interacting with an obsolete element. [Issue #30]
|
||||
|
||||
* Raise an suitable error if PhantomJS returns a non-zero exit status.
|
||||
Previously a version error would be raised, indicating that the
|
||||
PhantomJS version was too old when in fact it did not start at all. [Issue #23]
|
||||
|
||||
### 0.4.0 ###
|
||||
|
||||
* Element click position is now calculated using the native
|
||||
|
|
|
@ -56,9 +56,13 @@ module Capybara::Poltergeist
|
|||
return if @phantomjs_version_checked
|
||||
|
||||
version = `#{path} --version`.chomp
|
||||
if version < PHANTOMJS_VERSION
|
||||
|
||||
if $? != 0
|
||||
raise PhantomJSFailed.new($?)
|
||||
elsif version < PHANTOMJS_VERSION
|
||||
raise PhantomJSTooOld.new(version)
|
||||
end
|
||||
|
||||
@phantomjs_version_checked = true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -82,5 +82,19 @@ module Capybara
|
|||
"PhantomJS version #{version} is too old. You must use at least version #{Client::PHANTOMJS_VERSION}"
|
||||
end
|
||||
end
|
||||
|
||||
class PhantomJSFailed < Error
|
||||
attr_reader :status
|
||||
|
||||
def initialize(status)
|
||||
@status = status
|
||||
end
|
||||
|
||||
def message
|
||||
"PhantomJS returned non-zero exit status #{status.exitstatus}. Ensure there is an X display available and " \
|
||||
"that DISPLAY is set. (See the Poltergeist README for details.) Make sure 'phantomjs --version' " \
|
||||
"runs successfully on your system."
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,5 +17,16 @@ module Capybara::Poltergeist
|
|||
e.message.should include('1.3.0')
|
||||
end
|
||||
end
|
||||
|
||||
it 'raises an error if phantomjs returns a non-zero exit code' do
|
||||
subject = Client.new(6000, nil, 'exit 42 && ')
|
||||
expect { subject.start }.to raise_error(Error)
|
||||
|
||||
begin
|
||||
subject.start
|
||||
rescue PhantomJSFailed => e
|
||||
e.message.should include('42')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue