Skip to content

Commit

Permalink
Merge branch 'master' of github.com:jnicklas/capybara
Browse files Browse the repository at this point in the history
Conflicts:
	Gemfile.lock
  • Loading branch information
jnicklas committed Oct 6, 2010
2 parents 657b9c5 + 55476db commit 81a686d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile
@@ -1,3 +1,3 @@
source :gemcutter
source :rubygems

gemspec
2 changes: 1 addition & 1 deletion Gemfile.lock
Expand Up @@ -30,7 +30,7 @@ GEM
nokogiri (1.4.3.1-java)
weakling (>= 0.0.3)
rack (1.2.1)
rack-test (0.5.4)
rack-test (0.5.6)
rack (>= 1.0)
rake (0.8.7)
rspec (2.0.0.beta.22)
Expand Down
4 changes: 2 additions & 2 deletions lib/capybara/driver/rack_test_driver.rb
Expand Up @@ -14,10 +14,10 @@ def [](name)
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
Expand Down
8 changes: 8 additions & 0 deletions lib/capybara/spec/session/select_spec.rb
Expand Up @@ -13,6 +13,10 @@
@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')
Expand Down Expand Up @@ -92,6 +96,10 @@
@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
1 change: 1 addition & 0 deletions lib/capybara/spec/views/form.erb
Expand Up @@ -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>

Expand Down

0 comments on commit 81a686d

Please sign in to comment.