forked from easonhan007/lazyman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lazy_page_spec.rb
44 lines (36 loc) · 966 Bytes
/
lazy_page_spec.rb
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
require 'spec_helper'
describe Lazyman::Page do
before :all do
@app_name = 'test'
Lazyman::Initializer.new File.dirname(__FILE__), @app_name
end
before(:each) do
@browser = mock_watir_browser
end
def mock_watir_browser
watir_browser = double('watir')
watir_browser.stub!(:is_a?).with(anything()).and_return(false)
watir_browser.stub!(:is_a?).with(Watir::Browser).and_return(true)
watir_browser
end
it 'method missing' do
@browser.stub :close
@browser.should_receive :close
Lazyman::Page.new(@browser).close
end
it 'should turn to page' do
p = Lazyman::Page.new(@browser).turn_to TestPage
p.is_a?(TestPage).should be_true
end
it 'should data driven with hash' do
btn = double();
hash = {:one => 'click', :two => 'ok'}
p = TestPage.new(@browser)
p.stub(:one).and_return(btn)
p.stub(:two=)
btn.should_receive(:click)
p.should_receive(:one)
p.should_receive(:two=).with('ok')
p.data_driven(hash)
end
end