Trashing Driver::Base#response in favor of #response_headers. Not supported by all browsers(e.g. Selenium)
This commit is contained in:
parent
481e912c5b
commit
5c22edb7cd
|
@ -19,7 +19,11 @@ class Capybara::Driver::Base
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
def response
|
def response_headers
|
||||||
|
raise Capybara::NotSupportedByDriverError
|
||||||
|
end
|
||||||
|
|
||||||
|
def body
|
||||||
raise "Not implemented"
|
raise "Not implemented"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -59,8 +59,12 @@ class Capybara::Driver::Celerity < Capybara::Driver::Base
|
||||||
browser.url
|
browser.url
|
||||||
end
|
end
|
||||||
|
|
||||||
def response
|
def body
|
||||||
Rack::MockResponse.new(browser.status_code, browser.response_headers, browser.html)
|
browser.html
|
||||||
|
end
|
||||||
|
|
||||||
|
def response_headers
|
||||||
|
browser.response_headers
|
||||||
end
|
end
|
||||||
|
|
||||||
def find(selector)
|
def find(selector)
|
||||||
|
|
|
@ -140,6 +140,10 @@ class Capybara::Driver::RackTest < Capybara::Driver::Base
|
||||||
request.url
|
request.url
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def response_headers
|
||||||
|
response.headers
|
||||||
|
end
|
||||||
|
|
||||||
def submit(path, attributes)
|
def submit(path, attributes)
|
||||||
post(path, attributes)
|
post(path, attributes)
|
||||||
follow_redirect! while response.redirect?
|
follow_redirect! while response.redirect?
|
||||||
|
|
|
@ -72,12 +72,8 @@ class Capybara::Driver::Selenium < Capybara::Driver::Base
|
||||||
driver.navigate.to(url(path))
|
driver.navigate.to(url(path))
|
||||||
end
|
end
|
||||||
|
|
||||||
def response
|
def body
|
||||||
#Can I get a response code and headers from Selenium?
|
driver.page_source
|
||||||
#Maybe we should just plug in the location here
|
|
||||||
#and leave more header involved stuff for another driver
|
|
||||||
#(e.g. celerity)
|
|
||||||
Rack::MockResponse.new(-1, {}, driver.page_source)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_url
|
def current_url
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
||||||
|
|
||||||
describe Capybara::Driver::Celerity do
|
if RUBY_PLATFORM =~ /java/
|
||||||
|
describe Capybara::Driver::Celerity do
|
||||||
before do
|
before do
|
||||||
@driver = Capybara::Driver::Celerity.new(TestApp)
|
@driver = Capybara::Driver::Celerity.new(TestApp)
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like "driver"
|
it_should_behave_like "driver"
|
||||||
it_should_behave_like "driver with javascript support"
|
it_should_behave_like "driver with javascript support"
|
||||||
|
it_should_behave_like "driver with header support"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
puts "#{File.basename(__FILE__)} requires JRuby; skipping.."
|
||||||
end
|
end
|
|
@ -0,0 +1,11 @@
|
||||||
|
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
||||||
|
|
||||||
|
describe Capybara::Driver::Culerity do
|
||||||
|
before do
|
||||||
|
@driver = Capybara::Driver::Culerity.new(TestApp)
|
||||||
|
end
|
||||||
|
|
||||||
|
it_should_behave_like "driver"
|
||||||
|
it_should_behave_like "driver with javascript support"
|
||||||
|
it_should_behave_like "driver with header support"
|
||||||
|
end
|
|
@ -6,4 +6,5 @@ describe Capybara::Driver::RackTest do
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like "driver"
|
it_should_behave_like "driver"
|
||||||
|
it_should_behave_like "driver with header support"
|
||||||
end
|
end
|
||||||
|
|
|
@ -92,3 +92,10 @@ shared_examples_for "driver with javascript support" do
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
shared_examples_for "driver with header support" do
|
||||||
|
it "should make headers available through response_headers" do
|
||||||
|
@driver.visit('/with_simple_html')
|
||||||
|
@driver.response_headers['Content-Type'].should == 'text/html'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue