symbiont 0.1.6 → 0.1.7

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.
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  *.rbc
4
4
  *.swo
5
5
  *.swp
6
+ .idea
6
7
  .bundle
7
8
  .config
8
9
  .yardoc
data/Gemfile.lock CHANGED
@@ -1,27 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- symbiont (0.1.3)
4
+ symbiont (0.1.6)
5
5
  watir-webdriver (= 0.6.1)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
- addressable (2.2.8)
10
+ addressable (2.3.2)
11
11
  builder (3.0.0)
12
- childprocess (0.3.2)
13
- ffi (~> 1.0.6)
12
+ childprocess (0.3.5)
13
+ ffi (~> 1.0, >= 1.0.6)
14
14
  cucumber (1.2.1)
15
15
  builder (>= 2.1.2)
16
16
  diff-lcs (>= 1.1.3)
17
17
  gherkin (~> 2.11.0)
18
18
  json (>= 1.4.6)
19
19
  diff-lcs (1.1.3)
20
- ffi (1.0.11)
20
+ ffi (1.1.5)
21
+ ffi (1.1.5-x86-mingw32)
21
22
  gherkin (2.11.1-x86-mingw32)
22
23
  json (>= 1.4.6)
23
24
  json (1.7.3)
24
- libwebsocket (0.1.3)
25
+ libwebsocket (0.1.5)
25
26
  addressable
26
27
  multi_json (1.3.5)
27
28
  rspec (2.11.0)
@@ -32,8 +33,8 @@ GEM
32
33
  rspec-expectations (2.11.1)
33
34
  diff-lcs (~> 1.1.3)
34
35
  rspec-mocks (2.11.1)
35
- rubyzip (0.9.8)
36
- selenium-webdriver (2.24.0)
36
+ rubyzip (0.9.9)
37
+ selenium-webdriver (2.25.0)
37
38
  childprocess (>= 0.2.5)
38
39
  libwebsocket (~> 0.1.3)
39
40
  multi_json (~> 1.0)
data/HISTORY.md CHANGED
@@ -1,6 +1,12 @@
1
1
  Change Log and History
2
2
  ======================
3
3
 
4
+ Version 0.1.7 / 2012-10-16
5
+ --------------------------
6
+
7
+ This release allows common Watir-type method calls to be callable on web objects directly. For example, you can now call 'id', 'value' and so on directly on the web objects. For a checkbox, you can directly call 'check' and 'uncheck'. This is as opposed to before where you had to use Symbiont's generated method structure, such as 'check_myCheckbox' (where myCheckbox was a declared checkbox web object). The other main element that was added was an encloser (within_window) that will allow you to essentially "attach" to a browser window and provide a set of actions in the context of that window.
8
+
9
+
4
10
  Version 0.1.6 / 2012-09-30
5
11
  --------------------------
6
12
 
data/lib/symbiont.rb CHANGED
@@ -35,6 +35,12 @@ module Symbiont
35
35
  caller.extend Symbiont::Enclosers
36
36
  end
37
37
 
38
+ # Returns the default wait value for pages. This value is the default
39
+ # value beyond which a timeout is assumed.
40
+ def self.page_level_wait
41
+ @page_wait ||= 15
42
+ end
43
+
38
44
  # The initialize method will be invoked when a page definition includes
39
45
  # Symbiont. Some key things are happening here that are critical to
40
46
  # Symbiont working correctly:
@@ -1,6 +1,22 @@
1
1
  module Symbiont
2
2
  module Enclosers
3
-
3
+
4
+ # Used to identify a web object or action on a web object as existing
5
+ # within an enclosing window object. The window can be referenced using
6
+ # either the title attribute of the window or a direct URL. The URL does
7
+ # not have to be the entire URL; it can just be a page name.
8
+ #
9
+ # @param [Hash] locator the :title or :url of the window
10
+ # @param [Proc; optional] block any code that should be executed as an
11
+ # action on or within the window
12
+ #
13
+ # @example
14
+ # page.within_window(title: "Report Page")
15
+ # page.within_window(url: report.html)
16
+ def within_window(locator, &block)
17
+ @platform.within_window(locator, &block)
18
+ end
19
+
4
20
  # Used to identify a web object as existing within an enclosing object
5
21
  # like a frame or an iframe. It is possible to nest by passing in parent
6
22
  # enclosers as the second parameter.
@@ -35,8 +51,8 @@ module Symbiont
35
51
  # @page.wait_for(5, 'page with expected title not found') do
36
52
  # @page.title.should == "Test App"
37
53
  # end
38
- def wait_for(message=nil, timeout=10, &block)
39
- @platform.wait_for(message, timeout, &block)
54
+ def wait_for(timeout=Symbiont.page_level_wait, message=nil, &block)
55
+ @platform.wait_for(timeout, message, &block)
40
56
  end
41
57
 
42
58
  # Provides a context for an action that will generate a JavaScript alert
@@ -59,7 +59,10 @@ module Symbiont
59
59
  def wait_for_pending_requests(timeout=30, message=nil)
60
60
  end_time = ::Time.now + timeout
61
61
  until ::Time.now > end_time
62
- return if @browser.run_script('return jQuery.active') == 0
62
+ begin
63
+ return if @browser.execute_script('return jQuery.active') == 0
64
+ rescue ReferenceError
65
+ end
63
66
  sleep 0.5
64
67
  end
65
68
  message = "Pending requests never indicated completion" unless message
@@ -67,10 +67,18 @@ module Symbiont
67
67
 
68
68
  # Platform method to wait for an action to complete in a given time.
69
69
  # @see Symbiont::Enclosers#wait_for
70
- def wait_for(message="wait condition not found", timeout, &block)
70
+ def wait_for(timeout, message="wait condition not found", &block)
71
71
  @browser.wait_until(timeout, message, &block)
72
72
  end
73
-
73
+
74
+ # Platform method to reference web objects in the context of a
75
+ # window.
76
+ # @see Symbiont::Enclosers#within_window
77
+ def within_window(locator, &block)
78
+ identifier = {locator.keys.first => /#{Regexp.escape(locator.values.first)}/}
79
+ @browser.window(identifier).use(&block)
80
+ end
81
+
74
82
  # Platform method to handle an alert message box.
75
83
  # @see Symbiont::Enclosers#will_alert
76
84
  def will_alert(&block)
@@ -1,3 +1,3 @@
1
1
  module Symbiont
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
@@ -24,7 +24,7 @@ module Symbiont
24
24
  end
25
25
 
26
26
  def visible?
27
- @web_object.visible?
27
+ @web_object.present?
28
28
  end
29
29
 
30
30
  def text
@@ -51,6 +51,22 @@ module Symbiont
51
51
  @web_object.tag_name
52
52
  end
53
53
 
54
+ def id
55
+ @web_object.id
56
+ end
57
+
58
+ def value
59
+ @web_object.value
60
+ end
61
+
62
+ def inspect
63
+ @web_object.inspect
64
+ end
65
+
66
+ def flash
67
+ @web_object.flash
68
+ end
69
+
54
70
  def when_actionable(timeout=5)
55
71
  @web_object.wait_until_present(timeout)
56
72
  self
@@ -2,7 +2,19 @@ module Symbiont
2
2
  module WebObjects
3
3
 
4
4
  class CheckBox < WebObject
5
-
5
+
6
+ def check
7
+ @web_object.set
8
+ end
9
+
10
+ def uncheck
11
+ @web_object.clear
12
+ end
13
+
14
+ def checked?
15
+ @web_object.set?
16
+ end
17
+
6
18
  end # class: CheckBox
7
19
 
8
20
  ::Symbiont::WebObjects.class_for_type[:checkbox] = ::Symbiont::WebObjects::CheckBox
@@ -15,7 +15,7 @@ describe Symbiont::Enclosers do
15
15
 
16
16
  it "should wait for a condition to be true" do
17
17
  watir_browser.should_receive(:wait_until).with(5, "some condition")
18
- watir_definition.wait_for("some condition", 5)
18
+ watir_definition.wait_for(5, "some condition")
19
19
  end
20
20
 
21
21
  it "should handle alert message boxes" do
@@ -38,5 +38,17 @@ describe Symbiont::Enclosers do
38
38
  watir_definition.will_prompt("Question") do
39
39
  end
40
40
  end
41
+
42
+ it "attaches to a window by using the title" do
43
+ watir_browser.should_receive(:window).with(:title => /Display\ Results/).and_return(watir_browser)
44
+ watir_browser.should_receive(:use)
45
+ watir_definition.within_window(title: "Display Results")
46
+ end
47
+
48
+ it "attaches to a window by using the url" do
49
+ watir_browser.should_receive(:window).with(:url => /results\.html/).and_return(watir_browser)
50
+ watir_browser.should_receive(:use)
51
+ watir_definition.within_window(url: "results.html")
52
+ end
41
53
  end
42
54
  end
@@ -56,13 +56,13 @@ describe Symbiont::Enclosers do
56
56
  end
57
57
 
58
58
  it "should wait for jquery pending requests to finish" do
59
- watir_browser.should_receive(:run_script).with('return jQuery.active').and_return(0)
59
+ watir_browser.should_receive(:execute_script).with('return jQuery.active').and_return(0)
60
60
  watir_definition.wait_for_pending_requests
61
61
  end
62
62
 
63
63
  it "should return an exception if pending requests did not finish" do
64
- watir_browser.should_receive(:run_script).with('return jQuery.active')
65
- watir_browser.should_receive(:run_script).with('return jQuery.active').and_return(1)
64
+ watir_browser.should_receive(:execute_script).with('return jQuery.active')
65
+ watir_browser.should_receive(:execute_script).with('return jQuery.active').and_return(1)
66
66
  expect { watir_definition.wait_for_pending_requests(1) }.to raise_error
67
67
  end
68
68
  end
@@ -4,4 +4,14 @@ describe Symbiont do
4
4
  it "should return version information" do
5
5
  Symbiont.version.should == "Symbiont v#{Symbiont::VERSION}"
6
6
  end
7
+
8
+ it "should provide a page level wait default" do
9
+ Symbiont.instance_variable_set("@page_wait", 10)
10
+ Symbiont.page_level_wait.should == 10
11
+ end
12
+
13
+ it "should set the page level wait default to 15" do
14
+ Symbiont.instance_variable_set("@page_wait", nil)
15
+ Symbiont.page_level_wait.should == 15
16
+ end
7
17
  end
@@ -27,6 +27,26 @@ describe "Web Objects" do
27
27
  watir_definition.tag.should == "div"
28
28
  end
29
29
 
30
+ it "should retrieve the id of a web object" do
31
+ watir_browser.should_receive(:id).and_return("id")
32
+ watir_definition.id.should == "id"
33
+ end
34
+
35
+ it "should retrieve the value of a web object" do
36
+ watir_browser.should_receive(:value).and_return("value")
37
+ watir_definition.value.should == "value"
38
+ end
39
+
40
+ it "should be able to inspect a web object" do
41
+ watir_browser.should_receive(:inspect).and_return(watir_definition)
42
+ watir_definition.inspect.should be_instance_of Symbiont::WebObjects::WebObject
43
+ end
44
+
45
+ it "should be able to flash a web_object" do
46
+ watir_browser.should_receive(:flash).and_return(watir_definition)
47
+ watir_definition.flash.should be_instance_of Symbiont::WebObjects::WebObject
48
+ end
49
+
30
50
  it "should determine if a web object is enabled" do
31
51
  watir_browser.should_receive(:enabled?).and_return(true)
32
52
  watir_definition.enabled?.should == true
@@ -48,12 +68,12 @@ describe "Web Objects" do
48
68
  end
49
69
 
50
70
  it "should determine if a web object is visible" do
51
- watir_browser.should_receive(:visible?).and_return(true)
71
+ watir_browser.should_receive(:present?).and_return(true)
52
72
  watir_definition.visible?.should == true
53
73
  end
54
74
 
55
75
  it "should determine if a web object is not visible" do
56
- watir_browser.should_receive(:visible?).and_return(false)
76
+ watir_browser.should_receive(:present?).and_return(false)
57
77
  watir_definition.visible?.should == false
58
78
  end
59
79
 
@@ -85,23 +105,23 @@ describe "Web Objects" do
85
105
  end
86
106
 
87
107
  it "should wait for a web object to become visible" do
88
- watir_browser.should_receive(:visible?).and_return(true)
108
+ watir_browser.should_receive(:present?).and_return(true)
89
109
  watir_definition.when_visible(5)
90
110
  end
91
111
 
92
112
  it "should reference a web object when it is visible" do
93
- watir_browser.should_receive(:visible?).and_return(true)
113
+ watir_browser.should_receive(:present?).and_return(true)
94
114
  web_object = watir_definition.when_visible(5)
95
115
  web_object.should === watir_definition
96
116
  end
97
117
 
98
118
  it "should wait for a web object to become invisible" do
99
- watir_browser.should_receive(:visible?).and_return(false)
119
+ watir_browser.should_receive(:present?).and_return(false)
100
120
  watir_definition.when_not_visible(5)
101
121
  end
102
122
 
103
123
  it "should reference a web object when it is not visible" do
104
- watir_browser.stub(:visible?).and_return(false)
124
+ watir_browser.stub(:present?).and_return(false)
105
125
  web_object = watir_definition.when_not_visible(5)
106
126
  web_object.should === watir_definition
107
127
  end
@@ -3,9 +3,25 @@ require 'spec_helper'
3
3
  describe Symbiont::WebObjects::CheckBox do
4
4
  describe "implementation" do
5
5
  let(:checkbox_object) { double('checkbox_object') }
6
+ let(:checkbox_definition) { Symbiont::WebObjects::CheckBox.new(checkbox_object) }
6
7
 
7
8
  it "should register with a submit type" do
8
9
  ::Symbiont::WebObjects.get_class_for(:input, :checkbox).should == ::Symbiont::WebObjects::CheckBox
9
10
  end
11
+
12
+ it "should be able to check the definition" do
13
+ checkbox_object.should_receive(:set)
14
+ checkbox_definition.check
15
+ end
16
+
17
+ it "should be able to uncheck the definition" do
18
+ checkbox_object.should_receive(:clear)
19
+ checkbox_definition.uncheck
20
+ end
21
+
22
+ it "should be able to determine if the definition is checked" do
23
+ checkbox_object.should_receive(:set?).and_return(true)
24
+ checkbox_definition.checked?
25
+ end
10
26
  end
11
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: symbiont
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-30 00:00:00.000000000 Z
12
+ date: 2012-10-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec