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

fill_options: {clear: :backspace} should only be tested for selenium

This commit is contained in:
Thomas Walpole 2015-04-12 20:32:12 -07:00
parent 61a5130d83
commit ed2071b480
2 changed files with 29 additions and 22 deletions

View file

@ -180,24 +180,4 @@ Capybara::SpecHelper.spec "#fill_in" do
end.to raise_error(Capybara::ElementNotFound)
end
end
context "with { :clear => :backspace } fill_option", :requires => [:js] do
it 'should only trigger onchange once' do
@session.visit('/with_js')
@session.fill_in('with_change_event', :with => 'some value',
:fill_options => { :clear => :backspace })
# click outside the field to trigger the change event
@session.find(:css, 'body').click
expect(@session.find(:css, '.change_event_triggered', :match => :one)).to have_text 'some value'
end
it 'should trigger change when clearing field' do
@session.visit('/with_js')
@session.fill_in('with_change_event', :with => '',
:fill_options => { :clear => :backspace })
# click outside the field to trigger the change event
@session.find(:css, 'body').click
expect(@session).to have_selector(:css, '.change_event_triggered', :match => :one)
end
end
end

View file

@ -63,7 +63,7 @@ RSpec.describe Capybara::Session do
expect($?.exitstatus).to be 0
end
end
describe "#accept_alert" do
it "supports a blockless mode" do
@session.visit('/with_js')
@ -73,6 +73,33 @@ RSpec.describe Capybara::Session do
expect{@session.driver.browser.switch_to.alert}.to raise_error("No alert is present")
end
end
context "#fill_in with { :clear => :backspace } fill_option", :requires => [:js] do
it 'should fill in a field, replacing an existing value' do
@session.visit('/form')
@session.fill_in('form_first_name', :with => 'Harry',
fill_options: { clear: :backspace} )
expect(@session.find(:fillable_field, 'form_first_name').value).to eq('Harry')
end
it 'should only trigger onchange once' do
@session.visit('/with_js')
@session.fill_in('with_change_event', :with => 'some value',
:fill_options => { :clear => :backspace })
# click outside the field to trigger the change event
@session.find(:css, 'body').click
expect(@session.find(:css, '.change_event_triggered', :match => :one)).to have_text 'some value'
end
it 'should trigger change when clearing field' do
@session.visit('/with_js')
@session.fill_in('with_change_event', :with => '',
:fill_options => { :clear => :backspace })
# click outside the field to trigger the change event
@session.find(:css, 'body').click
expect(@session).to have_selector(:css, '.change_event_triggered', :match => :one)
end
end
end
end
@ -80,7 +107,7 @@ RSpec.describe Capybara::Selenium::Driver do
before do
@driver = Capybara::Selenium::Driver.new(TestApp, browser: :firefox)
end
describe '#quit' do
it "should reset browser when quit" do
expect(@driver.browser).to be