/usr/lib/ruby/vendor_ruby/capybara/spec/session/assert_title.rb is in ruby-capybara 2.10.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#assert_title' do
before 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)
end
it "should be true when given an empty string" do
expect(@session.assert_title('')).to eq(true)
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]{10}_js/)
end.to raise_error(Capybara::ExpectationNotMet, 'expected "with_js" to match /w[a-z]{10}_js/')
end
it "should wait for title", requires: [:js] do
@session.click_link("Change title")
expect(@session.assert_title("changed title")).to eq(true)
end
it "should raise error if the title doesn't contain the given string" do
expect do
@session.assert_title('monkey')
end.to raise_error(Capybara::ExpectationNotMet, 'expected "with_js" to include "monkey"')
end
it "should normalize given title" do
@session.assert_title(' with_js ')
end
it "should normalize given title in error message" do
expect do
@session.assert_title(2)
end.to raise_error(Capybara::ExpectationNotMet, 'expected "with_js" to include "2"')
end
end
Capybara::SpecHelper.spec '#assert_no_title' do
before do
@session.visit('/with_js')
end
it "should raise error if the title contains the given string" do
expect do
@session.assert_no_title('with_j')
end.to raise_error(Capybara::ExpectationNotMet, 'expected "with_js" not to include "with_j"')
end
it "should allow regexp matches" do
expect do
@session.assert_no_title(/w[a-z]{3}_js/)
end.to raise_error(Capybara::ExpectationNotMet, 'expected "with_js" not to match /w[a-z]{3}_js/')
@session.assert_no_title(/monkey/)
end
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)
end
it "should be true if the title doesn't contain the given string" do
expect(@session.assert_no_title('monkey')).to eq(true)
end
end
|