1
0
Fork 0
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:
Jonas Nicklas 2010-07-10 03:11:54 +02:00
parent 719b2a92cf
commit fe5e308f41
8 changed files with 28 additions and 51 deletions

View file

@ -3,10 +3,6 @@ class Capybara::Driver::Base
raise NotImplementedError
end
def current_path
URI.parse(current_url).path
end
def visit(path)
raise NotImplementedError
end
@ -15,6 +11,14 @@ class Capybara::Driver::Base
raise NotImplementedError
end
def source
raise NotImplementedError
end
def body
raise NotImplementedError
end
def execute_script(script)
raise Capybara::NotSupportedByDriverError
end
@ -23,13 +27,6 @@ class Capybara::Driver::Base
raise Capybara::NotSupportedByDriverError
end
def wait?
false
end
def wait_until *args
end
def response_headers
raise Capybara::NotSupportedByDriverError
end
@ -38,16 +35,15 @@ class Capybara::Driver::Base
raise Capybara::NotSupportedByDriverError
end
def body
raise NotImplementedError
end
def within_frame(frame_id)
raise Capybara::NotSupportedByDriverError
end
def source
raise NotImplementedError
def wait?
false
end
def wait_until(*args)
end
def cleanup!

View file

@ -17,7 +17,7 @@ class Capybara::Driver::Celerity < Capybara::Driver::Base
if tag_name == "select" and node.multiple?
node.selected_options
else
super
self[:value]
end
end

View file

@ -17,7 +17,7 @@ module Capybara
end
def value
self[:value]
raise NotImplementedError
end
def set(value)

View file

@ -30,7 +30,7 @@ class Capybara::Driver::RackTest < Capybara::Driver::Base
if tag_name == 'textarea'
node.content
else
super
self[:value]
end
end

View file

@ -20,7 +20,7 @@ class Capybara::Driver::Selenium < Capybara::Driver::Base
if tag_name == "select" and self[:multiple]
node.find_elements(:xpath, ".//option").select { |n| n.selected? }.map { |n| n.text }
else
super
self[:value]
end
end

View file

@ -33,7 +33,6 @@ module Capybara
def_delegator :driver, :cleanup!
def_delegator :driver, :current_url
def_delegator :driver, :current_path
def_delegator :driver, :response_headers
def_delegator :driver, :status_code
def_delegator :driver, :visit
@ -52,6 +51,10 @@ module Capybara
super || current_node.respond_to?(method)
end
def current_path
URI.parse(current_url).path
end
def within(kind, scope=nil)
new_scope = locate(kind, scope, "scope '#{scope || kind}' not found on page")
begin

View file

@ -1,9 +1,5 @@
require 'capybara/spec/test_app'
Dir[File.dirname(__FILE__)+'/driver/*'].each { |group|
require group
}
shared_examples_for 'driver' do
describe '#visit' do
@ -18,11 +14,6 @@ shared_examples_for 'driver' do
@driver.visit('/foo')
@driver.current_url.should include('/foo')
end
it 'should show the correct location' do
@driver.visit('/foo')
@driver.current_path.should == '/foo'
end
end
describe '#body' do
@ -84,26 +75,6 @@ shared_examples_for 'driver' do
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
shared_examples_for "driver with javascript support" do

View file

@ -5,4 +5,11 @@ shared_examples_for "current_url" do
@session.current_url.should =~ %r(http://[^/]+/form)
end
end
describe '#current_path' do
it 'should show the correct location' do
@session.visit('/foo')
@session.current_path.should == '/foo'
end
end
end