page-object 0.8.3 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ === Version 0.8.4 / 2013-1-26
2
+ * Enhancements
3
+ * Extracted navigational methods into new gem named page_navigation
4
+
1
5
  === Version 0.8.3 / 2013-1-22
2
6
  * Enhancements
3
7
  * Updated to use the latest selenium-webdriver 2.29
@@ -1,3 +1,5 @@
1
+ require 'page_navigation'
2
+
1
3
  module PageObject
2
4
  #
3
5
  # Module to facilitate to creating of page objects in step definitions. You
@@ -33,6 +35,8 @@ module PageObject
33
35
  # to the method.
34
36
  #
35
37
  module PageFactory
38
+ include PageNavigation
39
+
36
40
 
37
41
  #
38
42
  # Create and navigate to a page object. The navigation will only work if the
@@ -92,55 +96,6 @@ module PageObject
92
96
  # Support 'if' for readability of usage
93
97
  alias_method :if, :if_page
94
98
 
95
- #
96
- # Navigate to a specific page following a predefined path.
97
- #
98
- # This method requires a lot of setup. See the documentation for
99
- # this class. Once the setup is complete you can navigate to a
100
- # page traversing through all other pages along the way. It will
101
- # call the method you specified in the routes for each
102
- # page as it navigates. Using the example setup defined in the
103
- # documentation above you can call the method two ways:
104
- #
105
- # @example
106
- # page.navigate_to(PageThree) # will use the default path
107
- # page.navigate_to(PageThree, :using => :another_route)
108
- #
109
- # @param [PageObject] a class that has included the PageObject
110
- # module and which has the navigation_method defined
111
- # @param [Hash] a hash that contains an element with the key
112
- # :using. This will be used to lookup the route. It has a
113
- # default value of :default.
114
- # @param [block] an optional block to be called
115
- # @return [PageObject] the page you are navigating to
116
- #
117
- def navigate_to(page_cls, how = {:using => :default}, &block)
118
- path = path_for how
119
- to_index = find_index_for(path, page_cls)-1
120
- navigate_through_pages(path[0..to_index])
121
- on_page(page_cls, &block)
122
- end
123
-
124
- #
125
- # Same as navigate_to except it will start at the @current_page
126
- # instead the beginning of the path.
127
- #
128
- # @param [PageObject] a class that has included the PageObject
129
- # module and which has the navigation_method defined
130
- # @param [Hash] a hash that contains an element with the key
131
- # :using. This will be used to lookup the route. It has a
132
- # default value of :default.
133
- # @param [block] an optional block to be called
134
- # @return [PageObject] the page you are navigating to
135
- #
136
- def continue_navigation_to(page_cls, how = {:using => :default}, &block)
137
- path = path_for how
138
- from_index = find_index_for(path, @current_page.class)+1
139
- to_index = find_index_for(path, page_cls)-1
140
- navigate_through_pages(path[from_index..to_index])
141
- on_page(page_cls, &block)
142
- end
143
-
144
99
  private
145
100
 
146
101
  def class_from_string(str)
@@ -148,33 +103,5 @@ module PageObject
148
103
  mod.const_get(class_name)
149
104
  end
150
105
  end
151
-
152
- def path_for(how)
153
- path = PageObject::PageFactory.page_object_routes[how[:using]]
154
- fail("PageFactory route :#{how[:using].to_s} not found") unless path
155
- path
156
- end
157
-
158
- def navigate_through_pages(pages)
159
- pages.each do |cls, method, *args|
160
- page = on_page(cls)
161
- fail("Navigation method not specified on #{cls}.") unless page.respond_to? method
162
- page.send method unless args
163
- page.send method, *args if args
164
- end
165
- end
166
-
167
- def find_index_for(path, item)
168
- path.find_index { |each| each[0] == item}
169
- end
170
-
171
- class << self
172
- attr_accessor :page_object_routes
173
-
174
- def routes=(routes)
175
- raise("You must provide a :default route for PageFactory routes") unless routes[:default]
176
- @page_object_routes = routes
177
- end
178
- end
179
106
  end
180
107
  end
@@ -1,4 +1,4 @@
1
1
  module PageObject
2
2
  # @private
3
- VERSION = "0.8.3"
3
+ VERSION = "0.8.4"
4
4
  end
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
 
22
22
  s.add_dependency 'watir-webdriver', '>= 0.6.2'
23
23
  s.add_dependency 'selenium-webdriver', '>= 2.29.0'
24
+ s.add_dependency 'page_navigation', '>= 0.3'
24
25
 
25
26
  s.add_development_dependency 'rspec', '>= 2.12.0'
26
27
  s.add_development_dependency 'cucumber', '>= 1.2.0'
@@ -184,7 +184,7 @@ describe PageObject::PageFactory do
184
184
  it "should store the routes" do
185
185
  routes = ['a', 'b', 'c']
186
186
  PageObject::PageFactory.routes = {:default => routes}
187
- PageObject::PageFactory.page_object_routes[:default].should == routes
187
+ PageObject::PageFactory.routes[:default].should == routes
188
188
  end
189
189
 
190
190
  it "should navigate to a page calling the default methods" do
@@ -226,12 +226,16 @@ describe PageObject::PageFactory do
226
226
  [AnotherPage, :b_method],
227
227
  [YetAnotherPage, :c_method]]
228
228
  }
229
- fake_page = double('a_page')
230
- AnotherPage.should_receive(:new).and_return(fake_page)
231
- fake_page.should_receive(:respond_to?).with(:b_method).and_return(true)
232
- fake_page.should_receive(:b_method)
229
+
233
230
  @world.current_page = FactoryTestPage.new(@world.browser)
234
- FactoryTestPage.should_not_receive(:new)
231
+ f_page = FactoryTestPage.new(@world.browser)
232
+ FactoryTestPage.should_receive(:new).and_return(f_page)
233
+ f_page.should_receive(:respond_to?).with(:a_method).and_return(true)
234
+ f_page.should_receive(:a_method)
235
+ a_page = AnotherPage.new(@world.browser)
236
+ AnotherPage.should_receive(:new).and_return(a_page)
237
+ a_page.should_receive(:respond_to?).with(:b_method).and_return(true)
238
+ a_page.should_receive(:b_method)
235
239
  @world.continue_navigation_to(YetAnotherPage).class.should == YetAnotherPage
236
240
  end
237
241
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page-object
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.8.4
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: 2013-01-24 00:00:00.000000000 Z
12
+ date: 2013-01-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: watir-webdriver
@@ -43,6 +43,22 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: 2.29.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: page_navigation
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0.3'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0.3'
46
62
  - !ruby/object:Gem::Dependency
47
63
  name: rspec
48
64
  requirement: !ruby/object:Gem::Requirement
@@ -381,7 +397,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
381
397
  version: '0'
382
398
  segments:
383
399
  - 0
384
- hash: -1401660757405095936
400
+ hash: -1959030872660536496
385
401
  required_rubygems_version: !ruby/object:Gem::Requirement
386
402
  none: false
387
403
  requirements:
@@ -390,7 +406,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
390
406
  version: '0'
391
407
  segments:
392
408
  - 0
393
- hash: -1401660757405095936
409
+ hash: -1959030872660536496
394
410
  requirements: []
395
411
  rubyforge_project: page-object
396
412
  rubygems_version: 1.8.24