centric_page_navigation 0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/ChangeLog +30 -0
- data/Gemfile +10 -0
- data/Guardfile +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +14 -0
- data/centric_page_navigation.gemspec +25 -0
- data/lib/page_navigation/routes.rb +21 -0
- data/lib/page_navigation/version.rb +3 -0
- data/lib/page_navigation.rb +142 -0
- data/spec/lib/page_navigation_spec.rb +214 -0
- data/spec/spec_helper.rb +7 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d9b36013fd2d7881392710a107d44d95daf1f17213e95137642a36d3fa3c2d8b
|
4
|
+
data.tar.gz: '0583f831e345754c7a2c428ad746394663cc60e1360f4a9054b69d132010e1cb'
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 46866b11e2f4af5dbb5d4267506d1e134ae7d25435a69d40708964ebf0610ff08ea7ae1daa2a21a1e1c865b37128e2d60ac6ea447561dd4ce5112da576f51c30
|
7
|
+
data.tar.gz: 1dba1830cd19a53eb2ed6c17a681efe0a6d0dd0091a7b5310e2d36279342abc3e689e8b6c25d1e0f9a827e24c1e0a939f16e60ba4ddd7f063f7d2c6430fa01bf
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
page-object
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.7.0
|
data/ChangeLog
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
=== Version 0.10 / 2016-10-18
|
2
|
+
* Improved error message when navigation methods are undefined
|
3
|
+
* Added optional 'visit' argument to navigate_to and navigate_all to visit first page (Thanks sciros)
|
4
|
+
|
5
|
+
=== Version 0.9 / 2013-05-03
|
6
|
+
* Added :from entry to navigate_to method call
|
7
|
+
|
8
|
+
=== Version 0.8 / 2013-04-26
|
9
|
+
* Added navigate_all method to navigate an entire route including the last page
|
10
|
+
|
11
|
+
=== Version 0.7 / 2013-2-27
|
12
|
+
* Added route_data hash to map a route to a specific DataMagic file
|
13
|
+
|
14
|
+
=== Version 0.6 / 2013-2-19
|
15
|
+
* Fixed continue_navigation_to to always start with @current_page
|
16
|
+
|
17
|
+
=== Version 0.5 / 2013-2-1
|
18
|
+
* Fixed with continue_navigation_to not picking the page after @current_page
|
19
|
+
|
20
|
+
=== Version 0.4 / 2013-1-28
|
21
|
+
* Fixed typo in homepage entry for gemspec
|
22
|
+
|
23
|
+
=== Version 0.3 / 2013-1-26
|
24
|
+
* Fixed issue when navigating from a page to the same page
|
25
|
+
|
26
|
+
=== Version 0.2 / 2013-1-25
|
27
|
+
* Fixed minor issue when module is included in module that is included in Class
|
28
|
+
|
29
|
+
=== Version 0.1 / 2013-1-25
|
30
|
+
* This is the initial release of this gem
|
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'rspec', :cli => '--color --format doc' do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { "spec" }
|
8
|
+
end
|
9
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Jeffrey S. Morgan
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# PageNavigation
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'centric_page_navigation'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install centric_page_navigation
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
5
|
+
spec.ruby_opts = "-I lib:spec"
|
6
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
7
|
+
end
|
8
|
+
task :spec
|
9
|
+
|
10
|
+
task :lib do
|
11
|
+
$LOAD_PATH.unshift(File.expand_path("lib", File.dirname(__FILE__)))
|
12
|
+
end
|
13
|
+
|
14
|
+
task :default => :spec
|
@@ -0,0 +1,25 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'page_navigation/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = 'centric_page_navigation'
|
7
|
+
gem.version = PageNavigation::VERSION
|
8
|
+
gem.platform = Gem::Platform::RUBY
|
9
|
+
gem.authors = ['Jeffrey S. Morgan','Dmitry Sharkov', 'Joseph Ours']
|
10
|
+
gem.email = ['jeff.morgan@leandog.com', 'joseph.ours@centricconsulting.com']
|
11
|
+
gem.homepage = 'http://github.com/centricconsulting/page_navigation'
|
12
|
+
gem.description = %q{Provides basic navigation through a collection of items that use the PageObject pattern.}
|
13
|
+
gem.summary = %q{Provides basic navigation through a collection of items that use the PageObject pattern.}
|
14
|
+
|
15
|
+
gem.rubyforge_project = 'centric_page_navigation'
|
16
|
+
|
17
|
+
gem.files = `git ls-files`.split($/)
|
18
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
19
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
20
|
+
gem.require_paths = ['lib']
|
21
|
+
|
22
|
+
gem.add_dependency 'centric_data_magic', '>= 1.2'
|
23
|
+
|
24
|
+
gem.add_development_dependency 'rspec', '>= 3.4.0'
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module PageNavigation
|
2
|
+
module Routes
|
3
|
+
|
4
|
+
def routes
|
5
|
+
@routes
|
6
|
+
end
|
7
|
+
|
8
|
+
def routes=(routes)
|
9
|
+
raise('You must provide a :default route') unless routes[:default]
|
10
|
+
@routes = routes
|
11
|
+
end
|
12
|
+
|
13
|
+
def route_data
|
14
|
+
@route_data
|
15
|
+
end
|
16
|
+
|
17
|
+
def route_data=(data)
|
18
|
+
@route_data = data
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
require 'page_navigation/version'
|
2
|
+
require 'page_navigation/routes'
|
3
|
+
require 'data_magic'
|
4
|
+
|
5
|
+
#
|
6
|
+
# Implements basic navigation capabilities for a collection of classes
|
7
|
+
# that implement a PageObject like pattern.
|
8
|
+
#
|
9
|
+
# In order to use these two methods you must define routes. A route
|
10
|
+
# is simply an array of Class/Method calls and can contain parameters
|
11
|
+
# that can be passed to the methods. Here is an example:
|
12
|
+
#
|
13
|
+
# @example Example routes defined in env.rb
|
14
|
+
# MyNavigator.routes = {
|
15
|
+
# :default => [[PageOne,:method1], [PageTwoA,:method2], [PageThree,:method3]],
|
16
|
+
# :another_route => [[PageOne,:method1, "arg1"], [PageTwoB,:method2b], [PageThree,:method3]]
|
17
|
+
# }
|
18
|
+
#
|
19
|
+
# Notice the first entry of :another_route is passing an argument
|
20
|
+
# to the method.
|
21
|
+
#
|
22
|
+
# The user must also maintain an instance variable named @current_page
|
23
|
+
# which points to the current object in the array.
|
24
|
+
#
|
25
|
+
module PageNavigation
|
26
|
+
|
27
|
+
def self.included(cls)
|
28
|
+
cls.extend PageNavigation::Routes
|
29
|
+
@cls = cls
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.cls
|
33
|
+
@cls
|
34
|
+
end
|
35
|
+
|
36
|
+
#
|
37
|
+
# Navigate to a specific page following a predefined path.
|
38
|
+
#
|
39
|
+
# This method requires a lot of setup. See the documentation for
|
40
|
+
# this module. Once the setup is complete you can navigate to a
|
41
|
+
# page traversing through all other pages along the way. It will
|
42
|
+
# call the method you specified in the routes for each
|
43
|
+
# page as it navigates. Using the example setup defined in the
|
44
|
+
# documentation above you can call the method two ways:
|
45
|
+
#
|
46
|
+
# @example
|
47
|
+
# page.navigate_to(PageThree) # will use the default path
|
48
|
+
# page.navigate_to(PageThree, :using => :another_route)
|
49
|
+
#
|
50
|
+
# @param [PageObject] page_cls a class that implements the PageObject pattern.
|
51
|
+
# @param [Hash] how a hash that contains two elements. One with the key
|
52
|
+
# :using. This will be used to lookup the route. It has a
|
53
|
+
# default value of :default. The other is with the key :visit. This specifies
|
54
|
+
# whether to explicitly visit the first page. It has a default value of false.
|
55
|
+
# @param [block] block an optional block to be called
|
56
|
+
# @return [PageObject] the page you are navigating to
|
57
|
+
#
|
58
|
+
def navigate_to(page_cls, how = {:using => :default, :visit => false}, &block)
|
59
|
+
how[:using] = :default unless how[:using]
|
60
|
+
how[:visit] = false unless how[:visit]
|
61
|
+
path = path_for how
|
62
|
+
to_index = find_index_for(path, page_cls)-1
|
63
|
+
if to_index == -1
|
64
|
+
return on(page_cls, &block)
|
65
|
+
else
|
66
|
+
start = how[:from] ? path.find_index { |entry| entry[0] == how[:from] } : 0
|
67
|
+
navigate_through_pages(path[start..to_index], how[:visit])
|
68
|
+
end
|
69
|
+
on(page_cls, &block)
|
70
|
+
end
|
71
|
+
|
72
|
+
#
|
73
|
+
# Same as navigate_to except it will start at the @current_page
|
74
|
+
# instead the beginning of the path.
|
75
|
+
#
|
76
|
+
# @param [PageObject] page_cls a class that implements the PageObject pattern.
|
77
|
+
# @param [Hash] how a hash that contains an element with the key
|
78
|
+
# :using. This will be used to lookup the route. It has a
|
79
|
+
# default value of :default.
|
80
|
+
# @param [block] block an optional block to be called
|
81
|
+
# @return [PageObject] the page you are navigating to
|
82
|
+
#
|
83
|
+
def continue_navigation_to(page_cls, how = {:using => :default}, &block)
|
84
|
+
path = path_for how
|
85
|
+
from_index = find_index_for(path, @current_page.class)
|
86
|
+
to_index = find_index_for(path, page_cls)-1
|
87
|
+
if from_index == to_index
|
88
|
+
navigate_through_pages([path[from_index]], false)
|
89
|
+
else
|
90
|
+
navigate_through_pages(path[from_index..to_index], false)
|
91
|
+
end
|
92
|
+
on(page_cls, &block)
|
93
|
+
end
|
94
|
+
|
95
|
+
#
|
96
|
+
# Navigate through a complete route.
|
97
|
+
#
|
98
|
+
# This method will navigate an entire route executing all of the
|
99
|
+
# methods. Since it completes the route it does not return any
|
100
|
+
# pages and it does not accept a block.
|
101
|
+
#
|
102
|
+
# @example
|
103
|
+
# page.navigate_all # will use the default path
|
104
|
+
# page.navigate_all(:using => :another_route)
|
105
|
+
#
|
106
|
+
# @param [Hash] how a hash that contains two elements. One with the key
|
107
|
+
# :using. This will be used to lookup the route. It has a
|
108
|
+
# default value of :default. The other is with the key :visit. This specifies
|
109
|
+
# whether to explicitly visit the first page. It has a default value of false.
|
110
|
+
#
|
111
|
+
def navigate_all(how = {:using => :default, :visit => false})
|
112
|
+
path = path_for how
|
113
|
+
navigate_through_pages(path[0..-1], how[:visit])
|
114
|
+
end
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
def path_for(how)
|
119
|
+
path = PageNavigation.cls.routes[how[:using]]
|
120
|
+
fail("PageFactory route :#{how[:using].to_s} not found") unless path
|
121
|
+
if PageNavigation.cls.route_data
|
122
|
+
file_to_load = PageNavigation.cls.route_data[how[:using]]
|
123
|
+
DataMagic.load "#{file_to_load.to_s}.yml" if file_to_load
|
124
|
+
end
|
125
|
+
path
|
126
|
+
end
|
127
|
+
|
128
|
+
def navigate_through_pages(pages, visit)
|
129
|
+
pages.each do |cls, method, *args|
|
130
|
+
page = visit ? visit(cls) : on(cls)
|
131
|
+
visit = false # visit once, for just the first page
|
132
|
+
fail("Navigation method '#{method}' not defined on #{cls}.") unless page.respond_to? method
|
133
|
+
page.send method unless args
|
134
|
+
page.send method, *args if args
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def find_index_for(path, item)
|
139
|
+
path.find_index { |each| each[0] == item}
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
@@ -0,0 +1,214 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
class FirstPage
|
6
|
+
end
|
7
|
+
|
8
|
+
class MiddlePage
|
9
|
+
end
|
10
|
+
|
11
|
+
class LastPage
|
12
|
+
end
|
13
|
+
|
14
|
+
class TestNavigator
|
15
|
+
include PageNavigation
|
16
|
+
attr_accessor :current_page
|
17
|
+
|
18
|
+
# placeholder for PageFactory's on_page (alias 'on')
|
19
|
+
def on(cls)
|
20
|
+
cls.new
|
21
|
+
end
|
22
|
+
|
23
|
+
# placeholder for PageFactory's visit_page (alias 'visit')
|
24
|
+
def visit(cls)
|
25
|
+
page_instance = cls.new
|
26
|
+
page_instance.visit
|
27
|
+
page_instance
|
28
|
+
end
|
29
|
+
|
30
|
+
def class_from_string(str)
|
31
|
+
str.split('::').inject(Object) do |mod, class_name|
|
32
|
+
mod.const_get(class_name)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe PageNavigation do
|
38
|
+
before(:each) do
|
39
|
+
@navigator = TestNavigator.new
|
40
|
+
allow(DataMagic).to receive(:load)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should raise an error when you do not provide a default route' do
|
44
|
+
expect { TestNavigator.routes = { another: [] } }.to raise_error 'You must provide a :default route'
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should store the routes' do
|
48
|
+
routes = %w[a b c]
|
49
|
+
TestNavigator.routes = { default: routes }
|
50
|
+
expect(TestNavigator.routes[:default]).to be routes
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should store route data' do
|
54
|
+
TestNavigator.route_data = { default: :blah }
|
55
|
+
expect(TestNavigator.route_data).to eq({ default: :blah })
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should navigate to a page calling the default methods' do
|
59
|
+
pages = [[FirstPage, :a_method], [MiddlePage, :b_method]]
|
60
|
+
TestNavigator.routes = { default: pages }
|
61
|
+
fake_page = double('middle_page')
|
62
|
+
expect(FirstPage).to receive(:new).and_return(fake_page)
|
63
|
+
expect(fake_page).to receive(:a_method)
|
64
|
+
expect(@navigator.navigate_to(MiddlePage).class).to be MiddlePage
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should load the DataMagic file when specified' do
|
68
|
+
pages = [[FirstPage, :a_method], [MiddlePage, :b_method]]
|
69
|
+
TestNavigator.routes = { default: pages }
|
70
|
+
TestNavigator.route_data = { default: :dm_file }
|
71
|
+
fake_page = double('middle_page')
|
72
|
+
expect(FirstPage).to receive(:new).and_return(fake_page)
|
73
|
+
expect(fake_page).to receive(:a_method)
|
74
|
+
expect(DataMagic).to receive(:load).with('dm_file.yml')
|
75
|
+
expect(@navigator.navigate_to(MiddlePage).class).to be MiddlePage
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should pass parameters to methods when navigating' do
|
79
|
+
pages = [[FirstPage, :a_method, 'blah'], [MiddlePage, :b_method]]
|
80
|
+
TestNavigator.routes = { default: pages }
|
81
|
+
fake_page = double('middle_page')
|
82
|
+
expect(FirstPage).to receive(:new).and_return(fake_page)
|
83
|
+
expect(fake_page).to receive(:a_method).with('blah')
|
84
|
+
expect(@navigator.navigate_to(MiddlePage).class).to be MiddlePage
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should fail when it does not find a proper route' do
|
88
|
+
TestNavigator.routes = { default: ['a'], another: ['b'] }
|
89
|
+
expect { @navigator.navigate_to(MiddlePage, using: :no_route) }.to raise_error
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should fail when no default method specified' do
|
93
|
+
TestNavigator.routes = {
|
94
|
+
default: [[FirstPage, :a_method], [MiddlePage, :b_method]]
|
95
|
+
}
|
96
|
+
fake_page = double('middle_page')
|
97
|
+
expect(FirstPage).to receive(:new).and_return(fake_page)
|
98
|
+
expect(fake_page).to receive(:respond_to?).with(:a_method).and_return(false)
|
99
|
+
expect { @navigator.navigate_to(MiddlePage) }.to raise_error
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should know how to continue routing from a location' do
|
103
|
+
first_page, middle_page, last_page = mock_common_method_calls
|
104
|
+
|
105
|
+
@navigator.current_page = FirstPage.new
|
106
|
+
|
107
|
+
expect(first_page).to receive(:a_method)
|
108
|
+
expect(middle_page).to receive(:b_method)
|
109
|
+
|
110
|
+
expect(@navigator.continue_navigation_to(LastPage).class).to be LastPage
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'should know how to continue routing from a location that is one page from the end' do
|
114
|
+
first_page, middle_page, last_page = mock_common_method_calls
|
115
|
+
|
116
|
+
@navigator.current_page = MiddlePage.new
|
117
|
+
|
118
|
+
expect(first_page).not_to receive(:a_method)
|
119
|
+
expect(middle_page).to receive(:b_method)
|
120
|
+
|
121
|
+
expect(@navigator.continue_navigation_to(LastPage).class).to be LastPage
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'should know how to navigate an entire route including the last page' do
|
125
|
+
first_page, middle_page, last_page = mock_common_method_calls
|
126
|
+
|
127
|
+
expect(first_page).to receive(:a_method)
|
128
|
+
expect(middle_page).to receive(:b_method)
|
129
|
+
expect(last_page).to receive(:c_method)
|
130
|
+
|
131
|
+
@navigator.navigate_all
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'should be able to start in the middle of a route and proceed' do
|
135
|
+
first_page, middle_page, last_page = mock_common_method_calls
|
136
|
+
|
137
|
+
expect(first_page).not_to receive(:a_method)
|
138
|
+
expect(middle_page).to receive(:b_method)
|
139
|
+
|
140
|
+
@navigator.navigate_to(LastPage, from: MiddlePage)
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'should visit page at start of route given visit param set to true' do
|
144
|
+
first_page, middle_page, last_page = mock_common_method_calls
|
145
|
+
|
146
|
+
expect(first_page).to receive(:visit)
|
147
|
+
expect(first_page).to receive(:a_method)
|
148
|
+
expect(middle_page).to receive(:b_method)
|
149
|
+
expect(middle_page).not_to receive(:visit)
|
150
|
+
|
151
|
+
@navigator.navigate_to(LastPage, visit: true)
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'should not visit page at start of route given visit param set to false (explicit)' do
|
155
|
+
first_page, middle_page, last_page = mock_common_method_calls
|
156
|
+
|
157
|
+
expect(first_page).not_to receive(:visit)
|
158
|
+
expect(first_page).to receive(:a_method)
|
159
|
+
expect(middle_page).to receive(:b_method)
|
160
|
+
|
161
|
+
@navigator.navigate_to(LastPage, visit: false)
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'should not visit page at start of route given visit param set to false (default)' do
|
165
|
+
first_page, middle_page, last_page = mock_common_method_calls
|
166
|
+
|
167
|
+
expect(first_page).not_to receive(:visit)
|
168
|
+
expect(first_page).to receive(:a_method)
|
169
|
+
expect(middle_page).to receive(:b_method)
|
170
|
+
|
171
|
+
@navigator.navigate_to(LastPage)
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'should handle specification of both using and visit params' do
|
175
|
+
first_page, middle_page, last_page = mock_common_method_calls
|
176
|
+
|
177
|
+
expect(first_page).to receive(:respond_to?).with(:x_method).at_least(:once).and_return(true)
|
178
|
+
expect(first_page).to receive(:visit)
|
179
|
+
expect(first_page).to receive(:x_method)
|
180
|
+
expect(middle_page).to receive(:respond_to?).with(:y_method).at_least(:once).and_return(true)
|
181
|
+
expect(middle_page).to receive(:y_method)
|
182
|
+
expect(middle_page).not_to receive(:visit)
|
183
|
+
|
184
|
+
@navigator.navigate_to(LastPage, visit: true, using: :alt)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def mock_common_method_calls
|
189
|
+
TestNavigator.routes = {
|
190
|
+
default: [[FirstPage, :a_method],
|
191
|
+
[MiddlePage, :b_method],
|
192
|
+
[LastPage, :c_method]],
|
193
|
+
alt: [[FirstPage, :x_method],
|
194
|
+
[MiddlePage, :y_method],
|
195
|
+
[LastPage, :z_method]]
|
196
|
+
}
|
197
|
+
|
198
|
+
first_page = FirstPage.new
|
199
|
+
allow(FirstPage).to receive(:new).and_return(first_page)
|
200
|
+
allow(first_page).to receive(:respond_to?).with(:visit).and_return(true)
|
201
|
+
allow(first_page).to receive(:respond_to?).with(:a_method).and_return(true)
|
202
|
+
|
203
|
+
middle_page = MiddlePage.new
|
204
|
+
allow(MiddlePage).to receive(:new).and_return(middle_page)
|
205
|
+
allow(middle_page).to receive(:respond_to?).with(:visit).and_return(true)
|
206
|
+
allow(middle_page).to receive(:respond_to?).with(:b_method).and_return(true)
|
207
|
+
|
208
|
+
last_page = LastPage.new
|
209
|
+
allow(LastPage).to receive(:new).and_return(last_page)
|
210
|
+
allow(last_page).to receive(:respond_to?).with(:visit).and_return(true)
|
211
|
+
allow(last_page).to receive(:respond_to?).with(:c_method).and_return(true)
|
212
|
+
|
213
|
+
[first_page, middle_page, last_page]
|
214
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: centric_page_navigation
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.12'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeffrey S. Morgan
|
8
|
+
- Dmitry Sharkov
|
9
|
+
- Joseph Ours
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2022-05-11 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: centric_data_magic
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ">="
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.2'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '1.2'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: rspec
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 3.4.0
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 3.4.0
|
43
|
+
description: Provides basic navigation through a collection of items that use the
|
44
|
+
PageObject pattern.
|
45
|
+
email:
|
46
|
+
- jeff.morgan@leandog.com
|
47
|
+
- joseph.ours@centricconsulting.com
|
48
|
+
executables: []
|
49
|
+
extensions: []
|
50
|
+
extra_rdoc_files: []
|
51
|
+
files:
|
52
|
+
- ".gitignore"
|
53
|
+
- ".rspec"
|
54
|
+
- ".ruby-gemset"
|
55
|
+
- ".ruby-version"
|
56
|
+
- ChangeLog
|
57
|
+
- Gemfile
|
58
|
+
- Guardfile
|
59
|
+
- LICENSE.txt
|
60
|
+
- README.md
|
61
|
+
- Rakefile
|
62
|
+
- centric_page_navigation.gemspec
|
63
|
+
- lib/page_navigation.rb
|
64
|
+
- lib/page_navigation/routes.rb
|
65
|
+
- lib/page_navigation/version.rb
|
66
|
+
- spec/lib/page_navigation_spec.rb
|
67
|
+
- spec/spec_helper.rb
|
68
|
+
homepage: http://github.com/centricconsulting/page_navigation
|
69
|
+
licenses: []
|
70
|
+
metadata: {}
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubygems_version: 3.3.7
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: Provides basic navigation through a collection of items that use the PageObject
|
90
|
+
pattern.
|
91
|
+
test_files:
|
92
|
+
- spec/lib/page_navigation_spec.rb
|
93
|
+
- spec/spec_helper.rb
|