page_navigation 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4 -1
- data/lib/page_navigation/version.rb +1 -1
- data/lib/page_navigation.rb +3 -2
- data/spec/lib/page_navigation_spec.rb +20 -3
- metadata +4 -4
data/ChangeLog
CHANGED
data/lib/page_navigation.rb
CHANGED
@@ -73,9 +73,10 @@ module PageNavigation
|
|
73
73
|
#
|
74
74
|
def continue_navigation_to(page_cls, how = {:using => :default}, &block)
|
75
75
|
path = path_for how
|
76
|
-
from_index = find_index_for(path, @current_page.class)
|
76
|
+
from_index = find_index_for(path, @current_page.class)
|
77
77
|
to_index = find_index_for(path, page_cls)-1
|
78
|
-
navigate_through_pages(path[from_index
|
78
|
+
navigate_through_pages([path[from_index]]) if from_index == to_index
|
79
|
+
navigate_through_pages(path[from_index..to_index]) unless from_index == to_index
|
79
80
|
on(page_cls, &block)
|
80
81
|
end
|
81
82
|
|
@@ -78,12 +78,29 @@ describe PageNavigation do
|
|
78
78
|
[AnotherPage, :b_method],
|
79
79
|
[YetAnotherPage, :c_method]]
|
80
80
|
}
|
81
|
-
|
81
|
+
@navigator.current_page = FactoryTestPage.new
|
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
|
+
a_page = AnotherPage.new
|
87
|
+
AnotherPage.should_receive(:new).and_return(a_page)
|
88
|
+
a_page.should_receive(:respond_to?).with(:b_method).and_return(true)
|
89
|
+
a_page.should_receive(:b_method)
|
90
|
+
@navigator.continue_navigation_to(YetAnotherPage).class.should == YetAnotherPage
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should know how to continue routng from a location that is one page from the end" do
|
94
|
+
TestNavigator.routes = {
|
95
|
+
:default => [[FactoryTestPage, :a_method],
|
96
|
+
[AnotherPage, :b_method],
|
97
|
+
[YetAnotherPage, :c_method]]
|
98
|
+
}
|
99
|
+
@navigator.current_page = AnotherPage.new
|
100
|
+
fake_page = AnotherPage.new
|
82
101
|
AnotherPage.should_receive(:new).and_return(fake_page)
|
83
102
|
fake_page.should_receive(:respond_to?).with(:b_method).and_return(true)
|
84
103
|
fake_page.should_receive(:b_method)
|
85
|
-
@navigator.current_page = FactoryTestPage.new
|
86
|
-
FactoryTestPage.should_not_receive(:new)
|
87
104
|
@navigator.continue_navigation_to(YetAnotherPage).class.should == YetAnotherPage
|
88
105
|
end
|
89
106
|
end
|
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.3'
|
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-
|
12
|
+
date: 2013-01-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -63,7 +63,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
63
63
|
version: '0'
|
64
64
|
segments:
|
65
65
|
- 0
|
66
|
-
hash:
|
66
|
+
hash: -751630789489587890
|
67
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
68
|
none: false
|
69
69
|
requirements:
|
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
72
|
version: '0'
|
73
73
|
segments:
|
74
74
|
- 0
|
75
|
-
hash:
|
75
|
+
hash: -751630789489587890
|
76
76
|
requirements: []
|
77
77
|
rubyforge_project: page_naigation
|
78
78
|
rubygems_version: 1.8.24
|