symbiont 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae39ecb1d2f038bed55793424d0eb7d00cf5fa44
4
- data.tar.gz: 97e1fe74cc798c76e1eee44c75d008e3fd3498be
3
+ metadata.gz: 5a17be88a1a66fd53974eee6f17a008c0dc13578
4
+ data.tar.gz: bccc7ebb6507f1fd54314215db12ecd623e0f035
5
5
  SHA512:
6
- metadata.gz: a30e010e67f0afb4dbc9a2db2fb089e136d5cab838cb663306372ef7415c767f57e35cf81b637eeb76235d92724f403a793f5b4e67a622e21466d0af01a6769e
7
- data.tar.gz: 1f9f7c9c31b0b8e84e1c102e636504e162d05fa9d02eef9cf7d1b044411bbee0f413ba8f3fb3354fcb3a50e05d807e504b03a5858d00e242e9a4a77da11efd0c
6
+ metadata.gz: d411934cd0073c31ce602b7af9c4b4d4f1025dbac7e69f8279ebc2ed0b965c845186ac523a5c13b6a1b1941eb2f317d80efb705b17728b9343fd756383ab0702
7
+ data.tar.gz: b00c7ca11d7ba5d2445324279439734f9dc4d808ef54b3592dde4547b38da55c07cf0149c298c34afa7e334932435342ee56c2bec536760a440c5ade01252caa
@@ -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
- driver.send(element, locator)
6
+ browser.send(element, locator)
7
7
  end
8
8
  end
9
9
  end
@@ -17,7 +17,7 @@ module Symbiont
17
17
  title_is_empty if title.nil? or title.empty?
18
18
  @title = title
19
19
  end
20
-
20
+
21
21
  def asserted_url
22
22
  @url
23
23
  end
@@ -18,7 +18,7 @@ module Symbiont
18
18
  return @context
19
19
  end
20
20
 
21
- @page = definition.new(@driver)
21
+ @page = definition.new(@browser)
22
22
  @page.view if visit == true
23
23
 
24
24
  @page.has_correct_url? if @page.respond_to?(:url_matches)
@@ -1,5 +1,8 @@
1
1
  module Symbiont
2
2
  module Helpers
3
+
4
+ private
5
+
3
6
  def url_is_empty
4
7
  puts "\nERROR".on_red
5
8
  puts "The url_is assertion is empty on the definition #{retrieve_class(caller)}.".cyan
@@ -36,8 +39,6 @@ module Symbiont
36
39
  raise Symbiont::Errors::NoTitleForDefinition
37
40
  end
38
41
 
39
- private
40
-
41
42
  def retrieve_class(caller)
42
43
  caller[1][/`.*'/][8..-3]
43
44
  end
@@ -4,18 +4,18 @@ module Symbiont
4
4
 
5
5
  def view
6
6
  no_url_is_provided if asserted_url.nil?
7
- driver.goto(asserted_url)
7
+ browser.goto(asserted_url)
8
8
  self
9
9
  end
10
10
 
11
11
  def has_correct_url?
12
12
  no_url_matches_is_provided if url_match.nil?
13
- !(driver.url =~ url_match).nil?
13
+ !(browser.url =~ url_match).nil?
14
14
  end
15
15
 
16
16
  def has_correct_title?
17
17
  no_title_is_provided if asserted_title.nil?
18
- !(driver.title.match(asserted_title)).nil?
18
+ !(browser.title.match(asserted_title)).nil?
19
19
  end
20
20
 
21
21
  def verified?
@@ -36,35 +36,35 @@ module Symbiont
36
36
  end
37
37
 
38
38
  def url
39
- driver.url
39
+ browser.url
40
40
  end
41
41
 
42
42
  def markup
43
- driver.html
43
+ browser.html
44
44
  end
45
45
 
46
46
  def text
47
- driver.text
47
+ browser.text
48
48
  end
49
49
 
50
50
  def title
51
- driver.title
51
+ browser.title
52
52
  end
53
53
 
54
54
  def visit(url)
55
- driver.goto(url)
55
+ browser.goto(url)
56
56
  end
57
57
 
58
58
  def screenshot(file)
59
- driver.wd.save_screenshot(file)
59
+ browser.wd.save_screenshot(file)
60
60
  end
61
61
 
62
62
  def run_script(script, *args)
63
- driver.execute_script(script, *args)
63
+ browser.execute_script(script, *args)
64
64
  end
65
65
 
66
66
  def get_cookie(name)
67
- for cookie in driver.cookies.to_a
67
+ for cookie in browser.cookies.to_a
68
68
  if cookie[:name] == name
69
69
  return cookie[:value]
70
70
  end
@@ -73,11 +73,11 @@ module Symbiont
73
73
  end
74
74
 
75
75
  def clear_cookies
76
- driver.cookies.clear
76
+ browser.cookies.clear
77
77
  end
78
78
 
79
79
  def refresh
80
- driver.refresh
80
+ browser.refresh
81
81
  end
82
82
 
83
83
  # @param block [Proc] the code that generates the alert
@@ -85,9 +85,9 @@ module Symbiont
85
85
  def will_alert(&block)
86
86
  yield
87
87
  value = nil
88
- if driver.alert.exists?
89
- value = driver.alert.text
90
- driver.alert.ok
88
+ if browser.alert.exists?
89
+ value = browser.alert.text
90
+ browser.alert.ok
91
91
  end
92
92
  value
93
93
  end
@@ -98,9 +98,9 @@ module Symbiont
98
98
  def will_confirm(response, &block)
99
99
  yield
100
100
  value = nil
101
- if driver.alert.exists?
102
- value = driver.alert.text
103
- response ? driver.alert.ok : driver.alert.close
101
+ if browser.alert.exists?
102
+ value = browser.alert.text
103
+ response ? browser.alert.ok : browser.alert.close
104
104
  end
105
105
  value
106
106
  end
@@ -111,9 +111,9 @@ module Symbiont
111
111
  # the value that the prompt had before the response was applied
112
112
  def will_prompt(response, &block)
113
113
  cmd = "window.prompt = function(text, value) {window.__lastWatirPrompt = {message: text, default_value: value}; return '#{response}';}"
114
- driver.wd.execute_script(cmd)
114
+ browser.wd.execute_script(cmd)
115
115
  yield
116
- result = driver.wd.execute_script('return window.__lastWatirPrompt')
116
+ result = browser.wd.execute_script('return window.__lastWatirPrompt')
117
117
  result && result.dup.each_key { |k| result[k.to_sym] = result.delete(k) }
118
118
  result
119
119
  end
@@ -1,3 +1,3 @@
1
1
  module Symbiont
2
- VERSION = '0.6.0'
2
+ VERSION = '0.7.0'
3
3
  end
data/lib/symbiont.rb CHANGED
@@ -43,12 +43,12 @@ module Symbiont
43
43
  end
44
44
 
45
45
  # @return [Object] browser driver reference
46
- attr_reader :driver
46
+ attr_reader :browser
47
47
 
48
48
  # @param driver [Object] a tool driver instance
49
49
  def initialize(driver)
50
- Symbiont.trace("Symbiont attached to driver:\n\t#{driver.inspect}")
51
- @driver = driver
50
+ Symbiont.trace("Symbiont attached to browser:\n\t#{driver.inspect}")
51
+ @browser = driver
52
52
 
53
53
  initialize_page if respond_to?(:initialize_page)
54
54
  initialize_activity if respond_to?(:initialize_activity)
@@ -60,7 +60,7 @@ def attach(mod=Symbiont)
60
60
  end
61
61
 
62
62
  def symbiont_browser(browser=:firefox)
63
- @driver = Watir::Browser.new browser
63
+ @browser = Watir::Browser.new browser
64
64
  end
65
65
 
66
66
  alias :symbiont_browser_for :symbiont_browser
@@ -83,3 +83,8 @@ class Watir::CheckBox
83
83
  alias_method :uncheck, :clear
84
84
  alias_method :checked?, :set?
85
85
  end
86
+
87
+ class Watir::Radio
88
+ alias_method :choose, :set
89
+ alias_method :chosen?, :set?
90
+ end
@@ -4,7 +4,7 @@ end
4
4
 
5
5
  class TestFactory
6
6
  include Symbiont::Factory
7
- attr_accessor :driver
7
+ attr_accessor :browser
8
8
  attr_accessor :page
9
9
  end
10
10
 
@@ -22,15 +22,15 @@ class ValidPage
22
22
  %w(text_field button file_field textarea select_list checkbox).each do |element|
23
23
  send element, :"#{element}", id: element
24
24
 
25
- send element, :"#{element}_proc", proc { driver.send(element, id: element) }
26
- send element, :"#{element}_lambda", -> { driver.send(element, id: element) }
25
+ send element, :"#{element}_proc", proc { browser.send(element, id: element) }
26
+ send element, :"#{element}_lambda", -> { browser.send(element, id: element) }
27
27
 
28
28
  send element, :"#{element}_block" do
29
- driver.send(element, id: element)
29
+ browser.send(element, id: element)
30
30
  end
31
31
 
32
32
  send element, :"#{element}_block_arg" do |id|
33
- driver.send(element, id: id)
33
+ browser.send(element, id: id)
34
34
  end
35
35
  end
36
36
  end
@@ -3,51 +3,51 @@ require 'spec_helper'
3
3
  describe Symbiont::Factory do
4
4
  before(:each) do
5
5
  @factory = TestFactory.new
6
- @factory.driver = mock_browser_for_watir
6
+ @factory.browser = mock_browser_for_watir
7
7
  end
8
8
 
9
9
  it 'will create a new definition and view it, using on_view' do
10
- expect(@factory.driver).to receive(:goto)
10
+ expect(@factory.browser).to receive(:goto)
11
11
  @factory.on_view(ValidPage)
12
12
  end
13
13
 
14
14
  it 'will create a new definition and view it, using on_view and a block' do
15
- expect(@factory.driver).to receive(:goto)
15
+ expect(@factory.browser).to receive(:goto)
16
16
  @factory.on_view ValidPage do |page|
17
17
  expect(page).to be_instance_of ValidPage
18
18
  end
19
19
  end
20
20
 
21
21
  it 'will create a new definition, using on and a block with a parameter' do
22
- expect(@factory.driver).not_to receive(:goto)
22
+ expect(@factory.browser).not_to receive(:goto)
23
23
  @factory.on ValidPage do |page|
24
24
  expect(page).to be_instance_of ValidPage
25
25
  end
26
26
  end
27
27
 
28
28
  it 'will create a new definition, using on and a block without a parameter' do
29
- expect(@factory.driver).not_to receive(:goto)
29
+ expect(@factory.browser).not_to receive(:goto)
30
30
  @factory.on ValidPage do
31
31
  expect(@factory.page).to be_instance_of ValidPage
32
32
  end
33
33
  end
34
34
 
35
35
  it 'will use an existing object reference with on' do
36
- expect(@factory.driver).to receive(:goto)
36
+ expect(@factory.browser).to receive(:goto)
37
37
  obj1 = @factory.on_view ValidPage
38
38
  obj2 = @factory.on ValidPage
39
39
  expect(obj1).to be(obj2)
40
40
  end
41
41
 
42
42
  it 'will not use an existing object reference with on_new' do
43
- expect(@factory.driver).to receive(:goto)
43
+ expect(@factory.browser).to receive(:goto)
44
44
  obj1 = @factory.on_view ValidPage
45
45
  obj2 = @factory.on_new ValidPage
46
46
  expect(obj1).not_to be(obj2)
47
47
  end
48
48
 
49
49
  it 'will create a new definition, using on_set' do
50
- expect(@factory.driver).not_to receive(:goto)
50
+ expect(@factory.browser).not_to receive(:goto)
51
51
  @factory.on_set ValidPage do |page|
52
52
  expect(page).to be_instance_of ValidPage
53
53
  end
@@ -60,7 +60,7 @@ describe Symbiont::Factory do
60
60
  end
61
61
 
62
62
  it 'will use an existing object reference with on_set' do
63
- expect(@factory.driver).to receive(:goto)
63
+ expect(@factory.browser).to receive(:goto)
64
64
  obj1 = @factory.on_view ValidPage
65
65
  obj2 = @factory.on_set ValidPage
66
66
  expect(obj1).to be(obj2)
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.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Nyman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-12 00:00:00.000000000 Z
11
+ date: 2014-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -134,7 +134,7 @@ licenses:
134
134
  - MIT
135
135
  metadata: {}
136
136
  post_install_message: "\n(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)\n\n
137
- \ Symbiont 0.6.0 has been installed.\n\n(::) (::) (::) (::) (::) (::) (::) (::)
137
+ \ Symbiont 0.7.0 has been installed.\n\n(::) (::) (::) (::) (::) (::) (::) (::)
138
138
  (::) (::) (::) (::)\n "
139
139
  rdoc_options: []
140
140
  require_paths: