symbiont 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +22 -22
- data/.travis.yml +25 -14
- data/Gemfile +4 -2
- data/{LICENSE → LICENSE.txt} +22 -22
- data/README.md +57 -65
- data/Rakefile +28 -34
- data/lib/symbiont/accessor.rb +7 -0
- data/lib/symbiont/assertions.rb +33 -0
- data/lib/symbiont/elements.rb +69 -0
- data/lib/symbiont/errors.rb +7 -0
- data/lib/symbiont/factory.rb +75 -46
- data/lib/symbiont/helpers.rb +49 -0
- data/lib/symbiont/logging.rb +5 -0
- data/lib/symbiont/pages.rb +32 -0
- data/lib/symbiont/platform.rb +12 -0
- data/lib/symbiont/version.rb +3 -3
- data/lib/symbiont.rb +34 -92
- data/spec/fixtures/element_definitions.rb +32 -0
- data/spec/fixtures/mock_drivers.rb +8 -0
- data/spec/fixtures/page_definitions.rb +36 -0
- data/spec/spec_helper.rb +31 -80
- data/spec/symbiont/assertion_spec.rb +88 -0
- data/spec/symbiont/driver_spec.rb +41 -0
- data/spec/symbiont/element_spec.rb +8 -0
- data/spec/symbiont/factory_spec.rb +70 -130
- data/spec/symbiont/page_spec.rb +50 -0
- data/symbiont.gemspec +52 -27
- data/test/symbiont-script.rb +97 -0
- metadata +89 -230
- data/Gemfile.lock +0 -44
- data/HISTORY.md +0 -99
- data/app/app.rb +0 -48
- data/app/public/css/cupertino/images/ui-bg_diagonals-thick_90_eeeeee_40x40.png +0 -0
- data/app/public/css/cupertino/images/ui-bg_flat_15_cd0a0a_40x100.png +0 -0
- data/app/public/css/cupertino/images/ui-bg_glass_100_e4f1fb_1x400.png +0 -0
- data/app/public/css/cupertino/images/ui-bg_glass_50_3baae3_1x400.png +0 -0
- data/app/public/css/cupertino/images/ui-bg_glass_80_d7ebf9_1x400.png +0 -0
- data/app/public/css/cupertino/images/ui-bg_highlight-hard_100_f2f5f7_1x100.png +0 -0
- data/app/public/css/cupertino/images/ui-bg_highlight-hard_70_000000_1x100.png +0 -0
- data/app/public/css/cupertino/images/ui-bg_highlight-soft_100_deedf7_1x100.png +0 -0
- data/app/public/css/cupertino/images/ui-bg_highlight-soft_25_ffef8f_1x100.png +0 -0
- data/app/public/css/cupertino/images/ui-icons_2694e8_256x240.png +0 -0
- data/app/public/css/cupertino/images/ui-icons_2e83ff_256x240.png +0 -0
- data/app/public/css/cupertino/images/ui-icons_3d80b3_256x240.png +0 -0
- data/app/public/css/cupertino/images/ui-icons_72a7cf_256x240.png +0 -0
- data/app/public/css/cupertino/images/ui-icons_ffffff_256x240.png +0 -0
- data/app/public/css/cupertino/jquery-ui-1.8.16.custom.css +0 -290
- data/app/public/css/demo_table_jui.css +0 -471
- data/app/public/css/font/ColabLig-webfont.eot +0 -0
- data/app/public/css/font/ColabLig-webfont.svg +0 -149
- data/app/public/css/font/ColabLig-webfont.ttf +0 -0
- data/app/public/css/font/ColabLig-webfont.woff +0 -0
- data/app/public/css/font/ColabMed-webfont.eot +0 -0
- data/app/public/css/font/ColabMed-webfont.svg +0 -149
- data/app/public/css/font/ColabMed-webfont.ttf +0 -0
- data/app/public/css/font/ColabMed-webfont.woff +0 -0
- data/app/public/css/font/ColabReg-webfont.eot +0 -0
- data/app/public/css/font/ColabReg-webfont.svg +0 -149
- data/app/public/css/font/ColabReg-webfont.ttf +0 -0
- data/app/public/css/font/ColabReg-webfont.woff +0 -0
- data/app/public/css/font/ColabThi-webfont.eot +0 -0
- data/app/public/css/font/ColabThi-webfont.svg +0 -149
- data/app/public/css/font/ColabThi-webfont.ttf +0 -0
- data/app/public/css/font/ColabThi-webfont.woff +0 -0
- data/app/public/css/normalize.css +0 -376
- data/app/public/css/site.css +0 -446
- data/app/public/fancybox/blank.gif +0 -0
- data/app/public/fancybox/fancy_close.png +0 -0
- data/app/public/fancybox/fancy_loading.png +0 -0
- data/app/public/fancybox/fancy_nav_left.png +0 -0
- data/app/public/fancybox/fancy_nav_right.png +0 -0
- data/app/public/fancybox/fancy_shadow_e.png +0 -0
- data/app/public/fancybox/fancy_shadow_n.png +0 -0
- data/app/public/fancybox/fancy_shadow_ne.png +0 -0
- data/app/public/fancybox/fancy_shadow_nw.png +0 -0
- data/app/public/fancybox/fancy_shadow_s.png +0 -0
- data/app/public/fancybox/fancy_shadow_se.png +0 -0
- data/app/public/fancybox/fancy_shadow_sw.png +0 -0
- data/app/public/fancybox/fancy_shadow_w.png +0 -0
- data/app/public/fancybox/fancy_title_left.png +0 -0
- data/app/public/fancybox/fancy_title_main.png +0 -0
- data/app/public/fancybox/fancy_title_over.png +0 -0
- data/app/public/fancybox/fancy_title_right.png +0 -0
- data/app/public/fancybox/fancybox-x.png +0 -0
- data/app/public/fancybox/fancybox-y.png +0 -0
- data/app/public/fancybox/fancybox.png +0 -0
- data/app/public/fancybox/jquery.fancybox-1.3.4.css +0 -359
- data/app/public/fancybox/jquery.fancybox-1.3.4.js +0 -1156
- data/app/public/fancybox/jquery.fancybox-1.3.4.min.js +0 -1
- data/app/public/img/Sorting icons.psd +0 -0
- data/app/public/img/back_disabled.png +0 -0
- data/app/public/img/back_enabled.png +0 -0
- data/app/public/img/back_enabled_hover.png +0 -0
- data/app/public/img/close.png +0 -0
- data/app/public/img/favicon.ico +0 -0
- data/app/public/img/forward_disabled.png +0 -0
- data/app/public/img/forward_enabled.png +0 -0
- data/app/public/img/forward_enabled_hover.png +0 -0
- data/app/public/img/lucid-bg.png +0 -0
- data/app/public/img/lucid-ft.png +0 -0
- data/app/public/img/open.png +0 -0
- data/app/public/img/sort_asc.png +0 -0
- data/app/public/img/sort_asc_disabled.png +0 -0
- data/app/public/img/sort_both.png +0 -0
- data/app/public/img/sort_desc.png +0 -0
- data/app/public/img/sort_desc_disabled.png +0 -0
- data/app/public/js/comics.js +0 -11
- data/app/public/js/signup.js +0 -141
- data/app/public/js/site.js +0 -42
- data/app/public/js/stardate.js +0 -35
- data/app/public/js/vendor/html5shiv.js +0 -5
- data/app/public/js/vendor/jquery-1.8.3.min.js +0 -2
- data/app/public/js/vendor/jquery.dataTables.min.js +0 -151
- data/app/public/js/vendor/jquery.validate.min.js +0 -4
- data/app/views/comics.erb +0 -344
- data/app/views/index.erb +0 -7
- data/app/views/layout.erb +0 -72
- data/app/views/layout_small.erb +0 -21
- data/app/views/stardate.erb +0 -5
- data/app/views/stardate_calc.erb +0 -30
- data/app/views/webobject.erb +0 -147
- data/lib/symbiont/data_setter.rb +0 -53
- data/lib/symbiont/enclosers.rb +0 -118
- data/lib/symbiont/evaluators.rb +0 -92
- data/lib/symbiont/generators.rb +0 -331
- data/lib/symbiont/locators.rb +0 -43
- data/lib/symbiont/logger.rb +0 -5
- data/lib/symbiont/platform_watir/platform_object.rb +0 -466
- data/lib/symbiont/platform_watir.rb +0 -9
- data/lib/symbiont/platforms.rb +0 -23
- data/lib/symbiont/web_objects/_common.rb +0 -174
- data/lib/symbiont/web_objects/button.rb +0 -22
- data/lib/symbiont/web_objects/checkbox.rb +0 -31
- data/lib/symbiont/web_objects/div.rb +0 -15
- data/lib/symbiont/web_objects/heading.rb +0 -12
- data/lib/symbiont/web_objects/hidden_field.rb +0 -19
- data/lib/symbiont/web_objects/label.rb +0 -15
- data/lib/symbiont/web_objects/link.rb +0 -23
- data/lib/symbiont/web_objects/list_item.rb +0 -13
- data/lib/symbiont/web_objects/option.rb +0 -10
- data/lib/symbiont/web_objects/ordered_list.rb +0 -49
- data/lib/symbiont/web_objects/paragraph.rb +0 -11
- data/lib/symbiont/web_objects/radio.rb +0 -31
- data/lib/symbiont/web_objects/select_list.rb +0 -82
- data/lib/symbiont/web_objects/span.rb +0 -15
- data/lib/symbiont/web_objects/table.rb +0 -71
- data/lib/symbiont/web_objects/table_cell.rb +0 -24
- data/lib/symbiont/web_objects/table_row.rb +0 -59
- data/lib/symbiont/web_objects/text_area.rb +0 -26
- data/lib/symbiont/web_objects/text_field.rb +0 -31
- data/lib/symbiont/web_objects/unordered_list.rb +0 -49
- data/lib/symbiont/web_objects.rb +0 -22
- data/lucid.yml +0 -6
- data/spec/symbiont/data_setter_spec.rb +0 -65
- data/spec/symbiont/enclosers_spec.rb +0 -76
- data/spec/symbiont/evaluators_spec.rb +0 -95
- data/spec/symbiont/generators/button_generators_spec.rb +0 -72
- data/spec/symbiont/generators/checkbox_generators_spec.rb +0 -79
- data/spec/symbiont/generators/div_generators_spec.rb +0 -56
- data/spec/symbiont/generators/hidden_field_generators_spec.rb +0 -65
- data/spec/symbiont/generators/link_generators_spec.rb +0 -62
- data/spec/symbiont/generators/paragraph_generators_spec.rb +0 -57
- data/spec/symbiont/generators/radio_generators_spec.rb +0 -76
- data/spec/symbiont/generators/select_list_generators_spec.rb +0 -93
- data/spec/symbiont/generators/span_generators_spec.rb +0 -56
- data/spec/symbiont/generators/table_cell_generators_spec.rb +0 -56
- data/spec/symbiont/generators/table_generators_spec.rb +0 -56
- data/spec/symbiont/generators/text_area_generators_spec.rb +0 -72
- data/spec/symbiont/generators/text_field_generators_spec.rb +0 -72
- data/spec/symbiont/generators_spec.rb +0 -59
- data/spec/symbiont/locators_spec.rb +0 -68
- data/spec/symbiont/platform_object_spec.rb +0 -18
- data/spec/symbiont/symbiont_spec.rb +0 -29
- data/spec/symbiont/web_object_spec.rb +0 -194
- data/spec/symbiont/web_objects/button_spec.rb +0 -38
- data/spec/symbiont/web_objects/checkbox_spec.rb +0 -27
- data/spec/symbiont/web_objects/div_spec.rb +0 -18
- data/spec/symbiont/web_objects/heading_spec.rb +0 -22
- data/spec/symbiont/web_objects/hidden_field_spec.rb +0 -18
- data/spec/symbiont/web_objects/label_spec.rb +0 -18
- data/spec/symbiont/web_objects/link_spec.rb +0 -33
- data/spec/symbiont/web_objects/list_item_spec.rb +0 -18
- data/spec/symbiont/web_objects/option_spec.rb +0 -9
- data/spec/symbiont/web_objects/ordered_list_spec.rb +0 -53
- data/spec/symbiont/web_objects/paragraph_spec.rb +0 -18
- data/spec/symbiont/web_objects/radio_spec.rb +0 -27
- data/spec/symbiont/web_objects/select_list_spec.rb +0 -69
- data/spec/symbiont/web_objects/span_spec.rb +0 -18
- data/spec/symbiont/web_objects/table_cell_spec.rb +0 -19
- data/spec/symbiont/web_objects/table_row_spec.rb +0 -58
- data/spec/symbiont/web_objects/table_spec.rb +0 -61
- data/spec/symbiont/web_objects/text_area_spec.rb +0 -18
- data/spec/symbiont/web_objects/text_field_spec.rb +0 -39
- data/spec/symbiont/web_objects/unordered_list_spec.rb +0 -51
- data/specs/common/support/browser.rb +0 -25
- data/specs/common/support/env.rb +0 -6
- data/specs/common/support/events.rb +0 -15
- data/specs/enclosers.feature +0 -9
- data/specs/evaluators.feature +0 -26
- data/specs/pages/characters.rb +0 -22
- data/specs/pages/home.rb +0 -9
- data/specs/pages/stardate.rb +0 -23
- data/specs/pages/web_objects.rb +0 -77
- data/specs/select_list.feature +0 -53
- data/specs/steps/enclosers_steps.rb +0 -17
- data/specs/steps/evaluators_steps.rb +0 -44
- data/specs/steps/navigation_steps.rb +0 -14
- data/specs/steps/select_list_steps.rb +0 -94
- data/specs/steps/table_cell_steps.rb +0 -31
- data/specs/steps/table_steps.rb +0 -87
- data/specs/table.feature +0 -49
- data/specs/table_cell.feature +0 -27
@@ -0,0 +1,32 @@
|
|
1
|
+
module Symbiont
|
2
|
+
module Page
|
3
|
+
include Helpers
|
4
|
+
|
5
|
+
def view
|
6
|
+
no_url_is_provided if url.nil?
|
7
|
+
driver.goto(url)
|
8
|
+
end
|
9
|
+
|
10
|
+
def has_correct_url?
|
11
|
+
no_url_matches_is_provided if url_match.nil?
|
12
|
+
!(driver.url =~ url_match).nil?
|
13
|
+
end
|
14
|
+
|
15
|
+
def has_correct_title?
|
16
|
+
no_title_is_provided if page_title.nil?
|
17
|
+
!(driver.title.match(page_title)).nil?
|
18
|
+
end
|
19
|
+
|
20
|
+
def url
|
21
|
+
self.class.url
|
22
|
+
end
|
23
|
+
|
24
|
+
def url_match
|
25
|
+
self.class.url_match
|
26
|
+
end
|
27
|
+
|
28
|
+
def page_title
|
29
|
+
self.class.page_title
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Symbiont
|
2
|
+
module Platform
|
3
|
+
# @return [Object] browser driver reference
|
4
|
+
attr_reader :driver
|
5
|
+
|
6
|
+
# @param driver [Object] a tool driver instance
|
7
|
+
def initialize(driver)
|
8
|
+
Symbiont.trace("Dialect attached to driver:\n\t#{driver.inspect}")
|
9
|
+
@driver = driver
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/symbiont/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Symbiont
|
2
|
-
VERSION =
|
3
|
-
end
|
1
|
+
module Symbiont
|
2
|
+
VERSION = '0.3.0'
|
3
|
+
end
|
data/lib/symbiont.rb
CHANGED
@@ -1,92 +1,34 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
require 'symbiont/
|
4
|
-
require 'symbiont/
|
5
|
-
require 'symbiont/
|
6
|
-
require 'symbiont/
|
7
|
-
|
8
|
-
require '
|
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
|
-
caller.extend Symbiont::Enclosers
|
36
|
-
end
|
37
|
-
|
38
|
-
# Returns the default wait value for pages. This value is the default
|
39
|
-
# value beyond which a timeout is assumed.
|
40
|
-
def self.page_level_wait
|
41
|
-
@page_wait ||= 15
|
42
|
-
end
|
43
|
-
|
44
|
-
def self.page_level_wait=(value)
|
45
|
-
@page_wait = value
|
46
|
-
end
|
47
|
-
|
48
|
-
# Returns the default wait value for elements on a page. This value is
|
49
|
-
# the default value beyond which a timeout is assumed.
|
50
|
-
def self.element_level_wait
|
51
|
-
@element_wait ||= 5
|
52
|
-
end
|
53
|
-
|
54
|
-
def self.element_level_wait=(value)
|
55
|
-
@element_wait = value
|
56
|
-
end
|
57
|
-
|
58
|
-
# The initialize method will be invoked when a page definition includes
|
59
|
-
# Symbiont. Some key things are happening here that are critical to
|
60
|
-
# Symbiont working correctly:
|
61
|
-
# (1) A browser instance is being created.
|
62
|
-
# (2) A platform object is created for that browser.
|
63
|
-
#
|
64
|
-
# @param [Object] browser a browser instance with a tool driver
|
65
|
-
# @param [boolean] visit if true, a definition will be navigated to
|
66
|
-
def initialize(browser, visit=nil)
|
67
|
-
Symbiont::trace("Symbiont attached to browser: #{browser}")
|
68
|
-
@browser = browser
|
69
|
-
establish_platform_object_for(browser)
|
70
|
-
view if visit && respond_to?(:view)
|
71
|
-
start if visit && respond_to?(:start)
|
72
|
-
end
|
73
|
-
|
74
|
-
private
|
75
|
-
|
76
|
-
# This method is crucial in that it sets up the platform instance that
|
77
|
-
# will be used by just about every module that makes calls to any
|
78
|
-
# platform-specific functionality.
|
79
|
-
#
|
80
|
-
# @param [Object] browser a browser instance with a tool driver
|
81
|
-
def establish_platform_object_for(browser)
|
82
|
-
@platform = get_platform_for(browser)
|
83
|
-
end
|
84
|
-
|
85
|
-
# This method processes a block with single or multiple parameters.
|
86
|
-
#
|
87
|
-
# @param [Proc] block the block to process
|
88
|
-
def process_block(&block)
|
89
|
-
block.arity == 1 ? block.call(self) : self.instance_eval(&block)
|
90
|
-
end
|
91
|
-
|
92
|
-
end
|
1
|
+
require 'watir-webdriver'
|
2
|
+
|
3
|
+
require 'symbiont/version'
|
4
|
+
require 'symbiont/logging'
|
5
|
+
require 'symbiont/errors'
|
6
|
+
require 'symbiont/helpers'
|
7
|
+
|
8
|
+
require 'colorize'
|
9
|
+
|
10
|
+
require 'symbiont/platform'
|
11
|
+
require 'symbiont/assertions'
|
12
|
+
require 'symbiont/pages'
|
13
|
+
require 'symbiont/elements'
|
14
|
+
require 'symbiont/accessor'
|
15
|
+
require 'symbiont/factory'
|
16
|
+
|
17
|
+
module Symbiont
|
18
|
+
include Platform
|
19
|
+
|
20
|
+
# @param caller [Class] the class including the framework
|
21
|
+
def self.included(caller)
|
22
|
+
caller.extend Symbiont::Assertion
|
23
|
+
caller.extend Symbiont::Element
|
24
|
+
|
25
|
+
caller.send :include, Symbiont::Page
|
26
|
+
caller.send :include, Symbiont::Accessor
|
27
|
+
|
28
|
+
Symbiont.trace("#{caller.class} #{caller} has attached the Symbiont.")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def attach(mod=Symbiont)
|
33
|
+
include mod
|
34
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
shared_examples_for 'element generator for' do |elements|
|
2
|
+
elements.each do |element|
|
3
|
+
|
4
|
+
context "#{element} on the watir-webdriver platform" do
|
5
|
+
it "will locate a specific #{element} with a single locator" do
|
6
|
+
expect(watir_browser).to receive(element).with(id: element).and_return(watir_element)
|
7
|
+
expect(watir_definition.send "#{element}").to eq(watir_element)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "will locate a specific #{element} with a proc" do
|
11
|
+
expect(watir_browser).to receive(element).with(id: element).and_return(watir_element)
|
12
|
+
expect(watir_definition.send "#{element}_proc").to eq(watir_element)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "will locate a specific #{element} with a lambda" do
|
16
|
+
expect(watir_browser).to receive(element).with(id: element).and_return(watir_element)
|
17
|
+
expect(watir_definition.send "#{element}_lambda").to eq(watir_element)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "will locate a specific #{element} with a block" do
|
21
|
+
expect(watir_browser).to receive(element).with(id: element).and_return(watir_element)
|
22
|
+
expect(watir_definition.send "#{element}_block", element).to eq(watir_element)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "will locate a specific #{element} with a block and argument" do
|
26
|
+
expect(watir_browser).to receive(element).with(id: element).and_return(watir_element)
|
27
|
+
expect(watir_definition.send "#{element}_block_arg", element).to eq(watir_element)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class PageWithMissingAssertions
|
2
|
+
attach Symbiont
|
3
|
+
end
|
4
|
+
|
5
|
+
class TestFactory
|
6
|
+
include Symbiont::Factory
|
7
|
+
attr_accessor :driver
|
8
|
+
attr_accessor :active
|
9
|
+
end
|
10
|
+
|
11
|
+
class ValidPageNewContext
|
12
|
+
attach Symbiont
|
13
|
+
end
|
14
|
+
|
15
|
+
class ValidPage
|
16
|
+
attach Symbiont
|
17
|
+
|
18
|
+
url_is 'http://localhost:9292'
|
19
|
+
url_matches /:\d{4}/
|
20
|
+
title_is 'Dialogic'
|
21
|
+
|
22
|
+
%w(text_field button).each do |element|
|
23
|
+
send element, :"#{element}", id: element
|
24
|
+
|
25
|
+
send element, :"#{element}_proc", proc { driver.send(element, id: element) }
|
26
|
+
send element, :"#{element}_lambda", -> { driver.send(element, id: element) }
|
27
|
+
|
28
|
+
send element, :"#{element}_block" do
|
29
|
+
driver.send(element, id: element)
|
30
|
+
end
|
31
|
+
|
32
|
+
send element, :"#{element}_block_arg" do |id|
|
33
|
+
driver.send(element, id: id)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,98 +1,49 @@
|
|
1
|
-
|
1
|
+
require 'simplecov'
|
2
|
+
require 'coveralls'
|
2
3
|
|
3
|
-
|
4
|
+
Coveralls.wear!
|
4
5
|
|
5
|
-
|
6
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
7
|
+
SimpleCov::Formatter::HTMLFormatter,
|
8
|
+
Coveralls::SimpleCov::Formatter
|
9
|
+
]
|
6
10
|
|
7
11
|
SimpleCov.start do
|
8
|
-
add_filter
|
9
|
-
coverage_dir "
|
10
|
-
|
12
|
+
add_filter '/spec'
|
13
|
+
coverage_dir "#{SimpleCov.root}/spec/reports/coverage"
|
14
|
+
minimum_coverage 90
|
15
|
+
maximum_coverage_drop 5
|
16
|
+
end
|
11
17
|
|
12
18
|
require 'symbiont'
|
13
19
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
look_for :name
|
22
|
-
|
23
|
-
text_field :name, id: "name"
|
24
|
-
text_field :email do |element|
|
25
|
-
"email"
|
20
|
+
RSpec.configure do |config|
|
21
|
+
original_stderr = $stderr
|
22
|
+
original_stdout = $stdout
|
23
|
+
config.before(:all) do
|
24
|
+
$stderr = File.new(File.join(File.dirname(__FILE__), 'reports/symbiont-output.txt'), 'w')
|
25
|
+
$stdout = File.new(File.join(File.dirname(__FILE__), 'reports/symbiont-output.txt'), 'w')
|
26
26
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
"description"
|
27
|
+
config.after(:all) do
|
28
|
+
$stderr = original_stderr
|
29
|
+
$stdout = original_stdout
|
31
30
|
end
|
32
31
|
|
33
|
-
|
34
|
-
hidden_field :visa do |element|
|
35
|
-
"visa"
|
36
|
-
end
|
37
|
-
|
38
|
-
paragraph :first, id: "first"
|
39
|
-
p :last, id: "last"
|
40
|
-
paragraph :middle do |element|
|
41
|
-
"middle"
|
42
|
-
end
|
32
|
+
config.alias_it_should_behave_like_to :provides_an, 'when providing an'
|
43
33
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
button :login, id: "login"
|
50
|
-
button :logout do |element|
|
51
|
-
"logout"
|
52
|
-
end
|
53
|
-
|
54
|
-
checkbox :apply_tax, id: "apply_tax"
|
55
|
-
checkbox :apply_fee do |element|
|
56
|
-
"apply_fee"
|
57
|
-
end
|
58
|
-
|
59
|
-
select_list :concepts, id: "concepts"
|
60
|
-
select_list :topics do |element|
|
61
|
-
"topics"
|
62
|
-
end
|
63
|
-
|
64
|
-
radio :include_tax, id: "include_tax"
|
65
|
-
radio :include_fee do |element|
|
66
|
-
"include_fee"
|
67
|
-
end
|
68
|
-
|
69
|
-
div :section, id: "section"
|
70
|
-
div :aside do |element|
|
71
|
-
"aside"
|
72
|
-
end
|
73
|
-
|
74
|
-
span :inline, id: "inline"
|
75
|
-
span :part do |element|
|
76
|
-
"part"
|
77
|
-
end
|
78
|
-
|
79
|
-
table :accounts, id: "accounts"
|
80
|
-
table :invoices do |element|
|
81
|
-
"invoices"
|
82
|
-
end
|
34
|
+
shared_context :page do
|
35
|
+
let(:watir_browser) { mock_browser_for_watir }
|
36
|
+
let(:watir_definition) { ValidPage.new(watir_browser) }
|
83
37
|
|
84
|
-
|
85
|
-
|
86
|
-
"sum"
|
38
|
+
let(:empty_definition) { PageWithMissingAssertions.new(watir_browser) }
|
39
|
+
let(:no_driver_definition) { ValidPage.new(:unknown) }
|
87
40
|
end
|
88
41
|
|
89
|
-
|
90
|
-
|
42
|
+
shared_context :element do
|
43
|
+
let(:watir_element) { double('element') }
|
91
44
|
end
|
92
45
|
end
|
93
46
|
|
94
|
-
|
95
|
-
|
96
|
-
watir_browser.stub(:is_a?).with(Watir::Browser).and_return(true)
|
97
|
-
watir_browser
|
47
|
+
Dir['spec/fixtures/**/*.rb'].each do |file|
|
48
|
+
require file.sub(/spec\//, '')
|
98
49
|
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Symbiont::Assertion do
|
4
|
+
context 'a definition with valid assertions' do
|
5
|
+
it 'will allow a url to be asserted' do
|
6
|
+
expect {
|
7
|
+
class PageWithUrl
|
8
|
+
attach Symbiont
|
9
|
+
url_is 'http://localhost:9292'
|
10
|
+
end
|
11
|
+
}.not_to raise_error
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'will allow a url match pattern to be asserted' do
|
15
|
+
expect {
|
16
|
+
class PageWithUrlMatches
|
17
|
+
attach Symbiont
|
18
|
+
url_matches /localhost/
|
19
|
+
end
|
20
|
+
}.not_to raise_error
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'will allow a title to be asserted' do
|
24
|
+
expect {
|
25
|
+
class PageWithTitle
|
26
|
+
attach Symbiont
|
27
|
+
title_is 'Dialogic'
|
28
|
+
end
|
29
|
+
}.not_to raise_error
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'a definition with missing assertion values' do
|
34
|
+
it 'will indicate a missing url_is assertion value' do
|
35
|
+
expect {
|
36
|
+
class PageWithMissingUrl
|
37
|
+
attach Symbiont
|
38
|
+
url_is
|
39
|
+
end
|
40
|
+
}.to raise_error Symbiont::Errors::NoUrlForDefinition
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'will indicate an empty url_is assertion value' do
|
44
|
+
expect {
|
45
|
+
class PageWithEmptyUrl
|
46
|
+
attach Symbiont
|
47
|
+
url_is ''
|
48
|
+
end
|
49
|
+
}.to raise_error Symbiont::Errors::NoUrlForDefinition
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'will indicate a missing url_matches assertion value' do
|
53
|
+
expect {
|
54
|
+
class PageWithMissingUrlMatch
|
55
|
+
attach Symbiont
|
56
|
+
url_matches
|
57
|
+
end
|
58
|
+
}.to raise_error Symbiont::Errors::NoUrlMatchForDefinition
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'will indicate an empty url_matches assertion value' do
|
62
|
+
expect {
|
63
|
+
class PageWithEmptyUrlMatch
|
64
|
+
attach Symbiont
|
65
|
+
url_matches ''
|
66
|
+
end
|
67
|
+
}.to raise_error Symbiont::Errors::NoUrlMatchForDefinition
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'will indicate a missing title_is assertion value' do
|
71
|
+
expect {
|
72
|
+
class PageWithMissingTitle
|
73
|
+
attach Symbiont
|
74
|
+
title_is
|
75
|
+
end
|
76
|
+
}.to raise_error Symbiont::Errors::NoTitleForDefinition
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'will indicate an empty title_is assertion value' do
|
80
|
+
expect {
|
81
|
+
class PageWithEmptyTitle
|
82
|
+
attach Symbiont
|
83
|
+
title_is ''
|
84
|
+
end
|
85
|
+
}.to raise_error Symbiont::Errors::NoTitleForDefinition
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Page Definitions' do
|
4
|
+
include_context :page
|
5
|
+
|
6
|
+
context 'a definition using watir-webdriver' do
|
7
|
+
context 'with a url_is assertion' do
|
8
|
+
it 'will call the driver navigation method when viewed' do
|
9
|
+
watir_browser.should_receive(:goto).twice
|
10
|
+
expect { watir_definition.view }.not_to raise_error
|
11
|
+
watir_definition.view
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'with a url_matches assertion' do
|
16
|
+
it 'will verify a url if the url_matches assertion has been set' do
|
17
|
+
watir_browser.should_receive(:url).twice.and_return('http://localhost:9292')
|
18
|
+
expect { watir_definition.has_correct_url? }.not_to raise_error
|
19
|
+
watir_definition.has_correct_url?.should be_true
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'will not verify a url if the url does not match the url_matches assertion' do
|
23
|
+
watir_browser.should_receive(:url).and_return('http://127.0.0.1')
|
24
|
+
watir_definition.has_correct_url?.should be_false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'with a title_is assertion' do
|
29
|
+
it 'will verify a title if the title_is assertion has been set' do
|
30
|
+
watir_browser.should_receive(:title).twice.and_return 'Dialogic'
|
31
|
+
expect { watir_definition.has_correct_title? }.not_to raise_error
|
32
|
+
watir_definition.has_correct_title?.should be_true
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'will not verify a title if the title does not match the title_is assertion' do
|
36
|
+
watir_browser.should_receive(:title).and_return('Page Title')
|
37
|
+
watir_definition.has_correct_title?.should be_false
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|