symbiont 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.hound.yml +5 -2
- data/lib/symbiont.rb +8 -0
- data/lib/symbiont/accessor.rb +1 -1
- data/lib/symbiont/elements.rb +29 -24
- data/lib/symbiont/errors.rb +12 -2
- data/lib/symbiont/factory.rb +8 -0
- data/lib/symbiont/helpers.rb +6 -6
- data/lib/symbiont/pages.rb +4 -0
- data/lib/symbiont/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bc327293c3472c14282edc22537abb5dfd66c26
|
4
|
+
data.tar.gz: 0dbe1b6627077c1689bc407f99ed67522fc966bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2517f266a4f8ac4e2d69d6e8ec7724b41cf80ee359eab725b4feb01cbfea2920ae69a45185b3ecd82771a7f53478c022eb30a579cc6ce4deaf2f954308b8753c
|
7
|
+
data.tar.gz: 201f6eeacdfdf55e6e9ec482d883d91c21055348d13e7a132c1afb9270000bb25757710a1801c76328bfbc0664b5d257612783023d56e22a4d1a6d94b2a4f289
|
data/.hound.yml
CHANGED
data/lib/symbiont.rb
CHANGED
@@ -44,6 +44,14 @@ module Symbiont
|
|
44
44
|
@browser
|
45
45
|
end
|
46
46
|
|
47
|
+
def self.version
|
48
|
+
"""
|
49
|
+
Symbiont v#{Symbiont::VERSION}
|
50
|
+
Watir-WebDriver: #{Gem.loaded_specs['watir-webdriver'].version}
|
51
|
+
Selenium-WebDriver: #{Gem.loaded_specs['selenium-webdriver'].version}
|
52
|
+
"""
|
53
|
+
end
|
54
|
+
|
47
55
|
# @return [Object] browser driver reference
|
48
56
|
attr_reader :browser
|
49
57
|
|
data/lib/symbiont/accessor.rb
CHANGED
data/lib/symbiont/elements.rb
CHANGED
@@ -3,28 +3,32 @@ module Symbiont
|
|
3
3
|
# Watir uses to reference and access web objects.
|
4
4
|
#
|
5
5
|
# @return [Array] factory method list
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
class << self
|
7
|
+
attr_accessor :settable, :selectable
|
8
|
+
|
9
|
+
def elements
|
10
|
+
unless @elements
|
11
|
+
@elements = Watir::Container.instance_methods
|
12
|
+
@elements.delete(:extract_selector)
|
13
|
+
end
|
14
|
+
@elements
|
10
15
|
end
|
11
|
-
@elements
|
12
|
-
end
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
def settable
|
18
|
+
@settable ||= [:text_field, :file_field, :textarea, :checkbox]
|
19
|
+
end
|
17
20
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
+
def selectable
|
22
|
+
@selectable ||= [:select_list]
|
23
|
+
end
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
+
def settable?(element)
|
26
|
+
settable.include? element.to_sym
|
27
|
+
end
|
25
28
|
|
26
|
-
|
27
|
-
|
29
|
+
def selectable?(element)
|
30
|
+
selectable.include? element.to_sym
|
31
|
+
end
|
28
32
|
end
|
29
33
|
|
30
34
|
module Element
|
@@ -32,7 +36,7 @@ module Symbiont
|
|
32
36
|
# as a method that can be called on a page class. This is what
|
33
37
|
# allows element definitions to be created.
|
34
38
|
Symbiont.elements.each do |element|
|
35
|
-
define_method
|
39
|
+
define_method(element) do |*signature, &block|
|
36
40
|
identifier, locator = parse_signature(signature)
|
37
41
|
context = context_from_signature(locator, &block)
|
38
42
|
define_element_accessor(identifier, locator, element, &context)
|
@@ -82,11 +86,12 @@ module Symbiont
|
|
82
86
|
#
|
83
87
|
# This approach would lead to the *values variable having
|
84
88
|
# an array like this: ["Click Me"].
|
85
|
-
def define_element_accessor(identifier, locator, element, &block)
|
86
|
-
define_method
|
89
|
+
def define_element_accessor(identifier, *locator, element, &block)
|
90
|
+
define_method("#{identifier}".to_sym) do |*values|
|
87
91
|
if block_given?
|
88
92
|
instance_exec(*values, &block)
|
89
93
|
else
|
94
|
+
locator = [] if locator[0].nil?
|
90
95
|
reference_element(element, locator)
|
91
96
|
end
|
92
97
|
end
|
@@ -112,8 +117,8 @@ module Symbiont
|
|
112
117
|
# The second approach would lead to the *values variable having
|
113
118
|
# an array like this: ['200']. The first approach would be
|
114
119
|
# handled by define_element_accessor instead.
|
115
|
-
def define_set_accessor(identifier, locator, element, &block)
|
116
|
-
define_method
|
120
|
+
def define_set_accessor(identifier, *locator, element, &block)
|
121
|
+
define_method("#{identifier}=".to_sym) do |*values|
|
117
122
|
accessor =
|
118
123
|
if block_given?
|
119
124
|
instance_exec(&block)
|
@@ -149,8 +154,8 @@ module Symbiont
|
|
149
154
|
# The second approach would lead to the *values variable having
|
150
155
|
# an array like this: ['City']. The first approach would be
|
151
156
|
# handled by define_element_accessor instead.
|
152
|
-
def define_select_accessor(identifier, locator, element, &block)
|
153
|
-
define_method
|
157
|
+
def define_select_accessor(identifier, *locator, element, &block)
|
158
|
+
define_method("#{identifier}=".to_sym) do |*values|
|
154
159
|
if block_given?
|
155
160
|
instance_exec(&block).select(*values)
|
156
161
|
else
|
data/lib/symbiont/errors.rb
CHANGED
@@ -3,7 +3,17 @@ module Symbiont
|
|
3
3
|
class NoUrlForDefinition < StandardError; end
|
4
4
|
class NoUrlMatchForDefinition < StandardError; end
|
5
5
|
class NoTitleForDefinition < StandardError; end
|
6
|
-
|
7
|
-
class
|
6
|
+
|
7
|
+
class PageURLFromFactoryNotVerified < StandardError
|
8
|
+
def message
|
9
|
+
'The page URL was not verified during a factory setup.'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class PageTitleFromFactoryNotVerified < StandardError
|
14
|
+
def message
|
15
|
+
'The page title was not verified during a factory setup.'
|
16
|
+
end
|
17
|
+
end
|
8
18
|
end
|
9
19
|
end
|
data/lib/symbiont/factory.rb
CHANGED
@@ -22,6 +22,14 @@ module Symbiont
|
|
22
22
|
@page = definition.new(@browser)
|
23
23
|
@page.view if visit
|
24
24
|
|
25
|
+
if @page.class.instance_variable_get(:@url_match)
|
26
|
+
raise Symbiont::Errors::PageURLFromFactoryNotVerified unless @page.has_correct_url?
|
27
|
+
end
|
28
|
+
|
29
|
+
if @page.class.instance_variable_get(:@title)
|
30
|
+
raise Symbiont::Errors::PageTitleFromFactoryNotVerified unless @page.has_correct_title?
|
31
|
+
end
|
32
|
+
|
25
33
|
@model = @page
|
26
34
|
|
27
35
|
block.call @page if block
|
data/lib/symbiont/helpers.rb
CHANGED
@@ -22,22 +22,22 @@ module Symbiont
|
|
22
22
|
|
23
23
|
def no_url_is_provided
|
24
24
|
puts "\nERROR".on_red
|
25
|
-
puts "You called a '#{retrieve_method(caller)}' action but the
|
26
|
-
definition #{self.class} does not have a url_is assertion.".cyan
|
25
|
+
puts "You called a '#{retrieve_method(caller)}' action but the ".cyan +
|
26
|
+
"definition #{self.class} does not have a url_is assertion.".cyan
|
27
27
|
raise Symbiont::Errors::NoUrlForDefinition
|
28
28
|
end
|
29
29
|
|
30
30
|
def no_url_matches_is_provided
|
31
31
|
puts "\nERROR".on_red
|
32
|
-
puts "You called a '#{retrieve_method(caller)}' action but the
|
33
|
-
definition #{self.class} does not have a url_matches assertion.".cyan
|
32
|
+
puts "You called a '#{retrieve_method(caller)}' action but the ".cyan +
|
33
|
+
"definition #{self.class} does not have a url_matches assertion.".cyan
|
34
34
|
raise Symbiont::Errors::NoUrlMatchForDefinition
|
35
35
|
end
|
36
36
|
|
37
37
|
def no_title_is_provided
|
38
38
|
puts "\nERROR".on_red
|
39
|
-
puts "You called a '#{retrieve_method(caller)}' action but the
|
40
|
-
definition #{self.class} does not have a title_is assertion.".cyan
|
39
|
+
puts "You called a '#{retrieve_method(caller)}' action but the ".cyan +
|
40
|
+
"definition #{self.class} does not have a title_is assertion.".cyan
|
41
41
|
raise Symbiont::Errors::NoTitleForDefinition
|
42
42
|
end
|
43
43
|
|
data/lib/symbiont/pages.rb
CHANGED
data/lib/symbiont/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: symbiont
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Nyman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -211,7 +211,7 @@ licenses:
|
|
211
211
|
- MIT
|
212
212
|
metadata: {}
|
213
213
|
post_install_message: "\n(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)\n\n
|
214
|
-
\ Symbiont 0.
|
214
|
+
\ Symbiont 0.14.0 has been installed.\n\n(::) (::) (::) (::) (::) (::) (::) (::)
|
215
215
|
(::) (::) (::) (::)\n "
|
216
216
|
rdoc_options: []
|
217
217
|
require_paths:
|