2016-03-07 19:52:19 -05:00
|
|
|
# frozen_string_literal: true
|
2012-07-21 16:44:10 -04:00
|
|
|
Capybara::SpecHelper.spec '#has_button?' do
|
|
|
|
before do
|
|
|
|
@session.visit('/form')
|
|
|
|
end
|
2010-01-18 15:40:59 -05:00
|
|
|
|
2012-07-21 16:44:10 -04:00
|
|
|
it "should be true if the given button is on the page" do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).to have_button('med')
|
|
|
|
expect(@session).to have_button('crap321')
|
|
|
|
expect(@session).to have_button(:'crap321')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2010-01-18 15:40:59 -05:00
|
|
|
|
2016-10-04 14:10:29 -04:00
|
|
|
it "should be true for disabled buttons if disabled: true" do
|
|
|
|
expect(@session).to have_button('Disabled button', disabled: true)
|
2013-08-08 19:05:38 -04:00
|
|
|
end
|
|
|
|
|
2012-07-21 16:44:10 -04:00
|
|
|
it "should be false if the given button is not on the page" do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).not_to have_button('monkey')
|
2010-01-18 15:40:59 -05:00
|
|
|
end
|
2013-08-08 19:05:38 -04:00
|
|
|
|
|
|
|
it "should be false for disabled buttons by default" do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).not_to have_button('Disabled button')
|
2013-08-08 19:05:38 -04:00
|
|
|
end
|
|
|
|
|
2016-10-04 14:10:29 -04:00
|
|
|
it "should be false for disabled buttons if disabled: false" do
|
|
|
|
expect(@session).not_to have_button('Disabled button', disabled: false)
|
2013-08-08 19:05:38 -04:00
|
|
|
end
|
2015-09-18 23:22:19 -04:00
|
|
|
|
2016-10-04 14:10:29 -04:00
|
|
|
it "should be true for disabled buttons if disabled: :all" do
|
|
|
|
expect(@session).to have_button('Disabled button', disabled: :all)
|
2015-09-18 23:22:19 -04:00
|
|
|
end
|
|
|
|
|
2016-10-04 14:10:29 -04:00
|
|
|
it "should be true for enabled buttons if disabled: :all" do
|
|
|
|
expect(@session).to have_button('med', disabled: :all)
|
2015-09-18 23:22:19 -04:00
|
|
|
end
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2010-01-18 15:40:59 -05:00
|
|
|
|
2012-07-21 16:44:10 -04:00
|
|
|
Capybara::SpecHelper.spec '#has_no_button?' do
|
|
|
|
before do
|
|
|
|
@session.visit('/form')
|
|
|
|
end
|
2010-01-18 15:40:59 -05:00
|
|
|
|
2012-07-21 16:44:10 -04:00
|
|
|
it "should be true if the given button is on the page" do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).not_to have_no_button('med')
|
|
|
|
expect(@session).not_to have_no_button('crap321')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2010-01-18 15:40:59 -05:00
|
|
|
|
2016-10-04 14:10:29 -04:00
|
|
|
it "should be true for disabled buttons if disabled: true" do
|
|
|
|
expect(@session).not_to have_no_button('Disabled button', disabled: true)
|
2013-08-08 19:05:38 -04:00
|
|
|
end
|
|
|
|
|
2012-07-21 16:44:10 -04:00
|
|
|
it "should be false if the given button is not on the page" do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).to have_no_button('monkey')
|
2010-01-18 15:40:59 -05:00
|
|
|
end
|
2013-08-08 19:05:38 -04:00
|
|
|
|
|
|
|
it "should be false for disabled buttons by default" do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(@session).to have_no_button('Disabled button')
|
2013-08-08 19:05:38 -04:00
|
|
|
end
|
|
|
|
|
2016-10-04 14:10:29 -04:00
|
|
|
it "should be false for disabled buttons if disabled: false" do
|
|
|
|
expect(@session).to have_no_button('Disabled button', disabled: false)
|
2013-08-08 19:05:38 -04:00
|
|
|
end
|
2010-01-18 15:40:59 -05:00
|
|
|
end
|