Rename Driver#body to Driver#html
For historical reasons, Session#html used to delegate to Driver#body, (but Session#body & Session#source delegate to Driver#source). This commit puts an end to this confusing state of affairs. This change requires driver authors to update their drivers.
This commit is contained in:
parent
c77e27ed4c
commit
954fcc69a3
|
@ -9,6 +9,8 @@
|
||||||
they are disabled. [Jonas Nicklas]
|
they are disabled. [Jonas Nicklas]
|
||||||
* Can no longer find elements by id via `find(:foo)`, use `find("#foo")` or
|
* Can no longer find elements by id via `find(:foo)`, use `find("#foo")` or
|
||||||
`find_by_id("foo")` instead. [Jonas Nicklas]
|
`find_by_id("foo")` instead. [Jonas Nicklas]
|
||||||
|
* Rename `Driver#body` to `Driver#html` (relevant only for driver authors) [Jo
|
||||||
|
Liss]
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ class Capybara::Driver::Base
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
end
|
end
|
||||||
|
|
||||||
def body
|
def html
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ class Capybara::RackTest::Browser
|
||||||
@dom = nil
|
@dom = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def body
|
def html
|
||||||
dom.to_xml
|
dom.to_xml
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -66,8 +66,8 @@ class Capybara::RackTest::Driver < Capybara::Driver::Base
|
||||||
browser.find(selector)
|
browser.find(selector)
|
||||||
end
|
end
|
||||||
|
|
||||||
def body
|
def html
|
||||||
browser.body
|
browser.html
|
||||||
end
|
end
|
||||||
|
|
||||||
def source
|
def source
|
||||||
|
|
|
@ -38,7 +38,7 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
|
||||||
browser.page_source
|
browser.page_source
|
||||||
end
|
end
|
||||||
|
|
||||||
def body
|
def html
|
||||||
browser.page_source
|
browser.page_source
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -100,10 +100,10 @@ module Capybara
|
||||||
|
|
||||||
##
|
##
|
||||||
#
|
#
|
||||||
# @return [String] A snapshot of the HTML of the current document, as it looks right now (potentially modified by JavaScript).
|
# @return [String] A snapshot of the DOM of the current document, as it looks right now (potentially modified by JavaScript).
|
||||||
#
|
#
|
||||||
def html
|
def html
|
||||||
driver.body
|
driver.html
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -30,21 +30,21 @@ describe Capybara::Session do
|
||||||
@session.driver.options[:respect_data_method] = true
|
@session.driver.options[:respect_data_method] = true
|
||||||
@session.visit "/with_html"
|
@session.visit "/with_html"
|
||||||
@session.click_link "A link with data-method"
|
@session.click_link "A link with data-method"
|
||||||
@session.body.should include('The requested object was deleted')
|
@session.html.should include('The requested object was deleted')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not use data-method if option is false" do
|
it "should not use data-method if option is false" do
|
||||||
@session.driver.options[:respect_data_method] = false
|
@session.driver.options[:respect_data_method] = false
|
||||||
@session.visit "/with_html"
|
@session.visit "/with_html"
|
||||||
@session.click_link "A link with data-method"
|
@session.click_link "A link with data-method"
|
||||||
@session.body.should include('Not deleted')
|
@session.html.should include('Not deleted')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should use data-method if available even if it's capitalized" do
|
it "should use data-method if available even if it's capitalized" do
|
||||||
@session.driver.options[:respect_data_method] = true
|
@session.driver.options[:respect_data_method] = true
|
||||||
@session.visit "/with_html"
|
@session.visit "/with_html"
|
||||||
@session.click_link "A link with capitalized data-method"
|
@session.click_link "A link with capitalized data-method"
|
||||||
@session.body.should include('The requested object was deleted')
|
@session.html.should include('The requested object was deleted')
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
@ -57,7 +57,7 @@ describe Capybara::Session do
|
||||||
it "should submit an empty form-data section if no file is submitted" do
|
it "should submit an empty form-data section if no file is submitted" do
|
||||||
@session.visit("/form")
|
@session.visit("/form")
|
||||||
@session.click_button("Upload Empty")
|
@session.click_button("Upload Empty")
|
||||||
@session.body.should include('Successfully ignored empty file field.')
|
@session.html.should include('Successfully ignored empty file field.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -73,27 +73,27 @@ describe Capybara::RackTest::Driver do
|
||||||
it 'should always set headers' do
|
it 'should always set headers' do
|
||||||
@driver = Capybara::RackTest::Driver.new(TestApp, :headers => {'HTTP_FOO' => 'foobar'})
|
@driver = Capybara::RackTest::Driver.new(TestApp, :headers => {'HTTP_FOO' => 'foobar'})
|
||||||
@driver.visit('/get_header')
|
@driver.visit('/get_header')
|
||||||
@driver.body.should include('foobar')
|
@driver.html.should include('foobar')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should keep headers on link clicks' do
|
it 'should keep headers on link clicks' do
|
||||||
@driver = Capybara::RackTest::Driver.new(TestApp, :headers => {'HTTP_FOO' => 'foobar'})
|
@driver = Capybara::RackTest::Driver.new(TestApp, :headers => {'HTTP_FOO' => 'foobar'})
|
||||||
@driver.visit('/header_links')
|
@driver.visit('/header_links')
|
||||||
@driver.find('.//a').first.click
|
@driver.find('.//a').first.click
|
||||||
@driver.body.should include('foobar')
|
@driver.html.should include('foobar')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should keep headers on form submit' do
|
it 'should keep headers on form submit' do
|
||||||
@driver = Capybara::RackTest::Driver.new(TestApp, :headers => {'HTTP_FOO' => 'foobar'})
|
@driver = Capybara::RackTest::Driver.new(TestApp, :headers => {'HTTP_FOO' => 'foobar'})
|
||||||
@driver.visit('/header_links')
|
@driver.visit('/header_links')
|
||||||
@driver.find('.//input').first.click
|
@driver.find('.//input').first.click
|
||||||
@driver.body.should include('foobar')
|
@driver.html.should include('foobar')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should keep headers on redirects' do
|
it 'should keep headers on redirects' do
|
||||||
@driver = Capybara::RackTest::Driver.new(TestApp, :headers => {'HTTP_FOO' => 'foobar'})
|
@driver = Capybara::RackTest::Driver.new(TestApp, :headers => {'HTTP_FOO' => 'foobar'})
|
||||||
@driver.visit('/get_header_via_redirect')
|
@driver.visit('/get_header_via_redirect')
|
||||||
@driver.body.should include('foobar')
|
@driver.html.should include('foobar')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ describe Capybara::RackTest::Driver do
|
||||||
|
|
||||||
it "should follow 5 redirects" do
|
it "should follow 5 redirects" do
|
||||||
@driver.visit("/redirect/5/times")
|
@driver.visit("/redirect/5/times")
|
||||||
@driver.body.should include('redirection complete')
|
@driver.html.should include('redirection complete')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not follow more than 6 redirects" do
|
it "should not follow more than 6 redirects" do
|
||||||
|
@ -140,7 +140,7 @@ describe Capybara::RackTest::Driver do
|
||||||
|
|
||||||
it "should follow 21 redirects" do
|
it "should follow 21 redirects" do
|
||||||
@driver.visit("/redirect/21/times")
|
@driver.visit("/redirect/21/times")
|
||||||
@driver.body.should include('redirection complete')
|
@driver.html.should include('redirection complete')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not follow more than 21 redirects" do
|
it "should not follow more than 21 redirects" do
|
||||||
|
|
Loading…
Reference in New Issue