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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c68cb90210987a71383e51232b6329c1327b3a99
4
- data.tar.gz: 35374152982c98a1f788a8bba8ba9d274a45dcc9
3
+ metadata.gz: 9bc327293c3472c14282edc22537abb5dfd66c26
4
+ data.tar.gz: 0dbe1b6627077c1689bc407f99ed67522fc966bf
5
5
  SHA512:
6
- metadata.gz: ee1f36d4723c194f0ef00ab92674f4b34187933ca393da9a11d0be5159c0b9b1fc9cb08b6290c041dabdf48fac15241eb89311a23817ecfa87d680732aa0b2f8
7
- data.tar.gz: e40a873f15ebbfdc82cdcc3e0d4488381d8f3ac7e24e23dc14825f0ce96bb5ea4512d74edc3ad619fb39353e704ebf962f3059810a525f4291e5b1bfadba2fd7
6
+ metadata.gz: 2517f266a4f8ac4e2d69d6e8ec7724b41cf80ee359eab725b4feb01cbfea2920ae69a45185b3ecd82771a7f53478c022eb30a579cc6ce4deaf2f954308b8753c
7
+ data.tar.gz: 201f6eeacdfdf55e6e9ec482d883d91c21055348d13e7a132c1afb9270000bb25757710a1801c76328bfbc0664b5d257612783023d56e22a4d1a6d94b2a4f289
data/.hound.yml CHANGED
@@ -73,7 +73,10 @@ Metrics/AbcSize:
73
73
  Enabled: false
74
74
 
75
75
  Metrics/ModuleLength:
76
- Max: 120
76
+ Max: 130
77
77
 
78
78
  Metrics/CyclomaticComplexity:
79
- Max: 7
79
+ Max: 12
80
+
81
+ Metrics/PerceivedComplexity:
82
+ Max: 12
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
 
@@ -3,7 +3,7 @@ module Symbiont
3
3
  # @param element [Symbol] name of Watir-based object
4
4
  # @param locator [Hash] locators for referencing the element
5
5
  def reference_element(element, locator)
6
- browser.send(element, locator)
6
+ browser.send(element, *locator)
7
7
  end
8
8
  end
9
9
  end
@@ -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
- def self.elements
7
- unless @elements
8
- @elements = Watir::Container.instance_methods
9
- # @elements.delete(:extract_selector)
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
- def self.settable
15
- @settable ||= [:text_field, :file_field, :textarea]
16
- end
17
+ def settable
18
+ @settable ||= [:text_field, :file_field, :textarea, :checkbox]
19
+ end
17
20
 
18
- def self.selectable
19
- @selectable ||= [:select_list]
20
- end
21
+ def selectable
22
+ @selectable ||= [:select_list]
23
+ end
21
24
 
22
- def self.settable?(element)
23
- settable.include? element.to_sym
24
- end
25
+ def settable?(element)
26
+ settable.include? element.to_sym
27
+ end
25
28
 
26
- def self.selectable?(element)
27
- selectable.include? element.to_sym
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 element do |*signature, &block|
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 "#{identifier}".to_sym do |*values|
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 "#{identifier}=".to_sym do |*values|
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 "#{identifier}=".to_sym do |*values|
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
@@ -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
- class WorkflowPathNotFound < StandardError; end
7
- class WorkflowActionNotFound < StandardError; end
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
@@ -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
@@ -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
 
@@ -27,6 +27,10 @@ module Symbiont
27
27
  has_correct_url?
28
28
  end
29
29
 
30
+ def secure?
31
+ !url.match(/^https/).nil?
32
+ end
33
+
30
34
  def asserted_url
31
35
  self.class.asserted_url
32
36
  end
@@ -1,3 +1,3 @@
1
1
  module Symbiont
2
- VERSION = '0.13.0'
2
+ VERSION = '0.14.0'
3
3
  end
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.13.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-03 00:00:00.000000000 Z
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.13.0 has been installed.\n\n(::) (::) (::) (::) (::) (::) (::) (::)
214
+ \ Symbiont 0.14.0 has been installed.\n\n(::) (::) (::) (::) (::) (::) (::) (::)
215
215
  (::) (::) (::) (::)\n "
216
216
  rdoc_options: []
217
217
  require_paths: