2016-03-07 19:52:19 -05:00
|
|
|
# frozen_string_literal: true
|
2018-02-28 19:11:41 -05:00
|
|
|
|
2012-07-21 16:44:10 -04:00
|
|
|
Capybara::SpecHelper.spec '#has_field' do
|
|
|
|
before { @session.visit('/form') }
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true if the field is on the page' do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).to have_field('Dog')
|
|
|
|
expect(@session).to have_field('form_description')
|
|
|
|
expect(@session).to have_field('Region')
|
2018-02-28 19:11:41 -05:00
|
|
|
expect(@session).to have_field(:Region)
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false if the field is not on the page' do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).not_to have_field('Monkey')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with value' do
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true if a field with the given value is on the page' do
|
2016-10-04 14:10:29 -04:00
|
|
|
expect(@session).to have_field('First Name', with: 'John')
|
|
|
|
expect(@session).to have_field('First Name', with: /^Joh/)
|
|
|
|
expect(@session).to have_field('Phone', with: '+1 555 7021')
|
|
|
|
expect(@session).to have_field('Street', with: 'Sesame street 66')
|
|
|
|
expect(@session).to have_field('Description', with: 'Descriptive text goes here')
|
2010-01-18 15:28:06 -05:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false if the given field is not on the page' do
|
2016-10-04 14:10:29 -04:00
|
|
|
expect(@session).not_to have_field('First Name', with: 'Peter')
|
|
|
|
expect(@session).not_to have_field('First Name', with: /eter$/)
|
|
|
|
expect(@session).not_to have_field('Wrong Name', with: 'John')
|
|
|
|
expect(@session).not_to have_field('Description', with: 'Monkey')
|
2010-01-18 15:28:06 -05:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true after the field has been filled in with the given value' do
|
2016-10-04 14:10:29 -04:00
|
|
|
@session.fill_in('First Name', with: 'Jonas')
|
|
|
|
expect(@session).to have_field('First Name', with: 'Jonas')
|
|
|
|
expect(@session).to have_field('First Name', with: /ona/)
|
2010-01-18 15:28:06 -05:00
|
|
|
end
|
2012-02-29 21:57:05 -05:00
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false after the field has been filled in with a different value' do
|
2016-10-04 14:10:29 -04:00
|
|
|
@session.fill_in('First Name', with: 'Jonas')
|
|
|
|
expect(@session).not_to have_field('First Name', with: 'John')
|
|
|
|
expect(@session).not_to have_field('First Name', with: /John|Paul|George|Ringo/)
|
2012-02-29 21:57:05 -05:00
|
|
|
end
|
2018-11-09 19:30:43 -05:00
|
|
|
|
|
|
|
it 'should output filter errors if only one element matched the selector but failed the filters' do
|
|
|
|
@session.fill_in('First Name', with: 'Thomas')
|
|
|
|
expect do
|
|
|
|
expect(@session).to have_field('First Name', with: 'Jonas')
|
|
|
|
end.to raise_exception(RSpec::Expectations::ExpectationNotMetError, /Expected value to be "Jonas" but was "Thomas"/)
|
|
|
|
|
|
|
|
# native boolean node filter
|
|
|
|
expect do
|
|
|
|
expect(@session).to have_field('First Name', readonly: true)
|
|
|
|
end.to raise_exception(RSpec::Expectations::ExpectationNotMetError, /Expected readonly true but it wasn't/)
|
|
|
|
|
|
|
|
# inherited boolean node filter
|
|
|
|
expect do
|
|
|
|
expect(@session).to have_field('form_pets_cat', checked: true)
|
|
|
|
end.to raise_exception(RSpec::Expectations::ExpectationNotMetError, /Expected checked true but it wasn't/)
|
|
|
|
end
|
2010-01-18 15:28:06 -05:00
|
|
|
end
|
|
|
|
|
2012-07-21 16:44:10 -04:00
|
|
|
context 'with type' do
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true if a field with the given type is on the page' do
|
2016-10-04 14:10:29 -04:00
|
|
|
expect(@session).to have_field('First Name', type: 'text')
|
|
|
|
expect(@session).to have_field('Html5 Email', type: 'email')
|
|
|
|
expect(@session).to have_field('Html5 Multiple Email', type: 'email')
|
|
|
|
expect(@session).to have_field('Html5 Tel', type: 'tel')
|
|
|
|
expect(@session).to have_field('Description', type: 'textarea')
|
|
|
|
expect(@session).to have_field('Languages', type: 'select')
|
2010-01-18 15:28:06 -05:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false if the given field is not on the page' do
|
2016-10-04 14:10:29 -04:00
|
|
|
expect(@session).not_to have_field('First Name', type: 'textarea')
|
|
|
|
expect(@session).not_to have_field('Html5 Email', type: 'tel')
|
|
|
|
expect(@session).not_to have_field('Html5 Multiple Email', type: 'tel')
|
|
|
|
expect(@session).not_to have_field('Description', type: '')
|
|
|
|
expect(@session).not_to have_field('Description', type: 'email')
|
|
|
|
expect(@session).not_to have_field('Languages', type: 'textarea')
|
2010-01-18 15:28:06 -05:00
|
|
|
end
|
2018-09-24 20:05:28 -04:00
|
|
|
|
|
|
|
it 'it can find type="hidden" elements if explicity specified' do
|
|
|
|
expect(@session).to have_field('form[data]', with: 'TWTW', type: 'hidden')
|
|
|
|
end
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2016-02-03 14:02:19 -05:00
|
|
|
|
|
|
|
context 'with multiple' do
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true if a field with the multiple attribute is on the page' do
|
2016-02-03 14:02:19 -05:00
|
|
|
expect(@session).to have_field('Html5 Multiple Email', multiple: true)
|
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false if a field without the multiple attribute is not on the page' do
|
2016-02-03 14:02:19 -05:00
|
|
|
expect(@session).not_to have_field('Html5 Multiple Email', multiple: false)
|
|
|
|
end
|
|
|
|
end
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2010-01-18 15:28:06 -05:00
|
|
|
|
2012-07-21 16:44:10 -04:00
|
|
|
Capybara::SpecHelper.spec '#has_no_field' do
|
|
|
|
before { @session.visit('/form') }
|
2012-02-29 21:57:05 -05:00
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false if the field is on the page' do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).not_to have_no_field('Dog')
|
|
|
|
expect(@session).not_to have_no_field('form_description')
|
|
|
|
expect(@session).not_to have_no_field('Region')
|
2010-01-18 15:28:06 -05:00
|
|
|
end
|
2010-01-18 16:31:22 -05:00
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true if the field is not on the page' do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).to have_no_field('Monkey')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2010-02-20 16:04:06 -05:00
|
|
|
|
2012-07-21 16:44:10 -04:00
|
|
|
context 'with value' do
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false if a field with the given value is on the page' do
|
2016-10-04 14:10:29 -04:00
|
|
|
expect(@session).not_to have_no_field('First Name', with: 'John')
|
|
|
|
expect(@session).not_to have_no_field('Phone', with: '+1 555 7021')
|
|
|
|
expect(@session).not_to have_no_field('Street', with: 'Sesame street 66')
|
|
|
|
expect(@session).not_to have_no_field('Description', with: 'Descriptive text goes here')
|
2010-01-18 16:31:22 -05:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true if the given field is not on the page' do
|
2016-10-04 14:10:29 -04:00
|
|
|
expect(@session).to have_no_field('First Name', with: 'Peter')
|
|
|
|
expect(@session).to have_no_field('Wrong Name', with: 'John')
|
|
|
|
expect(@session).to have_no_field('Description', with: 'Monkey')
|
2010-01-18 16:31:22 -05:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false after the field has been filled in with the given value' do
|
2016-10-04 14:10:29 -04:00
|
|
|
@session.fill_in('First Name', with: 'Jonas')
|
|
|
|
expect(@session).not_to have_no_field('First Name', with: 'Jonas')
|
2010-01-18 16:31:22 -05:00
|
|
|
end
|
2010-12-23 13:38:44 -05:00
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true after the field has been filled in with a different value' do
|
2016-10-04 14:10:29 -04:00
|
|
|
@session.fill_in('First Name', with: 'Jonas')
|
|
|
|
expect(@session).to have_no_field('First Name', with: 'John')
|
2010-12-23 13:38:44 -05:00
|
|
|
end
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2010-12-23 13:38:44 -05:00
|
|
|
|
2012-07-21 16:44:10 -04:00
|
|
|
context 'with type' do
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false if a field with the given type is on the page' do
|
2016-10-04 14:10:29 -04:00
|
|
|
expect(@session).not_to have_no_field('First Name', type: 'text')
|
|
|
|
expect(@session).not_to have_no_field('Html5 Email', type: 'email')
|
|
|
|
expect(@session).not_to have_no_field('Html5 Tel', type: 'tel')
|
|
|
|
expect(@session).not_to have_no_field('Description', type: 'textarea')
|
|
|
|
expect(@session).not_to have_no_field('Languages', type: 'select')
|
2010-12-23 13:38:44 -05:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true if the given field is not on the page' do
|
2016-10-04 14:10:29 -04:00
|
|
|
expect(@session).to have_no_field('First Name', type: 'textarea')
|
|
|
|
expect(@session).to have_no_field('Html5 Email', type: 'tel')
|
|
|
|
expect(@session).to have_no_field('Description', type: '')
|
|
|
|
expect(@session).to have_no_field('Description', type: 'email')
|
|
|
|
expect(@session).to have_no_field('Languages', type: 'textarea')
|
2010-12-23 13:38:44 -05:00
|
|
|
end
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
|
|
|
end
|
2010-12-23 13:38:44 -05:00
|
|
|
|
2012-07-21 16:44:10 -04:00
|
|
|
Capybara::SpecHelper.spec '#has_checked_field?' do
|
|
|
|
before { @session.visit('/form') }
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true if a checked field is on the page' do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).to have_checked_field('gender_female')
|
|
|
|
expect(@session).to have_checked_field('Hamster')
|
2010-01-18 16:31:22 -05:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true for disabled checkboxes if disabled: true' do
|
2016-10-04 14:10:29 -04:00
|
|
|
expect(@session).to have_checked_field('Disabled Checkbox', disabled: true)
|
2013-08-08 21:36:33 -04:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false if an unchecked field is on the page' do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).not_to have_checked_field('form_pets_cat')
|
|
|
|
expect(@session).not_to have_checked_field('Male')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2011-03-25 06:35:59 -04:00
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false if no field is on the page' do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).not_to have_checked_field('Does Not Exist')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2011-03-25 06:35:59 -04:00
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false for disabled checkboxes by default' do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).not_to have_checked_field('Disabled Checkbox')
|
2013-08-08 21:36:33 -04:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false for disabled checkboxes if disabled: false' do
|
2016-10-04 14:10:29 -04:00
|
|
|
expect(@session).not_to have_checked_field('Disabled Checkbox', disabled: false)
|
2013-08-08 21:36:33 -04:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true for disabled checkboxes if disabled: :all' do
|
2016-10-04 14:10:29 -04:00
|
|
|
expect(@session).to have_checked_field('Disabled Checkbox', disabled: :all)
|
2015-09-18 23:22:19 -04:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true for enabled checkboxes if disabled: :all' do
|
2016-10-04 14:10:29 -04:00
|
|
|
expect(@session).to have_checked_field('gender_female', disabled: :all)
|
2015-09-18 23:22:19 -04:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true after an unchecked checkbox is checked' do
|
2012-07-21 16:44:10 -04:00
|
|
|
@session.check('form_pets_cat')
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).to have_checked_field('form_pets_cat')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2011-03-25 06:35:59 -04:00
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false after a checked checkbox is unchecked' do
|
2012-07-21 16:44:10 -04:00
|
|
|
@session.uncheck('form_pets_dog')
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).not_to have_checked_field('form_pets_dog')
|
2011-03-25 06:35:59 -04:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true after an unchecked radio button is chosen' do
|
2012-07-21 16:44:10 -04:00
|
|
|
@session.choose('gender_male')
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).to have_checked_field('gender_male')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2010-02-20 16:04:06 -05:00
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false after another radio button in the group is chosen' do
|
2012-07-21 16:44:10 -04:00
|
|
|
@session.choose('gender_male')
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).not_to have_checked_field('gender_female')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
|
|
|
end
|
2010-01-18 16:31:22 -05:00
|
|
|
|
2012-07-21 16:44:10 -04:00
|
|
|
Capybara::SpecHelper.spec '#has_no_checked_field?' do
|
|
|
|
before { @session.visit('/form') }
|
2010-01-18 16:31:22 -05:00
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false if a checked field is on the page' do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).not_to have_no_checked_field('gender_female')
|
|
|
|
expect(@session).not_to have_no_checked_field('Hamster')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2010-12-23 13:38:44 -05:00
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false for disabled checkboxes if disabled: true' do
|
2016-10-04 14:10:29 -04:00
|
|
|
expect(@session).not_to have_no_checked_field('Disabled Checkbox', disabled: true)
|
2013-08-08 21:36:33 -04:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true if an unchecked field is on the page' do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).to have_no_checked_field('form_pets_cat')
|
|
|
|
expect(@session).to have_no_checked_field('Male')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2010-12-23 13:38:44 -05:00
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true if no field is on the page' do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).to have_no_checked_field('Does Not Exist')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2013-08-08 21:36:33 -04:00
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true for disabled checkboxes by default' do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).to have_no_checked_field('Disabled Checkbox')
|
2013-08-08 21:36:33 -04:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true for disabled checkboxes if disabled: false' do
|
2016-10-04 14:10:29 -04:00
|
|
|
expect(@session).to have_no_checked_field('Disabled Checkbox', disabled: false)
|
2013-08-08 21:36:33 -04:00
|
|
|
end
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2010-12-23 13:38:44 -05:00
|
|
|
|
2012-07-21 16:44:10 -04:00
|
|
|
Capybara::SpecHelper.spec '#has_unchecked_field?' do
|
|
|
|
before { @session.visit('/form') }
|
2010-12-23 13:38:44 -05:00
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false if a checked field is on the page' do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).not_to have_unchecked_field('gender_female')
|
|
|
|
expect(@session).not_to have_unchecked_field('Hamster')
|
2010-01-18 16:31:22 -05:00
|
|
|
end
|
2011-03-25 06:35:59 -04:00
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true if an unchecked field is on the page' do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).to have_unchecked_field('form_pets_cat')
|
|
|
|
expect(@session).to have_unchecked_field('Male')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2011-03-25 06:35:59 -04:00
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true for disabled unchecked fields if disabled: true' do
|
2016-10-04 14:10:29 -04:00
|
|
|
expect(@session).to have_unchecked_field('Disabled Unchecked Checkbox', disabled: true)
|
2013-08-08 21:36:33 -04:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false if no field is on the page' do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).not_to have_unchecked_field('Does Not Exist')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2011-03-25 06:35:59 -04:00
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false for disabled unchecked fields by default' do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).not_to have_unchecked_field('Disabled Unchecked Checkbox')
|
2013-08-08 21:36:33 -04:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false for disabled unchecked fields if disabled: false' do
|
2016-10-04 14:10:29 -04:00
|
|
|
expect(@session).not_to have_unchecked_field('Disabled Unchecked Checkbox', disabled: false)
|
2013-08-08 21:36:33 -04:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false after an unchecked checkbox is checked' do
|
2012-07-21 16:44:10 -04:00
|
|
|
@session.check('form_pets_cat')
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).not_to have_unchecked_field('form_pets_cat')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2011-03-25 06:35:59 -04:00
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true after a checked checkbox is unchecked' do
|
2012-07-21 16:44:10 -04:00
|
|
|
@session.uncheck('form_pets_dog')
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).to have_unchecked_field('form_pets_dog')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false after an unchecked radio button is chosen' do
|
2012-07-21 16:44:10 -04:00
|
|
|
@session.choose('gender_male')
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).not_to have_unchecked_field('gender_male')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true after another radio button in the group is chosen' do
|
2012-07-21 16:44:10 -04:00
|
|
|
@session.choose('gender_male')
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).to have_unchecked_field('gender_female')
|
2011-03-25 06:35:59 -04:00
|
|
|
end
|
2016-09-28 16:54:20 -04:00
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should support locator-less usage' do
|
|
|
|
expect(@session.has_unchecked_field?(disabled: true, id: 'form_disabled_unchecked_checkbox')).to be true
|
|
|
|
expect(@session).to have_unchecked_field(disabled: true, id: 'form_disabled_unchecked_checkbox')
|
2016-09-28 16:54:20 -04:00
|
|
|
end
|
2010-01-18 15:28:06 -05:00
|
|
|
end
|
|
|
|
|
2012-07-21 16:44:10 -04:00
|
|
|
Capybara::SpecHelper.spec '#has_no_unchecked_field?' do
|
|
|
|
before { @session.visit('/form') }
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true if a checked field is on the page' do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).to have_no_unchecked_field('gender_female')
|
|
|
|
expect(@session).to have_no_unchecked_field('Hamster')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false if an unchecked field is on the page' do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).not_to have_no_unchecked_field('form_pets_cat')
|
|
|
|
expect(@session).not_to have_no_unchecked_field('Male')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be false for disabled unchecked fields if disabled: true' do
|
2016-10-04 14:10:29 -04:00
|
|
|
expect(@session).not_to have_no_unchecked_field('Disabled Unchecked Checkbox', disabled: true)
|
2013-08-08 21:36:33 -04:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true if no field is on the page' do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).to have_no_unchecked_field('Does Not Exist')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2013-08-08 21:36:33 -04:00
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true for disabled unchecked fields by default' do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).to have_no_unchecked_field('Disabled Unchecked Checkbox')
|
2013-08-08 21:36:33 -04:00
|
|
|
end
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should be true for disabled unchecked fields if disabled: false' do
|
2016-10-04 14:10:29 -04:00
|
|
|
expect(@session).to have_no_unchecked_field('Disabled Unchecked Checkbox', disabled: false)
|
2013-08-08 21:36:33 -04:00
|
|
|
end
|
2016-09-28 16:54:20 -04:00
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
it 'should support locator-less usage' do
|
|
|
|
expect(@session.has_no_unchecked_field?(disabled: false, id: 'form_disabled_unchecked_checkbox')).to eq true
|
|
|
|
expect(@session).to have_no_unchecked_field(disabled: false, id: 'form_disabled_unchecked_checkbox')
|
2016-09-28 16:54:20 -04:00
|
|
|
end
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|