symbiont 0.4.0 → 0.5.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: cd18724d4d14d9283a706ab94d792c729abdb1c9
4
- data.tar.gz: 8f7e64b7080775f04027710b2e01d87599bb5861
3
+ metadata.gz: 40e70be6d5318a81169b82ff6883cb2c11326241
4
+ data.tar.gz: fc9316c0a36b95ffc727d4c3910a02e2d1ba2671
5
5
  SHA512:
6
- metadata.gz: 0481286fe56b0e66938637a42d68ee64e9207ba210788aa3e488e8632f44fcdca78598f2288f296836d69d76e5e0f008d21ae8a49a4c555d1453c1291468b49a
7
- data.tar.gz: 4f4ce214003961b53b594eb6e1e09540a6e70f4b92281e2a93e3e398d1323f7a7b0ae1cdc87119a5bdbbb463d9ece9e7f47a443f9fabb5297bdde166f26e66ef
6
+ metadata.gz: 633679d53faa74a76051840a800b94ae380a80282b9870d73bb5ae02f5154d8ecadfe7fbabdf022ce1f27b1dc59d9cac7326f2bb4f51ed1cbd8e92fa3acc6db3
7
+ data.tar.gz: 577844356cd9cf54fbf29f60d3884716f23c3da2379c1006ac5cb25e87d03fbf8ee8dd0263a9cb668f4ca5d13d75263b51adf61fa9ea5a4d64a98468a1cab08e
data/README.md CHANGED
@@ -28,7 +28,9 @@ You can also install Symbiont just as you would any other gem:
28
28
 
29
29
  ## Usage
30
30
 
31
- Instructions on how to use Symbiont will be available as the interface is defined. You can check out the [Symbiont test script](https://github.com/jnyman/symbiont/blob/master/test/symbiont-script.rb) for an idea of how the library can be interacted with. Do note that the test script requires a local copy of [Dialogic](https://github.com/jnyman/dialogic) to be running. To execute the test script:
31
+ To learn how to use the framework, you can check out my [blog posts on Symbiont](http://testerstories.com/category/symbiont/).
32
+
33
+ You can check out the [Symbiont test script](https://github.com/jnyman/symbiont/blob/master/test/symbiont-script.rb) for an idea of how the library can be interacted with. Do note that the test script requires a local copy of [Dialogic](https://github.com/jnyman/dialogic) to be running. To execute the test script:
32
34
 
33
35
  $ rake test:script
34
36
 
data/Rakefile CHANGED
@@ -19,7 +19,6 @@ namespace :spec do
19
19
  options = %w(--color)
20
20
  options += %w(--format documentation)
21
21
  options += %w(--format html --out spec/reports/symbiont-test-report.html)
22
- options += %w(--format nested --out spec/reports/symbiont-test-report.txt)
23
22
 
24
23
  config.rspec_opts = options
25
24
  end
@@ -11,13 +11,21 @@ module Symbiont
11
11
  end
12
12
 
13
13
  def self.settable
14
- @settable ||= [:text_field]
14
+ @settable ||= [:text_field, :file_field, :textarea]
15
+ end
16
+
17
+ def self.selectable
18
+ @selectable ||= [:select_list]
15
19
  end
16
20
 
17
21
  def self.settable?(element)
18
22
  settable.include? element.to_sym
19
23
  end
20
24
 
25
+ def self.selectable?(element)
26
+ selectable.include? element.to_sym
27
+ end
28
+
21
29
  module Element
22
30
  # Iterates through Watir factory methods. Each method is defined
23
31
  # as a method that can be called on a page class. This is what
@@ -28,6 +36,7 @@ module Symbiont
28
36
  context = context_from_signature(locator, &block)
29
37
  define_element_accessor(identifier, locator, element, &context)
30
38
  define_set_accessor(identifier, locator, element, &context) if Symbiont.settable?(element)
39
+ define_select_accessor(identifier, locator, element, &context) if Symbiont.selectable?(element)
31
40
  end
32
41
  end
33
42
 
@@ -104,8 +113,6 @@ module Symbiont
104
113
  # handled by define_element_accessor instead.
105
114
  def define_set_accessor(identifier, locator, element, &block)
106
115
  define_method "#{identifier}=".to_sym do |*values|
107
- puts "*** *values: #{values}"
108
-
109
116
  accessor = if block_given?
110
117
  instance_exec(&block)
111
118
  else
@@ -120,6 +127,36 @@ module Symbiont
120
127
  end
121
128
  end
122
129
 
130
+ # Defines an accessor method for an element that allows the value of
131
+ # the element to be selected via appending an "=" to the friendly
132
+ # name (identifier) of the element passed in.
133
+ #
134
+ # @param identifier [Symbol] friendly name of element definition
135
+ # @param locator [Hash] locators for referencing the element
136
+ # @param element [Symbol] name of Watir-based object
137
+ # @param block [Proc] a context block
138
+ #
139
+ # @example
140
+ # This element definition:
141
+ # select_list :city, id: 'city'
142
+ #
143
+ # Can be accessed in two ways:
144
+ # @page.city.select 'Chicago'
145
+ # @page.city = 'Chicago'
146
+ #
147
+ # The second approach would lead to the *values variable having
148
+ # an array like this: ['City']. The first approach would be
149
+ # handled by define_element_accessor instead.
150
+ def define_select_accessor(identifier, locator, element, &block)
151
+ define_method "#{identifier}=".to_sym do |*values|
152
+ if block_given?
153
+ instance_exec(&block).select *values
154
+ else
155
+ reference_element(element, locator).select *values
156
+ end
157
+ end
158
+ end
159
+
123
160
  # Returns the identifier and locator portions of an element definition.
124
161
  #
125
162
  # @param signature [Array] full element definition
@@ -1,6 +1,5 @@
1
1
  module Symbiont
2
2
  module Factory
3
-
4
3
  # Creates a definition context for actions. If an existing context
5
4
  # exists, that context will be re-used.
6
5
  #
@@ -9,9 +8,9 @@ module Symbiont
9
8
  # @param block [Proc] logic to execute in the context of the definition
10
9
  # @return [Object] instance of the definition
11
10
  def on(definition, visit=false, &block)
12
- if @active.kind_of?(definition)
13
- block.call @active if block
14
- return @active
11
+ if @page.kind_of?(definition)
12
+ block.call @page if block
13
+ return @page
15
14
  end
16
15
 
17
16
  if @context.kind_of?(definition)
@@ -19,11 +18,15 @@ module Symbiont
19
18
  return @context
20
19
  end
21
20
 
22
- @active = definition.new(@driver)
23
- @active.view if visit == true
24
- block.call @active if block
21
+ @page = definition.new(@driver)
22
+ @page.view if visit == true
23
+
24
+ @page.has_correct_url? if @page.respond_to?(:url_matches)
25
+ @page.has_correct_title? if @page.respond_to?(:title_is)
26
+
27
+ block.call @page if block
25
28
 
26
- @active
29
+ @page
27
30
  end
28
31
 
29
32
  alias_method :on_page, :on
@@ -49,7 +52,7 @@ module Symbiont
49
52
  # @param block [Proc] logic to execute in the context of the definition
50
53
  # @return [Object] instance of the definition
51
54
  def on_new(definition, &block)
52
- @active = nil
55
+ @page = nil
53
56
 
54
57
  if @context.kind_of?(definition)
55
58
  @context = nil
@@ -68,8 +71,8 @@ module Symbiont
68
71
  # @return [Object] instance of the definition
69
72
  def on_set(definition, &block)
70
73
  on(definition, &block)
71
- @context = @active
72
- @active
74
+ @context = @page
75
+ @page
73
76
  end
74
77
  end
75
78
  end
@@ -5,6 +5,7 @@ module Symbiont
5
5
  def view
6
6
  no_url_is_provided if asserted_url.nil?
7
7
  driver.goto(asserted_url)
8
+ self
8
9
  end
9
10
 
10
11
  def has_correct_url?
@@ -17,6 +18,11 @@ module Symbiont
17
18
  !(driver.title.match(asserted_title)).nil?
18
19
  end
19
20
 
21
+ def verified?
22
+ has_correct_url?
23
+ has_correct_title?
24
+ end
25
+
20
26
  def asserted_url
21
27
  self.class.asserted_url
22
28
  end
@@ -1,3 +1,3 @@
1
1
  module Symbiont
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.0'
3
3
  end
data/lib/symbiont.rb CHANGED
@@ -41,7 +41,7 @@ module Symbiont
41
41
 
42
42
  # @param driver [Object] a tool driver instance
43
43
  def initialize(driver)
44
- Symbiont.trace("Dialect attached to driver:\n\t#{driver.inspect}")
44
+ Symbiont.trace("Symbiont attached to driver:\n\t#{driver.inspect}")
45
45
  @driver = driver
46
46
 
47
47
  initialize_page if respond_to?(:initialize_page)
@@ -52,3 +52,9 @@ end
52
52
  def attach(mod=Symbiont)
53
53
  include mod
54
54
  end
55
+
56
+ def symbiont_browser(browser=:firefox)
57
+ @driver = Watir::Browser.new browser
58
+ end
59
+
60
+ alias :symbiont_browser_for :symbiont_browser
@@ -53,3 +53,19 @@ shared_examples_for 'element set generator for' do |elements|
53
53
  end
54
54
  end
55
55
  end
56
+
57
+ shared_examples_for 'element select generator for' do |elements|
58
+ elements.each do |element|
59
+ it "will set a value on a specific #{element} with a single locator" do
60
+ expect(watir_browser).to receive(element).with(id: element).and_return(watir_element)
61
+ expect(watir_element).to receive(:select).with('value')
62
+ watir_definition.send "#{element}=", 'value'
63
+ end
64
+
65
+ it "will set a value on a specific #{element} with a proc" do
66
+ expect(watir_browser).to receive(element).with(id: element).and_return(watir_element)
67
+ expect(watir_element).to receive(:select).with('value')
68
+ watir_definition.send "#{element}_proc=", 'value'
69
+ end
70
+ end
71
+ end
@@ -2,7 +2,7 @@ require 'watir-webdriver'
2
2
 
3
3
  def mock_browser_for_watir
4
4
  watir_browser = double('watir')
5
- watir_browser.stub(:is_a?).with(Watir::Browser).and_return(true)
6
- watir_browser.stub(:is_a?).with(Selenium::WebDriver::Driver).and_return(false)
5
+ allow(watir_browser).to receive(:is_a?).with(Watir::Browser).and_return(true)
6
+ allow(watir_browser).to receive(:is_a?).with(Selenium::WebDriver::Driver).and_return(false)
7
7
  watir_browser
8
8
  end
@@ -5,7 +5,7 @@ end
5
5
  class TestFactory
6
6
  include Symbiont::Factory
7
7
  attr_accessor :driver
8
- attr_accessor :active
8
+ attr_accessor :page
9
9
  end
10
10
 
11
11
  class ValidPageNewContext
@@ -19,7 +19,7 @@ class ValidPage
19
19
  url_matches /:\d{4}/
20
20
  title_is 'Dialogic'
21
21
 
22
- %w(text_field button).each do |element|
22
+ %w(text_field button file_field textarea select_list).each do |element|
23
23
  send element, :"#{element}", id: element
24
24
 
25
25
  send element, :"#{element}_proc", proc { driver.send(element, id: element) }
@@ -1,12 +1,23 @@
1
1
  require 'spec_helper'
2
2
 
3
+ describe 'Symbiont Driver' do
4
+ include_context :page
5
+
6
+ context 'a symbiont driver is requested' do
7
+ it 'will provide the default browser' do
8
+ expect(Watir::Browser).to receive(:new).once.and_return(watir_browser)
9
+ symbiont_browser
10
+ end
11
+ end
12
+ end
13
+
3
14
  describe 'Page Definitions' do
4
15
  include_context :page
5
16
 
6
17
  context 'a definition using watir-webdriver' do
7
18
  context 'with a url_is assertion' do
8
19
  it 'will call the driver navigation method when viewed' do
9
- watir_browser.should_receive(:goto).twice
20
+ expect(watir_browser).to receive(:goto).twice
10
21
  expect { watir_definition.view }.not_to raise_error
11
22
  watir_definition.view
12
23
  end
@@ -14,27 +25,27 @@ describe 'Page Definitions' do
14
25
 
15
26
  context 'with a url_matches assertion' do
16
27
  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')
28
+ expect(watir_browser).to receive(:url).twice.and_return('http://localhost:9292')
18
29
  expect { watir_definition.has_correct_url? }.not_to raise_error
19
- watir_definition.has_correct_url?.should be_true
30
+ expect(watir_definition.has_correct_url?).to be_truthy
20
31
  end
21
32
 
22
33
  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
34
+ expect(watir_browser).to receive(:url).and_return('http://127.0.0.1')
35
+ expect(watir_definition.has_correct_url?).to be_falsey
25
36
  end
26
37
  end
27
38
 
28
39
  context 'with a title_is assertion' do
29
40
  it 'will verify a title if the title_is assertion has been set' do
30
- watir_browser.should_receive(:title).twice.and_return 'Dialogic'
41
+ expect(watir_browser).to receive(:title).twice.and_return 'Dialogic'
31
42
  expect { watir_definition.has_correct_title? }.not_to raise_error
32
- watir_definition.has_correct_title?.should be_true
43
+ expect(watir_definition.has_correct_title?).to be_truthy
33
44
  end
34
45
 
35
46
  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
47
+ expect(watir_browser).to receive(:title).and_return('Page Title')
48
+ expect(watir_definition.has_correct_title?).to be_falsey
38
49
  end
39
50
  end
40
51
  end
@@ -5,5 +5,6 @@ describe Symbiont::Element do
5
5
  include_context :element
6
6
 
7
7
  provides_an 'element generator for', %w{text_field button}
8
- provides_an 'element set generator for', %w{text_field}
8
+ provides_an 'element set generator for', %w{text_field file_field textarea}
9
+ provides_an 'element select generator for', %w{select_list}
9
10
  end
@@ -7,63 +7,63 @@ describe Symbiont::Factory do
7
7
  end
8
8
 
9
9
  it 'will create a new definition and view it, using on_view' do
10
- @factory.driver.should_receive(:goto)
10
+ expect(@factory.driver).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
- @factory.driver.should_receive(:goto)
15
+ expect(@factory.driver).to receive(:goto)
16
16
  @factory.on_view ValidPage do |page|
17
- page.should be_instance_of ValidPage
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
- @factory.driver.should_not_receive(:goto)
22
+ expect(@factory.driver).not_to receive(:goto)
23
23
  @factory.on ValidPage do |page|
24
- page.should be_instance_of ValidPage
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
- @factory.driver.should_not_receive(:goto)
29
+ expect(@factory.driver).not_to receive(:goto)
30
30
  @factory.on ValidPage do
31
- @factory.active.should be_instance_of ValidPage
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
- @factory.driver.should_receive(:goto)
36
+ expect(@factory.driver).to receive(:goto)
37
37
  obj1 = @factory.on_view ValidPage
38
38
  obj2 = @factory.on ValidPage
39
- obj1.should == obj2
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
- @factory.driver.should_receive(:goto)
43
+ expect(@factory.driver).to receive(:goto)
44
44
  obj1 = @factory.on_view ValidPage
45
45
  obj2 = @factory.on_new ValidPage
46
- obj1.should_not == obj2
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
- @factory.driver.should_not_receive(:goto)
50
+ expect(@factory.driver).not_to receive(:goto)
51
51
  @factory.on_set ValidPage do |page|
52
- page.should be_instance_of ValidPage
52
+ expect(page).to be_instance_of ValidPage
53
53
  end
54
54
  end
55
55
 
56
56
  it 'will set a reference to be used outside the factory' do
57
- active = @factory.on ValidPage
58
- current = @factory.instance_variable_get '@active'
59
- current.should === active
57
+ page = @factory.on ValidPage
58
+ current = @factory.instance_variable_get '@page'
59
+ expect(current).to be(page)
60
60
  end
61
61
 
62
62
  it 'will use an existing object reference with on_set' do
63
- @factory.driver.should_receive(:goto)
63
+ expect(@factory.driver).to receive(:goto)
64
64
  obj1 = @factory.on_view ValidPage
65
65
  obj2 = @factory.on_set ValidPage
66
- obj1.should == obj2
66
+ expect(obj1).to be(obj2)
67
67
  end
68
68
 
69
69
  it 'will use an existing context using on after using on_set' do
@@ -79,8 +79,8 @@ describe Symbiont::Factory do
79
79
  @obj3 = page # obj1 CONTEXT is still set
80
80
  end
81
81
 
82
- @obj1.should_not == @obj2
83
- @obj1.should == @obj3
82
+ expect(@obj1).not_to be(@obj2)
83
+ expect(@obj1).to be(@obj3)
84
84
  end
85
85
 
86
86
  it 'will use an existing context using on_new of a different class after using on_set' do
@@ -96,8 +96,8 @@ describe Symbiont::Factory do
96
96
  @obj3 = page # CONTEXT is set to obj1
97
97
  end
98
98
 
99
- @obj1.should_not == @obj2
100
- @obj1.should == @obj3
99
+ expect(@obj1).not_to be(@obj2)
100
+ expect(@obj1).to be (@obj3)
101
101
  end
102
102
 
103
103
  it 'will clear existing context using on_new after using on_set' do
@@ -109,6 +109,6 @@ describe Symbiont::Factory do
109
109
  @obj2 = page # ACTIVE nil; since page is same, CONTEXT is nil
110
110
  end
111
111
 
112
- @obj1.should_not == @obj2
112
+ expect(@obj1).not_to be(@obj2)
113
113
  end
114
114
  end
@@ -50,8 +50,14 @@ describe Symbiont::Page do
50
50
  end
51
51
 
52
52
  context 'an instance of a page definition' do
53
+ it 'will be able to verify a page' do
54
+ expect(watir_browser).to receive(:title).and_return('Dialogic')
55
+ expect(watir_browser).to receive(:url).and_return('http://localhost:9292')
56
+ watir_definition.verified?
57
+ end
58
+
53
59
  it 'will be able to get the active url' do
54
- watir_browser.should_receive(:url).exactly(3).times.and_return('http://localhost:9292')
60
+ expect(watir_browser).to receive(:url).exactly(3).times.and_return('http://localhost:9292')
55
61
  expect(watir_definition).to respond_to :url
56
62
  expect(watir_definition.current_url).to eq('http://localhost:9292')
57
63
  expect(watir_definition.page_url).to eq('http://localhost:9292')
@@ -59,95 +65,95 @@ describe Symbiont::Page do
59
65
  end
60
66
 
61
67
  it 'will be able to get the markup of a page' do
62
- watir_browser.should_receive(:html).exactly(3).times.and_return('<h1>Page Section</h1>')
68
+ expect(watir_browser).to receive(:html).exactly(3).times.and_return('<h1>Page Section</h1>')
63
69
  expect(watir_definition.markup).to eq('<h1>Page Section</h1>')
64
70
  expect(watir_definition.html).to eq('<h1>Page Section</h1>')
65
71
  expect(watir_definition.html).to include('<h1>Page')
66
72
  end
67
73
 
68
74
  it 'will be able to get the text of a page' do
69
- watir_browser.should_receive(:text).exactly(3).times.and_return('some page text')
75
+ expect(watir_browser).to receive(:text).exactly(3).times.and_return('some page text')
70
76
  expect(watir_definition.page_text).to eq('some page text')
71
77
  expect(watir_definition.text).to eq('some page text')
72
78
  expect(watir_definition.text).to include('page text')
73
79
  end
74
80
 
75
81
  it 'will be able to get the title of a page' do
76
- watir_browser.should_receive(:title).exactly(3).times.and_return('Page Title')
82
+ expect(watir_browser).to receive(:title).exactly(3).times.and_return('Page Title')
77
83
  expect(watir_definition.page_title).to eq('Page Title')
78
84
  expect(watir_definition.title).to eq('Page Title')
79
85
  expect(watir_definition.title).to include('Title')
80
86
  end
81
87
 
82
88
  it 'will navigate to a specific url' do
83
- watir_browser.should_receive(:goto).exactly(3).times.with('http://localhost:9292')
89
+ expect(watir_browser).to receive(:goto).exactly(3).times.with('http://localhost:9292')
84
90
  watir_definition.visit('http://localhost:9292')
85
91
  watir_definition.navigate_to('http://localhost:9292')
86
92
  watir_definition.goto('http://localhost:9292')
87
93
  end
88
94
 
89
95
  it 'will be able to get a screenshot of the current page' do
90
- watir_browser.should_receive(:wd).twice.and_return(watir_browser)
91
- watir_browser.should_receive(:save_screenshot).twice
96
+ expect(watir_browser).to receive(:wd).twice.and_return(watir_browser)
97
+ expect(watir_browser).to receive(:save_screenshot).twice
92
98
  watir_definition.screenshot('testing.png')
93
99
  watir_definition.save_screenshot('testing.png')
94
100
  end
95
101
 
96
102
  it 'will run a script against the browser' do
97
- watir_browser.should_receive(:execute_script).twice.and_return('input')
103
+ expect(watir_browser).to receive(:execute_script).twice.and_return('input')
98
104
  expect(watir_definition.run_script('return document.activeElement')).to eq('input')
99
105
  expect(watir_definition.execute_script('return document.activeElement')).to eq('input')
100
106
  end
101
107
 
102
108
  it 'should run a script, with arguments, against the browser' do
103
- watir_browser.should_receive(:execute_script).with('return arguments[0].innerHTML', watir_element).and_return('testing')
104
- watir_definition.execute_script('return arguments[0].innerHTML', watir_element).should == 'testing'
109
+ expect(watir_browser).to receive(:execute_script).with('return arguments[0].innerHTML', watir_element).and_return('testing')
110
+ expect(watir_definition.execute_script('return arguments[0].innerHTML', watir_element)).to eq('testing')
105
111
  end
106
112
 
107
113
  it 'will be able to get a cookie value' do
108
114
  cookie = [{:name => 'test', :value => 'cookie', :path => '/'}]
109
- watir_browser.should_receive(:cookies).and_return(cookie)
115
+ expect(watir_browser).to receive(:cookies).and_return(cookie)
110
116
  expect(watir_definition.get_cookie('test')).to eq('cookie')
111
117
  end
112
118
 
113
119
  it 'will return nothing if a cookie value is not found' do
114
120
  cookie = [{:name => 'test', :value =>'cookie', :path => '/'}]
115
- watir_browser.should_receive(:cookies).and_return(nil)
121
+ expect(watir_browser).to receive(:cookies).and_return(nil)
116
122
  expect(watir_definition.get_cookie('testing')).to be_nil
117
123
  end
118
124
 
119
125
  it 'will be able to clear all cookies from the browser' do
120
- watir_browser.should_receive(:cookies).twice.and_return(watir_browser)
121
- watir_browser.should_receive(:clear).twice
126
+ expect(watir_browser).to receive(:cookies).twice.and_return(watir_browser)
127
+ expect(watir_browser).to receive(:clear).twice
122
128
  watir_definition.remove_cookies
123
129
  watir_definition.clear_cookies
124
130
  end
125
131
 
126
132
  it 'will be able to refresh the page' do
127
- watir_browser.should_receive(:refresh).twice.and_return(watir_browser)
133
+ expect(watir_browser).to receive(:refresh).twice.and_return(watir_browser)
128
134
  watir_definition.refresh_page
129
135
  watir_definition.refresh
130
136
  end
131
137
 
132
138
  it 'will be able to handle JavaScript alert dialogs' do
133
- watir_browser.should_receive(:alert).exactly(3).times.and_return(watir_browser)
134
- watir_browser.should_receive(:exists?).and_return(true)
135
- watir_browser.should_receive(:text)
136
- watir_browser.should_receive(:ok)
139
+ expect(watir_browser).to receive(:alert).exactly(3).times.and_return(watir_browser)
140
+ expect(watir_browser).to receive(:exists?).and_return(true)
141
+ expect(watir_browser).to receive(:text)
142
+ expect(watir_browser).to receive(:ok)
137
143
  watir_definition.will_alert {}
138
144
  end
139
145
 
140
146
  it 'will be able to handle JavaScript confirmation dialogs' do
141
- watir_browser.should_receive(:alert).exactly(3).times.and_return(watir_browser)
142
- watir_browser.should_receive(:exists?).and_return(true)
143
- watir_browser.should_receive(:text)
144
- watir_browser.should_receive(:ok)
147
+ expect(watir_browser).to receive(:alert).exactly(3).times.and_return(watir_browser)
148
+ expect(watir_browser).to receive(:exists?).and_return(true)
149
+ expect(watir_browser).to receive(:text)
150
+ expect(watir_browser).to receive(:ok)
145
151
  watir_definition.will_confirm(true) {}
146
152
  end
147
153
 
148
154
  it 'will be able to handle JavaScript prompt dialogs' do
149
- watir_browser.should_receive(:wd).twice.and_return(watir_browser)
150
- watir_browser.should_receive(:execute_script).twice
155
+ expect(watir_browser).to receive(:wd).twice.and_return(watir_browser)
156
+ expect(watir_browser).to receive(:execute_script).twice
151
157
  watir_definition.will_prompt('Testing') {}
152
158
  end
153
159
  end
data/symbiont.gemspec CHANGED
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
37
37
 
38
38
  spec.add_development_dependency 'bundler', '~> 1.6'
39
39
  spec.add_development_dependency 'rake'
40
- spec.add_development_dependency 'rspec', '>= 2.14'
40
+ spec.add_development_dependency 'rspec', '>= 3.0'
41
41
 
42
42
  spec.add_runtime_dependency 'colorize', '>= 0.7.2'
43
43
  spec.add_runtime_dependency 'watir-webdriver', '>= 0.6.9'
@@ -49,6 +49,10 @@ class Practice
49
49
  url_matches /:\d{4}/
50
50
  title_is 'Dialogic - Practice Page'
51
51
 
52
+ checkbox :enable_sith_list, id: 'toggleSith'
53
+ select_list :sith_power, id: 'sith'
54
+ select_list :physics_concept, id: 'physics'
55
+
52
56
  button :alert, id: 'alertButton'
53
57
  button :confirm, id: 'confirmButton'
54
58
  button :prompt, id: 'promptButton'
@@ -66,8 +70,6 @@ class Practice
66
70
  end
67
71
  end
68
72
 
69
- @driver = Watir::Browser.new
70
-
71
73
  def non_framed
72
74
  @page = Weight.new(@driver)
73
75
  @page.view
@@ -126,28 +128,32 @@ def factory
126
128
  end
127
129
  end
128
130
 
129
- #basic
131
+ def javascript_dialogs
132
+ response = @page.will_alert { @page.alert.click }
133
+ expect(response).to eq 'Alert Message Received'
130
134
 
131
- @page = Dialogic.new(@driver)
132
- @page.view
133
- @page.login_as_admin
135
+ response = @page.will_confirm(false) { @page.confirm.click }
136
+ expect(response).to eq 'Confirmation Message Received'
134
137
 
135
- @page = Practice.new(@driver)
136
- @page.view
138
+ response = @page.will_prompt("magenta") { @page.prompt.click }
139
+ expect(response[:message]).to eq('Favorite Color')
140
+ expect(response[:default_value]).to eq('blue')
141
+ end
137
142
 
138
- response = @page.will_alert { @page.alert.click }
139
- expect(response).to eq 'Alert Message Received'
143
+ def wait_state
144
+ Watir::Wait.until { @page.weight.exists? }
145
+ @page.weight.when_present.set '200'
146
+ end
140
147
 
141
- response = @page.will_confirm(false) { @page.confirm.click }
142
- expect(response).to eq 'Confirmation Message Received'
148
+ #basic
143
149
 
144
- response = @page.will_prompt("magenta") { @page.prompt.click }
145
- expect(response[:message]).to eq('Favorite Color')
146
- expect(response[:default_value]).to eq('blue')
150
+ symbiont_driver
147
151
 
148
- @page = Weight.new(@driver)
152
+ @page = Dialogic.new(@driver)
149
153
  @page.view
154
+ @page.login_as_admin
150
155
 
151
- Watir::Wait.until { @page.weight.exists? }
152
-
153
- @page.weight.when_present.set '200'
156
+ @page = Practice.new(@driver)
157
+ @page.view
158
+ @page.enable_sith_list.set
159
+ @page.sith_power.select 'Sundering Assault'
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.0
4
+ version: 0.5.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-05-08 00:00:00.000000000 Z
11
+ date: 2014-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - '>='
46
46
  - !ruby/object:Gem::Version
47
- version: '2.14'
47
+ version: '3.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
- version: '2.14'
54
+ version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: colorize
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -127,7 +127,7 @@ licenses:
127
127
  - MIT
128
128
  metadata: {}
129
129
  post_install_message: "\n (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
130
- (::)\n\n Symbiont 0.4.0 has been installed.\n\n (::) (::) (::) (::) (::)
130
+ (::)\n\n Symbiont 0.5.0 has been installed.\n\n (::) (::) (::) (::) (::)
131
131
  (::) (::) (::) (::) (::) (::) (::)\n "
132
132
  rdoc_options: []
133
133
  require_paths:
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  requirements:
146
146
  - Watir-WebDriver, Colorize
147
147
  rubyforge_project:
148
- rubygems_version: 2.2.2
148
+ rubygems_version: 2.0.14
149
149
  signing_key:
150
150
  specification_version: 4
151
151
  summary: An Endosymbiotic Facultative Semantically Clean Fluent Interface Test Framework
@@ -160,4 +160,3 @@ test_files:
160
160
  - spec/symbiont/factory_spec.rb
161
161
  - spec/symbiont/page_spec.rb
162
162
  - test/symbiont-script.rb
163
- has_rdoc: