symbiont 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/symbiont/accessor.rb +1 -1
- data/lib/symbiont/assertions.rb +1 -1
- data/lib/symbiont/factory.rb +1 -1
- data/lib/symbiont/helpers.rb +3 -2
- data/lib/symbiont/pages.rb +21 -21
- data/lib/symbiont/version.rb +1 -1
- data/lib/symbiont.rb +9 -4
- data/spec/fixtures/page_definitions.rb +5 -5
- data/spec/symbiont/factory_spec.rb +9 -9
- 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: 5a17be88a1a66fd53974eee6f17a008c0dc13578
|
4
|
+
data.tar.gz: bccc7ebb6507f1fd54314215db12ecd623e0f035
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d411934cd0073c31ce602b7af9c4b4d4f1025dbac7e69f8279ebc2ed0b965c845186ac523a5c13b6a1b1941eb2f317d80efb705b17728b9343fd756383ab0702
|
7
|
+
data.tar.gz: b00c7ca11d7ba5d2445324279439734f9dc4d808ef54b3592dde4547b38da55c07cf0149c298c34afa7e334932435342ee56c2bec536760a440c5ade01252caa
|
data/lib/symbiont/accessor.rb
CHANGED
data/lib/symbiont/assertions.rb
CHANGED
data/lib/symbiont/factory.rb
CHANGED
data/lib/symbiont/helpers.rb
CHANGED
@@ -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
|
data/lib/symbiont/pages.rb
CHANGED
@@ -4,18 +4,18 @@ module Symbiont
|
|
4
4
|
|
5
5
|
def view
|
6
6
|
no_url_is_provided if asserted_url.nil?
|
7
|
-
|
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
|
-
!(
|
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
|
-
!(
|
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
|
-
|
39
|
+
browser.url
|
40
40
|
end
|
41
41
|
|
42
42
|
def markup
|
43
|
-
|
43
|
+
browser.html
|
44
44
|
end
|
45
45
|
|
46
46
|
def text
|
47
|
-
|
47
|
+
browser.text
|
48
48
|
end
|
49
49
|
|
50
50
|
def title
|
51
|
-
|
51
|
+
browser.title
|
52
52
|
end
|
53
53
|
|
54
54
|
def visit(url)
|
55
|
-
|
55
|
+
browser.goto(url)
|
56
56
|
end
|
57
57
|
|
58
58
|
def screenshot(file)
|
59
|
-
|
59
|
+
browser.wd.save_screenshot(file)
|
60
60
|
end
|
61
61
|
|
62
62
|
def run_script(script, *args)
|
63
|
-
|
63
|
+
browser.execute_script(script, *args)
|
64
64
|
end
|
65
65
|
|
66
66
|
def get_cookie(name)
|
67
|
-
for cookie in
|
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
|
-
|
76
|
+
browser.cookies.clear
|
77
77
|
end
|
78
78
|
|
79
79
|
def refresh
|
80
|
-
|
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
|
89
|
-
value =
|
90
|
-
|
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
|
102
|
-
value =
|
103
|
-
response ?
|
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
|
-
|
114
|
+
browser.wd.execute_script(cmd)
|
115
115
|
yield
|
116
|
-
result =
|
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
|
data/lib/symbiont/version.rb
CHANGED
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 :
|
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
|
51
|
-
@
|
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
|
-
@
|
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 :
|
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 {
|
26
|
-
send element, :"#{element}_lambda", -> {
|
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
|
-
|
29
|
+
browser.send(element, id: element)
|
30
30
|
end
|
31
31
|
|
32
32
|
send element, :"#{element}_block_arg" do |id|
|
33
|
-
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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-
|
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.
|
137
|
+
\ Symbiont 0.7.0 has been installed.\n\n(::) (::) (::) (::) (::) (::) (::) (::)
|
138
138
|
(::) (::) (::) (::)\n "
|
139
139
|
rdoc_options: []
|
140
140
|
require_paths:
|