1
0
Fork 0
mirror of https://github.com/teampoltergeist/poltergeist.git synced 2022-11-09 12:05:00 -05:00

fix steps and tidy a bit

This commit is contained in:
Jon Leighton 2012-07-11 20:05:10 +01:00
parent 966763dcc7
commit ad7e7b9efa
4 changed files with 12 additions and 17 deletions

View file

@ -10,14 +10,13 @@ module Capybara::Poltergeist
client
end
attr_reader :pid, :port, :path, :inspector, :width, :height, :phantomjs_options
attr_reader :pid, :port, :path, :inspector, :window_size, :phantomjs_options
def initialize(port, inspector = nil, path = nil, width = 1024, height = 768, phantomjs_options=nil)
@port = port
@inspector = inspector
@path = path || PHANTOMJS_NAME
@width = width
@height = height
def initialize(port, inspector = nil, 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
pid = Process.pid
@ -62,8 +61,7 @@ module Capybara::Poltergeist
parts << PHANTOMJS_SCRIPT
parts << port
parts << width
parts << height
parts.concat window_size
parts
end
end

View file

@ -13,9 +13,6 @@ module Capybara::Poltergeist
@server = nil
@client = nil
@headers = {}
if @options[:window_size]
@width, @height = @options[:window_size]
end
@app_server = Capybara::Server.new(app)
@app_server.boot if Capybara.run_server
@ -34,7 +31,7 @@ module Capybara::Poltergeist
end
def client
@client ||= Client.start(server.port, inspector, options[:phantomjs], @width, @height, options[:phantomjs_options])
@client ||= Client.start(server.port, inspector, options[:phantomjs], options[:window_size], options[:phantomjs_options])
end
def client_pid

View file

@ -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, 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,9 +41,9 @@ module Capybara::Poltergeist
end
context "with additional command-line options" do
subject { Client.new(6000, nil, nil, nil, nil, %w[--ignore-ssl-error=yes --load-images=no]) }
subject { Client.new(6000, nil, 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, nil, nil)
Spawn.should_receive(:spawn).with("phantomjs", '--ignore-ssl-error=yes', '--load-images=no', Client::PHANTOMJS_SCRIPT, 6000, 1024, 768)
subject.start
end
end

View file

@ -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)
Client.should_receive(:start).with(64297, nil, nil, [800, 600], nil)
subject.client
end
end