mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Rearranged drivers a little bit
This commit is contained in:
parent
719b2a92cf
commit
fe5e308f41
8 changed files with 28 additions and 51 deletions
|
@ -3,10 +3,6 @@ class Capybara::Driver::Base
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_path
|
|
||||||
URI.parse(current_url).path
|
|
||||||
end
|
|
||||||
|
|
||||||
def visit(path)
|
def visit(path)
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
end
|
end
|
||||||
|
@ -15,6 +11,14 @@ class Capybara::Driver::Base
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def source
|
||||||
|
raise NotImplementedError
|
||||||
|
end
|
||||||
|
|
||||||
|
def body
|
||||||
|
raise NotImplementedError
|
||||||
|
end
|
||||||
|
|
||||||
def execute_script(script)
|
def execute_script(script)
|
||||||
raise Capybara::NotSupportedByDriverError
|
raise Capybara::NotSupportedByDriverError
|
||||||
end
|
end
|
||||||
|
@ -23,13 +27,6 @@ class Capybara::Driver::Base
|
||||||
raise Capybara::NotSupportedByDriverError
|
raise Capybara::NotSupportedByDriverError
|
||||||
end
|
end
|
||||||
|
|
||||||
def wait?
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
def wait_until *args
|
|
||||||
end
|
|
||||||
|
|
||||||
def response_headers
|
def response_headers
|
||||||
raise Capybara::NotSupportedByDriverError
|
raise Capybara::NotSupportedByDriverError
|
||||||
end
|
end
|
||||||
|
@ -38,16 +35,15 @@ class Capybara::Driver::Base
|
||||||
raise Capybara::NotSupportedByDriverError
|
raise Capybara::NotSupportedByDriverError
|
||||||
end
|
end
|
||||||
|
|
||||||
def body
|
|
||||||
raise NotImplementedError
|
|
||||||
end
|
|
||||||
|
|
||||||
def within_frame(frame_id)
|
def within_frame(frame_id)
|
||||||
raise Capybara::NotSupportedByDriverError
|
raise Capybara::NotSupportedByDriverError
|
||||||
end
|
end
|
||||||
|
|
||||||
def source
|
def wait?
|
||||||
raise NotImplementedError
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
def wait_until(*args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def cleanup!
|
def cleanup!
|
||||||
|
|
|
@ -17,7 +17,7 @@ class Capybara::Driver::Celerity < Capybara::Driver::Base
|
||||||
if tag_name == "select" and node.multiple?
|
if tag_name == "select" and node.multiple?
|
||||||
node.selected_options
|
node.selected_options
|
||||||
else
|
else
|
||||||
super
|
self[:value]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ module Capybara
|
||||||
end
|
end
|
||||||
|
|
||||||
def value
|
def value
|
||||||
self[:value]
|
raise NotImplementedError
|
||||||
end
|
end
|
||||||
|
|
||||||
def set(value)
|
def set(value)
|
||||||
|
|
|
@ -30,7 +30,7 @@ class Capybara::Driver::RackTest < Capybara::Driver::Base
|
||||||
if tag_name == 'textarea'
|
if tag_name == 'textarea'
|
||||||
node.content
|
node.content
|
||||||
else
|
else
|
||||||
super
|
self[:value]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ class Capybara::Driver::Selenium < Capybara::Driver::Base
|
||||||
if tag_name == "select" and self[:multiple]
|
if tag_name == "select" and self[:multiple]
|
||||||
node.find_elements(:xpath, ".//option").select { |n| n.selected? }.map { |n| n.text }
|
node.find_elements(:xpath, ".//option").select { |n| n.selected? }.map { |n| n.text }
|
||||||
else
|
else
|
||||||
super
|
self[:value]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@ module Capybara
|
||||||
|
|
||||||
def_delegator :driver, :cleanup!
|
def_delegator :driver, :cleanup!
|
||||||
def_delegator :driver, :current_url
|
def_delegator :driver, :current_url
|
||||||
def_delegator :driver, :current_path
|
|
||||||
def_delegator :driver, :response_headers
|
def_delegator :driver, :response_headers
|
||||||
def_delegator :driver, :status_code
|
def_delegator :driver, :status_code
|
||||||
def_delegator :driver, :visit
|
def_delegator :driver, :visit
|
||||||
|
@ -52,6 +51,10 @@ module Capybara
|
||||||
super || current_node.respond_to?(method)
|
super || current_node.respond_to?(method)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def current_path
|
||||||
|
URI.parse(current_url).path
|
||||||
|
end
|
||||||
|
|
||||||
def within(kind, scope=nil)
|
def within(kind, scope=nil)
|
||||||
new_scope = locate(kind, scope, "scope '#{scope || kind}' not found on page")
|
new_scope = locate(kind, scope, "scope '#{scope || kind}' not found on page")
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
require 'capybara/spec/test_app'
|
require 'capybara/spec/test_app'
|
||||||
|
|
||||||
Dir[File.dirname(__FILE__)+'/driver/*'].each { |group|
|
|
||||||
require group
|
|
||||||
}
|
|
||||||
|
|
||||||
shared_examples_for 'driver' do
|
shared_examples_for 'driver' do
|
||||||
|
|
||||||
describe '#visit' do
|
describe '#visit' do
|
||||||
|
@ -18,11 +14,6 @@ shared_examples_for 'driver' do
|
||||||
@driver.visit('/foo')
|
@driver.visit('/foo')
|
||||||
@driver.current_url.should include('/foo')
|
@driver.current_url.should include('/foo')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should show the correct location' do
|
|
||||||
@driver.visit('/foo')
|
|
||||||
@driver.current_path.should == '/foo'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#body' do
|
describe '#body' do
|
||||||
|
@ -84,26 +75,6 @@ shared_examples_for 'driver' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "node relative searching" do
|
|
||||||
before do
|
|
||||||
@driver.visit('/tables')
|
|
||||||
@node = @driver.find('//body').first
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should be able to navigate/search child node" do
|
|
||||||
@node.all('//table').size.should == 5
|
|
||||||
@node.find('//form').all('.//table').size.should == 1
|
|
||||||
@node.find('//form').find('.//table//caption').text.should == 'Agent'
|
|
||||||
if @driver.class == Capybara::Driver::Selenium
|
|
||||||
pending("Selenium gets this wrong, see http://code.google.com/p/selenium/issues/detail?id=403") do
|
|
||||||
@node.find('//form').all('//table').size.should == 5
|
|
||||||
end
|
|
||||||
else
|
|
||||||
@node.find('//form').all('//table').size.should == 5
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
shared_examples_for "driver with javascript support" do
|
shared_examples_for "driver with javascript support" do
|
||||||
|
|
|
@ -5,4 +5,11 @@ shared_examples_for "current_url" do
|
||||||
@session.current_url.should =~ %r(http://[^/]+/form)
|
@session.current_url.should =~ %r(http://[^/]+/form)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#current_path' do
|
||||||
|
it 'should show the correct location' do
|
||||||
|
@session.visit('/foo')
|
||||||
|
@session.current_path.should == '/foo'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue