forked from cheezy/page-object
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request cheezy#254 from leviwilson/expected_title
Fix #wait_for_expected_title?
- Loading branch information
Showing
2 changed files
with
48 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require 'spec_helper' | ||
|
||
class GenericPage | ||
include PageObject | ||
|
||
wait_for_expected_title 'expected title' | ||
end | ||
|
||
describe 'accessors' do | ||
let(:browser) { mock_watir_browser } | ||
let(:page) { GenericPage.new browser } | ||
|
||
context '#wait_for_expected_title' do | ||
before(:each) do | ||
allow(browser).to receive(:wait_until).and_yield | ||
end | ||
|
||
it 'true if already there' do | ||
allow(browser).to receive(:title).and_return 'expected title' | ||
expect(page.wait_for_expected_title?).to be_truthy | ||
end | ||
|
||
it 'does not wait if it already is there' do | ||
allow(browser).to receive(:title).and_return 'expected title' | ||
expect(browser).to_not receive(:wait_until) | ||
|
||
expect(page.wait_for_expected_title?).to be_truthy | ||
end | ||
|
||
it 'errors when it does not match' do | ||
allow(browser).to receive(:title).and_return 'wrong title' | ||
expect { page.wait_for_expected_title? }.to raise_error "Expected title 'expected title' instead of 'wrong title'" | ||
end | ||
|
||
it 'picks up when the title changes' do | ||
allow(browser).to receive(:title).and_return 'wrong title', 'expected title' | ||
expect(page.wait_for_expected_title?).to be_truthy | ||
end | ||
end | ||
end |