mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Merge remote branch 'darrinholst/master'
This commit is contained in:
commit
5325d6a9c4
3 changed files with 22 additions and 15 deletions
|
@ -106,7 +106,7 @@ class Capybara::Driver::RackTest < Capybara::Driver::Base
|
|||
class Form < Node
|
||||
def params(button)
|
||||
params = {}
|
||||
|
||||
|
||||
text_fields = %w[text hidden password url color tel email search].map{|f| "@type='#{f}'"}.join(' or ')
|
||||
|
||||
node.xpath(".//input[#{text_fields}]").map do |input|
|
||||
|
@ -141,7 +141,7 @@ class Capybara::Driver::RackTest < Capybara::Driver::Base
|
|||
end
|
||||
end
|
||||
end
|
||||
merge_param!(params, button[:name], button[:value]) if button[:name]
|
||||
merge_param!(params, button[:name], button[:value] || "") if button[:name]
|
||||
params
|
||||
end
|
||||
|
||||
|
@ -154,7 +154,7 @@ class Capybara::Driver::RackTest < Capybara::Driver::Base
|
|||
end
|
||||
|
||||
private
|
||||
|
||||
|
||||
def method
|
||||
self[:method] =~ /post/i ? :post : :get
|
||||
end
|
||||
|
@ -200,7 +200,7 @@ class Capybara::Driver::RackTest < Capybara::Driver::Base
|
|||
end
|
||||
|
||||
def submit(method, path, attributes)
|
||||
path = current_path if not path or path.empty?
|
||||
path = current_path if not path or path.empty?
|
||||
send(method, path, attributes, env)
|
||||
follow_redirects!
|
||||
cache_body
|
||||
|
|
|
@ -13,33 +13,33 @@ shared_examples_for "click_button" do
|
|||
end
|
||||
|
||||
context "with value given on a submit button" do
|
||||
context "on a form with HTML5 fields" do
|
||||
context "on a form with HTML5 fields" do
|
||||
before do
|
||||
@session.click_button('html5_submit')
|
||||
@results = extract_results(@session)
|
||||
end
|
||||
|
||||
|
||||
it "should serialise and submit search fields" do
|
||||
@results['html5_search'].should == 'what are you looking for'
|
||||
end
|
||||
|
||||
|
||||
it "should serialise and submit email fields" do
|
||||
@results['html5_email'].should == 'person@email.com'
|
||||
end
|
||||
|
||||
|
||||
it "should serialise and submit url fields" do
|
||||
@results['html5_url'].should == 'http://www.example.com'
|
||||
end
|
||||
|
||||
|
||||
it "should serialise and submit tel fields" do
|
||||
@results['html5_tel'].should == '911'
|
||||
end
|
||||
|
||||
|
||||
it "should serialise and submit color fields" do
|
||||
@results['html5_color'].should == '#FFF'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "on an HTML4 form" do
|
||||
before do
|
||||
@session.click_button('awesome')
|
||||
|
@ -187,7 +187,7 @@ shared_examples_for "click_button" do
|
|||
@session.click_button('ck_me')
|
||||
extract_results(@session)['first_name'].should == 'John'
|
||||
end
|
||||
|
||||
|
||||
it "should prefer exact matches over partial matches" do
|
||||
@session.click_button('Just a button')
|
||||
extract_results(@session)['button'].should == 'Just a button'
|
||||
|
@ -202,6 +202,12 @@ shared_examples_for "click_button" do
|
|||
end
|
||||
end
|
||||
|
||||
it "should serialize and send valueless buttons that were clicked" do
|
||||
@session.click_button('No Value!')
|
||||
@results = extract_results(@session)
|
||||
@results['no_value'].should_not be_nil
|
||||
end
|
||||
|
||||
it "should serialize and send GET forms" do
|
||||
@session.visit('/form')
|
||||
@session.click_button('med')
|
||||
|
@ -214,13 +220,13 @@ shared_examples_for "click_button" do
|
|||
@session.click_button('Go FAR')
|
||||
@session.body.should include('You landed')
|
||||
end
|
||||
|
||||
|
||||
it "should post pack to the same URL when no action given" do
|
||||
@session.visit('/postback')
|
||||
@session.click_button('With no action')
|
||||
@session.body.should include('Postback')
|
||||
end
|
||||
|
||||
|
||||
it "should post pack to the same URL when blank action given" do
|
||||
@session.visit('/postback')
|
||||
@session.click_button('With blank action')
|
||||
|
|
|
@ -153,6 +153,7 @@
|
|||
<input type="submit" name="form[crappy]" id="crap321" value="crappy"/>
|
||||
<input type="image" name="form[okay]" id="okay556" value="okay" alt="oh hai thar"/>
|
||||
<button type="submit" id="click_me_123" value="click_me">Click me!</button>
|
||||
<button type="submit" name="form[no_value]">No Value!</button>
|
||||
</p>
|
||||
</form>
|
||||
|
||||
|
|
Loading…
Reference in a new issue