mirror of
https://github.com/teampoltergeist/poltergeist.git
synced 2022-11-09 12:05:00 -05:00
move inspector options into phantomjs_options
This commit is contained in:
parent
ad7e7b9efa
commit
e270c89d1d
4 changed files with 17 additions and 21 deletions
|
@ -10,14 +10,13 @@ module Capybara::Poltergeist
|
|||
client
|
||||
end
|
||||
|
||||
attr_reader :pid, :port, :path, :inspector, :window_size, :phantomjs_options
|
||||
attr_reader :pid, :port, :path, :window_size, :phantomjs_options
|
||||
|
||||
def initialize(port, inspector = nil, path = nil, window_size = nil, phantomjs_options = nil)
|
||||
def initialize(port, path = nil, window_size = nil, phantomjs_options = nil)
|
||||
@port = port
|
||||
@inspector = inspector
|
||||
@path = path || PHANTOMJS_NAME
|
||||
@window_size = window_size || [1024, 768]
|
||||
@phantomjs_options = phantomjs_options
|
||||
@path = path || PHANTOMJS_NAME
|
||||
@window_size = window_size || [1024, 768]
|
||||
@phantomjs_options = phantomjs_options || []
|
||||
|
||||
pid = Process.pid
|
||||
at_exit { stop if Process.pid == pid }
|
||||
|
@ -49,16 +48,7 @@ module Capybara::Poltergeist
|
|||
def command
|
||||
@command ||= begin
|
||||
parts = [path]
|
||||
|
||||
if phantomjs_options
|
||||
parts += phantomjs_options
|
||||
end
|
||||
|
||||
if inspector
|
||||
parts << "--remote-debugger-port=#{inspector.port}"
|
||||
parts << "--remote-debugger-autorun=yes"
|
||||
end
|
||||
|
||||
parts.concat phantomjs_options
|
||||
parts << PHANTOMJS_SCRIPT
|
||||
parts << port
|
||||
parts.concat window_size
|
||||
|
|
|
@ -31,7 +31,13 @@ module Capybara::Poltergeist
|
|||
end
|
||||
|
||||
def client
|
||||
@client ||= Client.start(server.port, inspector, options[:phantomjs], options[:window_size], options[:phantomjs_options])
|
||||
@client ||= Client.start(server.port, options[:phantomjs], options[:window_size], phantomjs_options)
|
||||
end
|
||||
|
||||
def phantomjs_options
|
||||
list = options[:phantomjs_options] || []
|
||||
list += ["--remote-debugger-port=#{inspector.port}", "--remote-debugger-autorun=yes"] if inspector
|
||||
list
|
||||
end
|
||||
|
||||
def client_pid
|
||||
|
|
|
@ -21,7 +21,7 @@ module Capybara::Poltergeist
|
|||
end
|
||||
|
||||
it 'raises an error if phantomjs returns a non-zero exit code' do
|
||||
subject = Client.new(6000, nil, 'exit 42 && ')
|
||||
subject = Client.new(6000, 'exit 42 && ')
|
||||
expect { subject.start }.to raise_error(Error)
|
||||
|
||||
begin
|
||||
|
@ -32,7 +32,7 @@ module Capybara::Poltergeist
|
|||
end
|
||||
|
||||
context "with width and height specified" do
|
||||
subject { Client.new(6000, nil, nil, [800, 600]) }
|
||||
subject { Client.new(6000, nil, [800, 600]) }
|
||||
|
||||
it "starts phantomjs, passing the width and height through" do
|
||||
Spawn.should_receive(:spawn).with("phantomjs", Client::PHANTOMJS_SCRIPT, 6000, 800, 600)
|
||||
|
@ -41,7 +41,7 @@ module Capybara::Poltergeist
|
|||
end
|
||||
|
||||
context "with additional command-line options" do
|
||||
subject { Client.new(6000, nil, nil, nil, %w[--ignore-ssl-error=yes --load-images=no]) }
|
||||
subject { Client.new(6000, nil, nil, %w[--ignore-ssl-error=yes --load-images=no]) }
|
||||
it 'passed additional command-line options to phantomjs' do
|
||||
Spawn.should_receive(:spawn).with("phantomjs", '--ignore-ssl-error=yes', '--load-images=no', Client::PHANTOMJS_SCRIPT, 6000, 1024, 768)
|
||||
subject.start
|
||||
|
|
|
@ -57,7 +57,7 @@ module Capybara::Poltergeist
|
|||
server = stub
|
||||
server.stub(:port).and_return(64297)
|
||||
Server.should_receive(:new).and_return(server)
|
||||
Client.should_receive(:start).with(64297, nil, nil, [800, 600], nil)
|
||||
Client.should_receive(:start).with(64297, nil, [800, 600], [])
|
||||
subject.client
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue