Fix rack driver to support buttons with no 'type' attribute
(type defaults to 'submit' according to HTML 4/5 specs)
This commit is contained in:
parent
55476db4bd
commit
500aff259e
|
@ -70,7 +70,8 @@ class Capybara::Driver::RackTest < Capybara::Driver::Base
|
|||
if tag_name == 'a'
|
||||
method = self["data-method"] || :get
|
||||
driver.process(method, self[:href].to_s)
|
||||
elsif (tag_name == 'input' or tag_name == 'button') and %w(submit image).include?(type)
|
||||
elsif (tag_name == 'input' and %w(submit image).include?(type)) or
|
||||
((tag_name == 'button') and type.nil? or type == "submit")
|
||||
Form.new(driver, form).submit(self)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,6 +12,12 @@ shared_examples_for "click_link_or_button" do
|
|||
extract_results(@session)['first_name'].should == 'John'
|
||||
end
|
||||
|
||||
it "should click on a button with no type attribute" do
|
||||
@session.visit('/form')
|
||||
@session.click_link_or_button('no_type')
|
||||
extract_results(@session)['first_name'].should == 'John'
|
||||
end
|
||||
|
||||
it "should be aliased as click for backward compatibility" do
|
||||
Capybara.should_receive(:deprecate).with("click", "click_link_or_button")
|
||||
@session.visit('/form')
|
||||
|
|
|
@ -217,6 +217,7 @@
|
|||
<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>
|
||||
<button id="no_type">No Type!</button>
|
||||
</p>
|
||||
</form>
|
||||
|
||||
|
|
Loading…
Reference in New Issue