1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Fix the rack driver to favour option's value attributes over their content.

This commit is contained in:
Rob Holland 2010-10-04 21:17:07 +01:00
parent c67dceb537
commit 55476db4bd
5 changed files with 111 additions and 34 deletions

15
Gemfile
View file

@ -1,3 +1,14 @@
source :gemcutter
source 'http://gemcutter.org'
gemspec
gem 'rails', '3.0.0'
group :development, :test do
gem 'nokogiri'
gem 'xpath'
gem 'sinatra'
gem 'culerity'
gem 'selenium-webdriver'
gem 'launchy'
gem 'rspec-rails', '>= 2.0.0.beta.20'
gem 'cucumber-rails'
end

View file

@ -1,37 +1,92 @@
PATH
remote: .
specs:
capybara (0.3.9)
celerity (>= 0.7.9)
culerity (>= 0.2.4)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (>= 0.0.27)
xpath (>= 0.1.0)
GEM
remote: http://rubygems.org/
remote: http://gemcutter.org/
specs:
celerity (0.8.2)
abstract (1.0.0)
actionmailer (3.0.0)
actionpack (= 3.0.0)
mail (~> 2.2.5)
actionpack (3.0.0)
activemodel (= 3.0.0)
activesupport (= 3.0.0)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4.1)
rack (~> 1.2.1)
rack-mount (~> 0.6.12)
rack-test (~> 0.5.4)
tzinfo (~> 0.3.23)
activemodel (3.0.0)
activesupport (= 3.0.0)
builder (~> 2.1.2)
i18n (~> 0.4.1)
activerecord (3.0.0)
activemodel (= 3.0.0)
activesupport (= 3.0.0)
arel (~> 1.0.0)
tzinfo (~> 0.3.23)
activeresource (3.0.0)
activemodel (= 3.0.0)
activesupport (= 3.0.0)
activesupport (3.0.0)
arel (1.0.1)
activesupport (~> 3.0.0)
builder (2.1.2)
configuration (1.1.0)
cucumber (0.9.2)
builder (~> 2.1.2)
diff-lcs (~> 1.1.2)
gherkin (~> 2.2.5)
json (~> 1.4.6)
term-ansicolor (~> 1.0.5)
cucumber-rails (0.3.2)
cucumber (>= 0.8.0)
culerity (0.2.12)
diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
ffi (0.6.3)
rake (>= 0.8.7)
ffi (0.6.3-java)
gherkin (2.2.8)
json (~> 1.4.6)
term-ansicolor (~> 1.0.5)
gherkin (2.2.8-java)
json (~> 1.4.6)
term-ansicolor (~> 1.0.5)
i18n (0.4.1)
json (1.4.6)
json (1.4.6-java)
json_pure (1.4.6)
launchy (0.3.7)
configuration (>= 0.0.5)
rake (>= 0.8.1)
mail (2.2.6.1)
activesupport (>= 2.3.6)
mime-types
treetop (>= 1.4.5)
mime-types (1.16)
nokogiri (1.4.3.1)
nokogiri (1.4.3.1-java)
weakling (>= 0.0.3)
polyglot (0.3.1)
rack (1.2.1)
rack-test (0.5.4)
rack-mount (0.6.13)
rack (>= 1.0.0)
rack-test (0.5.6)
rack (>= 1.0)
rails (3.0.0)
actionmailer (= 3.0.0)
actionpack (= 3.0.0)
activerecord (= 3.0.0)
activeresource (= 3.0.0)
activesupport (= 3.0.0)
bundler (~> 1.0.0)
railties (= 3.0.0)
railties (3.0.0)
actionpack (= 3.0.0)
activesupport (= 3.0.0)
rake (>= 0.8.4)
thor (~> 0.14.0)
rake (0.8.7)
rspec (2.0.0.beta.22)
rspec-core (= 2.0.0.beta.22)
@ -43,6 +98,8 @@ GEM
rspec-mocks (2.0.0.beta.22)
rspec-core (= 2.0.0.beta.22)
rspec-expectations (= 2.0.0.beta.22)
rspec-rails (2.0.0.beta.22)
rspec (= 2.0.0.beta.22)
rubyzip (0.9.4)
selenium-webdriver (0.0.28)
ffi (>= 0.6.1)
@ -50,25 +107,25 @@ GEM
rubyzip
sinatra (1.0)
rack (>= 1.0)
term-ansicolor (1.0.5)
thor (0.14.3)
treetop (1.4.8)
polyglot (>= 0.3.1)
tzinfo (0.3.23)
weakling (0.0.4-java)
xpath (0.1.0)
yard (0.6.1)
PLATFORMS
java
ruby
DEPENDENCIES
capybara!
celerity (>= 0.7.9)
culerity (>= 0.2.4)
launchy (>= 0.3.5)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
rspec (>= 2.0.0.beta.22)
selenium-webdriver (>= 0.0.27)
sinatra (>= 0.9.4)
xpath (>= 0.1.0)
yard (>= 0.5.8)
cucumber-rails
culerity
launchy
nokogiri
rails (= 3.0.0)
rspec-rails (>= 2.0.0.beta.20)
selenium-webdriver
sinatra
xpath

View file

@ -14,10 +14,10 @@ class Capybara::Driver::RackTest < Capybara::Driver::Base
case
when 'select' == tag_name && 'value' == attr_name
if native['multiple'] == 'multiple'
native.xpath(".//option[@selected='selected']").map { |option| option.content }
native.xpath(".//option[@selected='selected']").map { |option| option[:value] || option.content }
else
option = native.xpath(".//option[@selected='selected']").first || native.xpath(".//option").first
option.content if option
option[:value] || option.content if option
end
when 'input' == tag_name && 'checkbox' == type && 'checked' == attr_name
native[attr_name] == 'checked' ? true : false

View file

@ -13,6 +13,10 @@ shared_examples_for "select" do
@session.find_field('Title').value.should == 'Miss'
end
it "should return the value attribute rather than content if present" do
@session.find_field('Locale').value.should == 'en'
end
it "should select an option from a select box by id" do
@session.select("Finish", :from => 'form_locale')
@session.click_button('awesome')
@ -92,6 +96,10 @@ shared_examples_for "select" do
@session.click_button('awesome')
extract_results(@session)['languages'].should include('Ruby', 'Javascript')
end
it "should return value attribute rather than content if present" do
@session.find_field('Underwear').value.should include('thermal')
end
end
end
end

View file

@ -155,6 +155,7 @@
<option selected="selected">Briefs</option>
<option selected="selected">Commando</option>
<option selected="selected">Frenchman's Pantalons</option>
<option selected="selected" value="thermal">Long Johns</option>
</select>
</p>