mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Fixed multiple select value for rack-test driver
This commit is contained in:
parent
291bb0fe72
commit
02daf7a32f
2 changed files with 16 additions and 2 deletions
|
@ -13,8 +13,12 @@ class Capybara::Driver::RackTest < Capybara::Driver::Base
|
|||
attr_name = name.to_s
|
||||
case
|
||||
when 'select' == tag_name && 'value' == attr_name
|
||||
if node['multiple'] == 'multiple'
|
||||
node.xpath(".//option[@selected='selected']").map { |option| option.content }
|
||||
else
|
||||
option = node.xpath(".//option[@selected='selected']").first || node.xpath(".//option").first
|
||||
option.content if option
|
||||
end
|
||||
when 'input' == tag_name && 'checkbox' == type && 'checked' == attr_name
|
||||
node[attr_name] == 'checked' ? true : false
|
||||
else
|
||||
|
|
|
@ -44,6 +44,16 @@ shared_examples_for "select" do
|
|||
end
|
||||
|
||||
context "with multiple select" do
|
||||
it "should return an empty value" do
|
||||
@session.find_field('Language').value.should == []
|
||||
end
|
||||
|
||||
it "should return value of the selected options" do
|
||||
@session.select("Ruby", :from => 'Language')
|
||||
@session.select("Javascript", :from => 'Language')
|
||||
@session.find_field('Language').value.should include('Ruby', 'Javascript')
|
||||
end
|
||||
|
||||
it "should select one option" do
|
||||
@session.select("Ruby", :from => 'Language')
|
||||
@session.click_button('awesome')
|
||||
|
|
Loading…
Reference in a new issue