-
Notifications
You must be signed in to change notification settings - Fork 219
/
Copy pathspec_helper.rb
38 lines (31 loc) · 1.18 KB
/
spec_helper.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
# encoding: utf-8
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'simplecov'
require 'coveralls'
SimpleCov.start { add_filter 'spec/' }
require 'rspec'
require 'watir'
require 'webdrivers'
require 'selenium-webdriver'
require 'page-object'
def mock_watir_browser
watir_browser = double('watir')
allow(watir_browser).to receive(:is_a?).with(anything).and_return(false)
allow(watir_browser).to receive(:is_a?).with(Watir::Browser).and_return(true)
allow(watir_browser).to receive(:exists?).and_return(true)
allow(watir_browser).to receive(:to_subtype).and_return(watir_browser)
watir_browser
end
def mock_adapter(browser, page_object)
adapter = double('adapter')
allow(adapter).to receive(:is_for?).with(anything()).and_return false
allow(adapter).to receive(:is_for?).with(browser).and_return true
allow(adapter).to receive(:create_page_object).and_return page_object
allow(adapter).to receive(:root_element_for).and_return browser
allow(adapter).to receive(:browser_for).and_return browser
adapter
end
def mock_adapters(adapters)
allow(PageObject::Platforms).to receive(:get).and_return adapters
end