page_navigation 0.4 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +3 -0
- data/Gemfile +4 -0
- data/Guardfile +9 -0
- data/lib/page_navigation.rb +11 -4
- data/lib/page_navigation/version.rb +1 -1
- data/spec/lib/page_navigation_spec.rb +1 -4
- metadata +5 -4
data/ChangeLog
CHANGED
data/Gemfile
CHANGED
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/lib/page_navigation.rb
CHANGED
@@ -56,7 +56,11 @@ module PageNavigation
|
|
56
56
|
def navigate_to(page_cls, how = {:using => :default}, &block)
|
57
57
|
path = path_for how
|
58
58
|
to_index = find_index_for(path, page_cls)-1
|
59
|
-
|
59
|
+
if to_index == -1
|
60
|
+
return on(page_cls, &block)
|
61
|
+
else
|
62
|
+
navigate_through_pages(path[0..to_index])
|
63
|
+
end
|
60
64
|
on(page_cls, &block)
|
61
65
|
end
|
62
66
|
|
@@ -73,10 +77,13 @@ module PageNavigation
|
|
73
77
|
#
|
74
78
|
def continue_navigation_to(page_cls, how = {:using => :default}, &block)
|
75
79
|
path = path_for how
|
76
|
-
from_index = find_index_for(path, @current_page.class)
|
80
|
+
from_index = find_index_for(path, @current_page.class)+1
|
77
81
|
to_index = find_index_for(path, page_cls)-1
|
78
|
-
|
79
|
-
|
82
|
+
if from_index == to_index
|
83
|
+
navigate_through_pages([path[from_index]])
|
84
|
+
else
|
85
|
+
navigate_through_pages(path[from_index..to_index])
|
86
|
+
end
|
80
87
|
on(page_cls, &block)
|
81
88
|
end
|
82
89
|
|
@@ -80,9 +80,6 @@ describe PageNavigation do
|
|
80
80
|
}
|
81
81
|
@navigator.current_page = FactoryTestPage.new
|
82
82
|
f_page = FactoryTestPage.new
|
83
|
-
FactoryTestPage.should_receive(:new).and_return(f_page)
|
84
|
-
f_page.should_receive(:respond_to?).with(:a_method).and_return(true)
|
85
|
-
f_page.should_receive(:a_method)
|
86
83
|
a_page = AnotherPage.new
|
87
84
|
AnotherPage.should_receive(:new).and_return(a_page)
|
88
85
|
a_page.should_receive(:respond_to?).with(:b_method).and_return(true)
|
@@ -96,7 +93,7 @@ describe PageNavigation do
|
|
96
93
|
[AnotherPage, :b_method],
|
97
94
|
[YetAnotherPage, :c_method]]
|
98
95
|
}
|
99
|
-
@navigator.current_page =
|
96
|
+
@navigator.current_page = FactoryTestPage.new
|
100
97
|
fake_page = AnotherPage.new
|
101
98
|
AnotherPage.should_receive(:new).and_return(fake_page)
|
102
99
|
fake_page.should_receive(:respond_to?).with(:b_method).and_return(true)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: page_navigation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.5'
|
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-
|
12
|
+
date: 2013-02-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- .rvmrc
|
41
41
|
- ChangeLog
|
42
42
|
- Gemfile
|
43
|
+
- Guardfile
|
43
44
|
- LICENSE.txt
|
44
45
|
- README.md
|
45
46
|
- Rakefile
|
@@ -63,7 +64,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
63
64
|
version: '0'
|
64
65
|
segments:
|
65
66
|
- 0
|
66
|
-
hash: -
|
67
|
+
hash: -3548323590874822099
|
67
68
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
69
|
none: false
|
69
70
|
requirements:
|
@@ -72,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
73
|
version: '0'
|
73
74
|
segments:
|
74
75
|
- 0
|
75
|
-
hash: -
|
76
|
+
hash: -3548323590874822099
|
76
77
|
requirements: []
|
77
78
|
rubyforge_project: page_naigation
|
78
79
|
rubygems_version: 1.8.24
|