Update title tests

This commit is contained in:
Thomas Walpole 2017-05-31 10:29:44 -07:00
parent e9cb35a1aa
commit 8e407cc243
1 changed files with 22 additions and 9 deletions

View File

@ -4,16 +4,23 @@ Capybara::SpecHelper.spec '#assert_title' do
@session.visit('/with_js')
end
it "should be true if the page's title contains the given string" do
expect(@session.assert_title('js')).to eq(true)
it "should not raise if the page's title contains the given string" do
expect do
@session.assert_title('js')
end.not_to raise_error
end
it "should be true when given an empty string" do
expect(@session.assert_title('')).to eq(true)
it "should not raise when given an empty string" do
expect do
@session.assert_title('')
end.not_to raise_error
end
it "should allow regexp matches" do
expect(@session.assert_title(/w[a-z]{3}_js/)).to eq(true)
expect do
@session.assert_title(/w[a-z]{3}_js/)
end.not_to raise_error
expect do
@session.assert_title(/w[a-z]{10}_js/)
end.to raise_error(Capybara::ExpectationNotMet, 'expected "with_js" to match /w[a-z]{10}_js/')
@ -21,7 +28,9 @@ Capybara::SpecHelper.spec '#assert_title' do
it "should wait for title", requires: [:js] do
@session.click_link("Change title")
expect(@session.assert_title("changed title")).to eq(true)
expect do
@session.assert_title("changed title", wait: 3)
end.not_to raise_error
end
it "should raise error if the title doesn't contain the given string" do
@ -61,10 +70,14 @@ Capybara::SpecHelper.spec '#assert_no_title' do
it "should wait for title to disappear", requires: [:js] do
@session.click_link("Change title")
expect(@session.assert_no_title('with_js')).to eq(true)
expect do
@session.assert_no_title('with_js', wait: 3)
end.not_to raise_error
end
it "should be true if the title doesn't contain the given string" do
expect(@session.assert_no_title('monkey')).to eq(true)
it "should not raise if the title doesn't contain the given string" do
expect do
@session.assert_no_title('monkey')
end.not_to raise_error
end
end