semantic_navigation 0.1.9 → 0.2.1
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.
- checksums.yaml +4 -4
- data/lib/semantic_navigation/helper_methods.rb +1 -1
- data/lib/semantic_navigation/railtie.rb +3 -1
- data/lib/semantic_navigation/version.rb +1 -1
- data/spec/lib/semantic_navigation/configuration_spec.rb +12 -12
- data/spec/lib/semantic_navigation/core/leaf_spec.rb +21 -15
- data/spec/lib/semantic_navigation/core/navigation_spec.rb +51 -39
- data/spec/lib/semantic_navigation/core/node_spec.rb +15 -15
- data/spec/lib/semantic_navigation/helper_methods_spec.rb +1 -1
- data/spec/lib/semantic_navigation/renderers/deprecations_spec.rb +4 -10
- data/spec/spec_helper.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 216bc40dad2085d5902d0b24ad7a1b3546f85d50
|
4
|
+
data.tar.gz: a6c3fb15468b760f1b59a248b22ba5cea9c56009
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 372129da53b76e11bf4bd3c199246629b0c23f0abcd63a0e612ebf64f6c69de87b52fc59505f50991896a2b66452f7dd35e01e8ba74b1af4a3db3c3ce62fd6c4
|
7
|
+
data.tar.gz: 8f4e7d2972a64454e941728685e3b8f1203b8da10ea141df9dba9b538d9abece3e8f6d4960fad82d7ac8555f75de57c60d61fa8d56646cd9c0e59e183b46a56c
|
@@ -37,7 +37,9 @@ module SemanticNavigation
|
|
37
37
|
SemanticNavigation::Railtie.register_bootstrap_renderers
|
38
38
|
}
|
39
39
|
else
|
40
|
-
ActionDispatch::Callbacks.
|
40
|
+
ActionDispatch::Callbacks.to_prepare {
|
41
|
+
require 'pry'
|
42
|
+
binding.pry
|
41
43
|
load SemanticNavigation.actual_config_location
|
42
44
|
SemanticNavigation::Railtie.register_bootstrap_renderers
|
43
45
|
}
|
@@ -39,7 +39,7 @@ describe SemanticNavigation::Configuration do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'passes received block to navigation class instance' do
|
42
|
-
navigation =
|
42
|
+
navigation = double
|
43
43
|
navigation.should_receive(:instance_eval)
|
44
44
|
SemanticNavigation::Core::Navigation.should_receive(:new).and_return navigation
|
45
45
|
SemanticNavigation::Configuration.navigate :some_menu do
|
@@ -72,10 +72,10 @@ describe SemanticNavigation::Configuration do
|
|
72
72
|
styles = SemanticNavigation::Configuration.class_variable_get("@@render_styles")
|
73
73
|
styles[:some_renderer].should == proc_object
|
74
74
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
75
|
+
double_renderer = double
|
76
|
+
double_renderer.should_receive(:do_something1).with(true)
|
77
|
+
double_renderer.should_receive(:do_something2).with('some_attr')
|
78
|
+
double_renderer.instance_eval &proc_object
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
@@ -108,13 +108,13 @@ describe SemanticNavigation::Configuration do
|
|
108
108
|
|
109
109
|
it 'registers a new helper method based on name of a renderer and depending on method navigation_for' do
|
110
110
|
SemanticNavigation::Configuration.register_renderer SomeRenderer
|
111
|
-
SemanticNavigation::HelperMethods.
|
111
|
+
expect(SemanticNavigation::HelperMethods).to be_method_defined(:some_renderer_for)
|
112
112
|
|
113
113
|
class SomeClass
|
114
114
|
include SemanticNavigation::HelperMethods
|
115
115
|
end
|
116
116
|
some_class_instance = SomeClass.new
|
117
|
-
some_class_instance.
|
117
|
+
expect(some_class_instance).to receive(:navigation_for).with(:some_menu, {as: :some_renderer})
|
118
118
|
|
119
119
|
some_class_instance.some_renderer_for :some_menu
|
120
120
|
end
|
@@ -123,11 +123,11 @@ describe SemanticNavigation::Configuration do
|
|
123
123
|
describe '#render' do
|
124
124
|
|
125
125
|
before :each do
|
126
|
-
@view_object =
|
127
|
-
@renderer =
|
128
|
-
@renderer_instance =
|
126
|
+
@view_object = double
|
127
|
+
@renderer = double
|
128
|
+
@renderer_instance = double
|
129
129
|
@renderer.should_receive(:new).and_return @renderer_instance
|
130
|
-
@navigation =
|
130
|
+
@navigation = double
|
131
131
|
|
132
132
|
SemanticNavigation::Configuration.class_variable_set "@@renderers", {:renderer => @renderer}
|
133
133
|
SemanticNavigation::Configuration.class_variable_set "@@navigations", {:some_menu => @navigation}
|
@@ -151,7 +151,7 @@ describe SemanticNavigation::Configuration do
|
|
151
151
|
it 'execs default renderer styles from configuration' do
|
152
152
|
render_styles = proc{}
|
153
153
|
SemanticNavigation::Configuration.class_variable_set "@@render_styles", {:renderer => render_styles}
|
154
|
-
@renderer_instance.
|
154
|
+
expect(@renderer_instance).to receive(:instance_eval)
|
155
155
|
@renderer_instance.should_receive(:name=).with(:renderer)
|
156
156
|
@navigation.should_receive(:mark_active)
|
157
157
|
@navigation.should_receive(:render).with(@renderer_instance)
|
@@ -89,8 +89,8 @@ describe SemanticNavigation::Core::Leaf do
|
|
89
89
|
describe '#mark_active' do
|
90
90
|
|
91
91
|
before :each do
|
92
|
-
@view_object =
|
93
|
-
SemanticNavigation::Configuration.
|
92
|
+
@view_object = double
|
93
|
+
allow(SemanticNavigation::Configuration).to receive(:view_object).and_return @view_object
|
94
94
|
end
|
95
95
|
|
96
96
|
context :marked do
|
@@ -98,50 +98,56 @@ describe SemanticNavigation::Core::Leaf do
|
|
98
98
|
it 'as active even if controller name starts from `/`' do
|
99
99
|
leaf = SemanticNavigation::Core::Leaf.new({url: {controller: '/first', action: 'index'}}, 1)
|
100
100
|
@view_object.stub(:params).and_return({controller: 'first', action: 'index'})
|
101
|
-
|
102
|
-
leaf.
|
101
|
+
|
102
|
+
expect(leaf.mark_active).to eq true
|
103
|
+
expect(leaf.active).to eq true
|
103
104
|
end
|
104
105
|
|
105
106
|
it 'as active if have active url with symbol names' do
|
106
107
|
leaf = SemanticNavigation::Core::Leaf.new({:url => {:controller => :first, :action => :index}}, 1)
|
107
108
|
@view_object.stub(:params).and_return({:controller => 'first', :action => 'index'})
|
108
|
-
|
109
|
-
leaf.
|
109
|
+
|
110
|
+
expect(leaf.mark_active).to eq true
|
111
|
+
expect(leaf.active).to eq true
|
110
112
|
end
|
111
113
|
|
112
114
|
it 'as active if have active url with string names' do
|
113
115
|
leaf = SemanticNavigation::Core::Leaf.new({:url => {:controller => "first", :action => "index"}}, 1)
|
114
116
|
@view_object.stub(:params).and_return({:controller => 'first', :action => 'index'})
|
115
|
-
|
116
|
-
leaf.
|
117
|
+
|
118
|
+
expect(leaf.mark_active).to eq true
|
119
|
+
expect(leaf.active).to eq true
|
117
120
|
end
|
118
121
|
|
119
122
|
it 'as inactive if have inactive url with symbol names' do
|
120
123
|
leaf = SemanticNavigation::Core::Leaf.new({:url => {:controller => :first, :action => :index}}, 1)
|
121
124
|
@view_object.stub(:params).and_return({controller: "second", action: 'index'})
|
122
|
-
leaf.mark_active.
|
123
|
-
leaf.active.
|
125
|
+
expect(leaf.mark_active).to eq false
|
126
|
+
expect(leaf.active).to eq false
|
124
127
|
end
|
125
128
|
|
126
129
|
it 'as inactive if have inactive url with string names' do
|
127
130
|
leaf = SemanticNavigation::Core::Leaf.new({:url => {:controller => "first", :action => "index"}}, 1)
|
128
131
|
@view_object.stub(:params).and_return({controller: "second", action: 'index'})
|
129
|
-
|
130
|
-
leaf.
|
132
|
+
|
133
|
+
expect(leaf.mark_active).to eq false
|
134
|
+
expect(leaf.active).to eq false
|
131
135
|
end
|
132
136
|
|
133
137
|
it 'as inactive if have nil url' do
|
134
138
|
leaf = SemanticNavigation::Core::Leaf.new({},1)
|
135
|
-
|
136
|
-
leaf.
|
139
|
+
|
140
|
+
expect(leaf.mark_active).to eq false
|
141
|
+
expect(leaf.active).to eq false
|
137
142
|
end
|
138
143
|
|
139
144
|
it 'as active if at least one url in passed array is active' do
|
140
145
|
leaf = SemanticNavigation::Core::Leaf.new({:url => [{:controller => :leaf_controller1, :action => :action},
|
141
146
|
{:controller => :leaf_controller2, :action => :action}]},1)
|
142
147
|
@view_object.stub(:params).and_return(:controller => 'leaf_controller2', :action => 'action')
|
148
|
+
|
143
149
|
leaf.mark_active
|
144
|
-
leaf.active.
|
150
|
+
expect(leaf.active).to eq true
|
145
151
|
end
|
146
152
|
|
147
153
|
end
|
@@ -7,19 +7,22 @@ describe SemanticNavigation::Core::Navigation do
|
|
7
7
|
it 'creates instance of navigation with level 0 and empty subitems' do
|
8
8
|
navigation = SemanticNavigation::Core::Navigation.new({})
|
9
9
|
navigation.level.should == 0
|
10
|
-
|
10
|
+
|
11
|
+
expect(navigation.sub_elements).to be_empty
|
11
12
|
end
|
12
13
|
|
13
14
|
it 'creates instance and save sended options' do
|
14
15
|
navigation = SemanticNavigation::Core::Navigation.new :id => :some_id,
|
15
16
|
:classes => [:one, :two]
|
16
17
|
navigation.id.should == :some_id
|
17
|
-
|
18
|
+
|
19
|
+
expect(navigation.classes).to eq [:one, :two]
|
18
20
|
end
|
19
21
|
|
20
22
|
it 'creates instance and save unintended properties' do
|
21
23
|
navigation = SemanticNavigation::Core::Navigation.new :some_attribute => :some_value
|
22
|
-
|
24
|
+
|
25
|
+
expect(navigation.instance_variable_get("@some_attribute")).to eq :some_value
|
23
26
|
end
|
24
27
|
|
25
28
|
end
|
@@ -32,7 +35,8 @@ describe SemanticNavigation::Core::Navigation do
|
|
32
35
|
it "receives item method and make the leaf" do
|
33
36
|
@navigation.item :some_id, 'some_url'
|
34
37
|
@navigation.sub_elements.size.should == 1
|
35
|
-
|
38
|
+
|
39
|
+
expect(@navigation.sub_elements.first).to be_is_a(SemanticNavigation::Core::Leaf)
|
36
40
|
end
|
37
41
|
|
38
42
|
it "receives item method with block and create node" do
|
@@ -40,27 +44,31 @@ describe SemanticNavigation::Core::Navigation do
|
|
40
44
|
item :leaf_id, 'leaf_url'
|
41
45
|
end
|
42
46
|
@navigation.sub_elements.size.should == 1
|
43
|
-
|
47
|
+
|
48
|
+
expect(@navigation.sub_elements.first).to be_is_a(SemanticNavigation::Core::Node)
|
44
49
|
end
|
45
50
|
|
46
51
|
it "receives item method with array of urls and save them properly" do
|
47
52
|
@navigation.item :leaf_id, ['string/url',"controller#action",:symbolic_name,['array','like','url']]
|
48
53
|
urls = @navigation.sub_elements.first.instance_variable_get("@url")
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
54
|
+
|
55
|
+
expect(urls).to eq ['string/url',
|
56
|
+
{:controller => 'controller', :action => 'action'},
|
57
|
+
:symbolic_name,
|
58
|
+
['array','like','url']]
|
53
59
|
end
|
54
60
|
|
55
61
|
it "receives item with Proc url and decode it to normal url (leaf)" do
|
56
62
|
@navigation.item :leaf_id, proc{'some' + 'func'}
|
57
|
-
|
63
|
+
|
64
|
+
expect(@navigation.sub_elements.first.url).to eq 'somefunc'
|
58
65
|
end
|
59
66
|
|
60
67
|
it 'receives item with array of urls one of each is a Proc (leaf)' do
|
61
68
|
@navigation.item :leaf_id, ['string_url',proc{'some' + 'func'}]
|
62
69
|
urls = @navigation.sub_elements.first.send :urls
|
63
|
-
|
70
|
+
|
71
|
+
expect(urls).to eq ['string_url', 'somefunc']
|
64
72
|
end
|
65
73
|
|
66
74
|
it "receives item with Proc url and decode it to normal url (node)" do
|
@@ -68,7 +76,8 @@ describe SemanticNavigation::Core::Navigation do
|
|
68
76
|
item :first_value, '#'
|
69
77
|
item :second_value, '#'
|
70
78
|
end
|
71
|
-
|
79
|
+
|
80
|
+
expect(@navigation.sub_elements.first.url).to eq 'somefunc'
|
72
81
|
end
|
73
82
|
|
74
83
|
it 'receives item with array of urls one of each is a Proc (node)' do
|
@@ -77,7 +86,8 @@ describe SemanticNavigation::Core::Navigation do
|
|
77
86
|
item :second_value, '#'
|
78
87
|
end
|
79
88
|
urls = @navigation.sub_elements.first.send :urls
|
80
|
-
|
89
|
+
|
90
|
+
expect(urls).to eq ['string_url', 'somefunc']
|
81
91
|
end
|
82
92
|
end
|
83
93
|
|
@@ -88,8 +98,8 @@ describe SemanticNavigation::Core::Navigation do
|
|
88
98
|
end
|
89
99
|
|
90
100
|
it "creates item with nil url" do
|
91
|
-
@navigation.sub_elements.size.
|
92
|
-
@navigation.sub_elements.first.url.
|
101
|
+
expect(@navigation.sub_elements.size).to eq 1
|
102
|
+
expect(@navigation.sub_elements.first.url).to be_nil
|
93
103
|
end
|
94
104
|
end
|
95
105
|
|
@@ -100,18 +110,18 @@ describe SemanticNavigation::Core::Navigation do
|
|
100
110
|
|
101
111
|
it "creates divider item with nil url and name" do
|
102
112
|
@navigation.divider
|
103
|
-
@navigation.sub_elements.size.
|
104
|
-
@navigation.sub_elements.first.url.
|
105
|
-
@navigation.sub_elements.first.name.
|
113
|
+
expect(@navigation.sub_elements.size).to eq 1
|
114
|
+
expect(@navigation.sub_elements.first.url).to be_nil
|
115
|
+
expect(@navigation.sub_elements.first.name).to be_empty
|
106
116
|
end
|
107
117
|
|
108
118
|
it "receives any length method containing char `_` and create divider" do
|
109
|
-
|
110
119
|
(1..10).each do |c|
|
111
120
|
@navigation.send ('_'*c).to_sym
|
112
121
|
end
|
113
|
-
|
114
|
-
@navigation.sub_elements.
|
122
|
+
|
123
|
+
expect(@navigation.sub_elements.size).to eq 10
|
124
|
+
expect(@navigation.sub_elements.map(&:id)).to eq [:divider]*10
|
115
125
|
end
|
116
126
|
end
|
117
127
|
|
@@ -122,11 +132,12 @@ describe SemanticNavigation::Core::Navigation do
|
|
122
132
|
end
|
123
133
|
|
124
134
|
it "while creating the item make support for urls in format controller#action" do
|
125
|
-
view_object =
|
135
|
+
view_object = double
|
126
136
|
|
127
137
|
@navigation.item :some_id, 'controller#action'
|
128
138
|
@navigation.sub_elements.size.should == 1
|
129
|
-
|
139
|
+
|
140
|
+
expect(@navigation.sub_elements.first.url).to eq({:controller => "controller", :action => "action"})
|
130
141
|
end
|
131
142
|
end
|
132
143
|
|
@@ -134,17 +145,18 @@ describe SemanticNavigation::Core::Navigation do
|
|
134
145
|
context :returns do
|
135
146
|
it 'true if render_if proc is nil' do
|
136
147
|
navigation = SemanticNavigation::Core::Navigation.new({})
|
137
|
-
|
148
|
+
|
149
|
+
expect(navigation.render_if).to eq true
|
138
150
|
end
|
139
151
|
|
140
152
|
it 'true if render_if proc return true' do
|
141
153
|
navigation = SemanticNavigation::Core::Navigation.new({:render_if => proc{true}})
|
142
|
-
navigation.render_if.
|
154
|
+
expect(navigation.render_if).to eq true
|
143
155
|
end
|
144
156
|
|
145
157
|
it 'false if render_if proc return false' do
|
146
158
|
navigation = SemanticNavigation::Core::Navigation.new({:render_if => proc{false}})
|
147
|
-
navigation.render_if.
|
159
|
+
expect(navigation.render_if).to eq false
|
148
160
|
end
|
149
161
|
|
150
162
|
end
|
@@ -152,16 +164,16 @@ describe SemanticNavigation::Core::Navigation do
|
|
152
164
|
context :passes do
|
153
165
|
it 'self to passed proc' do
|
154
166
|
navigation = SemanticNavigation::Core::Navigation.new({:id => :some_id, :render_if => proc{|o| o.id == :some_id}})
|
155
|
-
navigation.render_if.
|
167
|
+
expect(navigation.render_if).to eq true
|
156
168
|
navigation = SemanticNavigation::Core::Navigation.new({:id => :another_id, :render_if => proc{|o| o.id == :some_id}})
|
157
|
-
navigation.render_if.
|
169
|
+
expect(navigation.render_if).to eq false
|
158
170
|
end
|
159
171
|
end
|
160
172
|
end
|
161
173
|
|
162
174
|
describe '#render' do
|
163
175
|
it 'calls renderer class :render_navigation method' do
|
164
|
-
renderer =
|
176
|
+
renderer = double
|
165
177
|
navigation = SemanticNavigation::Core::Navigation.new({})
|
166
178
|
renderer.should_receive(:render_navigation).with(navigation)
|
167
179
|
navigation.render(renderer)
|
@@ -172,7 +184,7 @@ describe SemanticNavigation::Core::Navigation do
|
|
172
184
|
before :each do
|
173
185
|
@navigation = SemanticNavigation::Core::Navigation.new({})
|
174
186
|
|
175
|
-
@view_object =
|
187
|
+
@view_object = double
|
176
188
|
SemanticNavigation::Configuration.stub(:view_object).and_return @view_object
|
177
189
|
end
|
178
190
|
|
@@ -205,8 +217,8 @@ describe SemanticNavigation::Core::Navigation do
|
|
205
217
|
@view_object.stub(:params).and_return({:controller => "controller1", :action => "action", :some_other_params => "blablabla"})
|
206
218
|
|
207
219
|
@navigation.mark_active
|
208
|
-
@navigation.sub_elements[0].active.
|
209
|
-
@navigation.sub_elements[1].active.
|
220
|
+
expect(@navigation.sub_elements[0].active).to eq true
|
221
|
+
expect(@navigation.sub_elements[1].active).to eq false
|
210
222
|
end
|
211
223
|
|
212
224
|
it 'works for route like urls as good as for Hash url params' do
|
@@ -215,8 +227,8 @@ describe SemanticNavigation::Core::Navigation do
|
|
215
227
|
@view_object.stub(:params).and_return({:controller => "controller1", :action => "action", :some_other_params => "blablabla"})
|
216
228
|
|
217
229
|
@navigation.mark_active
|
218
|
-
@navigation.sub_elements[0].active.
|
219
|
-
@navigation.sub_elements[1].active.
|
230
|
+
expect(@navigation.sub_elements[0].active).to eq true
|
231
|
+
expect(@navigation.sub_elements[1].active).to eq false
|
220
232
|
end
|
221
233
|
|
222
234
|
end
|
@@ -225,7 +237,7 @@ describe SemanticNavigation::Core::Navigation do
|
|
225
237
|
before :each do
|
226
238
|
@navigation = SemanticNavigation::Core::Navigation.new({})
|
227
239
|
|
228
|
-
@view_object =
|
240
|
+
@view_object = double
|
229
241
|
SemanticNavigation::Configuration.stub(:view_object).and_return @view_object
|
230
242
|
end
|
231
243
|
|
@@ -287,7 +299,7 @@ describe SemanticNavigation::Core::Navigation do
|
|
287
299
|
|
288
300
|
|
289
301
|
it "scopes the creating items options" do
|
290
|
-
some_condition =
|
302
|
+
some_condition = double
|
291
303
|
@navigation.scope :render_if => some_condition do
|
292
304
|
item :first_item, "controller1#action"
|
293
305
|
item :second_item, "controller2#action"
|
@@ -299,7 +311,7 @@ describe SemanticNavigation::Core::Navigation do
|
|
299
311
|
end
|
300
312
|
|
301
313
|
it "doesnt scope unscoped items" do
|
302
|
-
some_condition =
|
314
|
+
some_condition = double
|
303
315
|
@navigation.scope render_if: some_condition do
|
304
316
|
item :first_item, "controller1#action"
|
305
317
|
item :second_item, "controller2#action"
|
@@ -311,8 +323,8 @@ describe SemanticNavigation::Core::Navigation do
|
|
311
323
|
end
|
312
324
|
|
313
325
|
it "doesnt override defined scopes" do
|
314
|
-
some_condition =
|
315
|
-
some_condition2 =
|
326
|
+
some_condition = double
|
327
|
+
some_condition2 = double
|
316
328
|
@navigation.scope :render_if => some_condition do
|
317
329
|
item :first_item, "controller1#action", render_if: some_condition2
|
318
330
|
item :second_item, "controller2#action"
|
@@ -64,7 +64,7 @@ describe SemanticNavigation::Core::Node do
|
|
64
64
|
@node = SemanticNavigation::Core::Node.new({:url => [{:controller => :node_controller, :action => :action},
|
65
65
|
{:controller => :node_controller2, :action => :action}]},1)
|
66
66
|
|
67
|
-
@view_object =
|
67
|
+
@view_object = double
|
68
68
|
@view_object.stub(:params).and_return({:action => "some", :action => "some"})
|
69
69
|
SemanticNavigation::Configuration.stub(:view_object).and_return @view_object
|
70
70
|
end
|
@@ -73,7 +73,7 @@ describe SemanticNavigation::Core::Node do
|
|
73
73
|
|
74
74
|
it '@active variable to false if no active sub_elements and node url is not active' do
|
75
75
|
@node.mark_active
|
76
|
-
@node.instance_variable_get("@active").
|
76
|
+
expect(@node.instance_variable_get("@active")).to eq false
|
77
77
|
end
|
78
78
|
|
79
79
|
it '@active variable to true if at least one sub_element is active' do
|
@@ -83,9 +83,9 @@ describe SemanticNavigation::Core::Node do
|
|
83
83
|
@view_object.should_receive(:current_page?).with('222').and_return false
|
84
84
|
|
85
85
|
@node.mark_active
|
86
|
-
@node.sub_elements[0].active.
|
87
|
-
@node.sub_elements[1].active.
|
88
|
-
@node.active.
|
86
|
+
expect(@node.sub_elements[0].active).to eq true
|
87
|
+
expect(@node.sub_elements[1].active).to eq false
|
88
|
+
expect(@node.active).to eq true
|
89
89
|
end
|
90
90
|
|
91
91
|
it '@active variable to false if all sub_elements is unactive' do
|
@@ -95,9 +95,9 @@ describe SemanticNavigation::Core::Node do
|
|
95
95
|
@view_object.should_receive(:current_page?).with('444').and_return false
|
96
96
|
|
97
97
|
@node.mark_active
|
98
|
-
@node.sub_elements[0].active.
|
99
|
-
@node.sub_elements[1].active.
|
100
|
-
@node.active.
|
98
|
+
expect(@node.sub_elements[0].active).to eq false
|
99
|
+
expect(@node.sub_elements[1].active).to eq false
|
100
|
+
expect(@node.active).to eq false
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
@@ -107,9 +107,9 @@ describe SemanticNavigation::Core::Node do
|
|
107
107
|
@view_object.stub(:params).and_return({:controller => "controller1", :action => "action", :some_other_params => "blablabla"})
|
108
108
|
|
109
109
|
@node.mark_active
|
110
|
-
@node.sub_elements[0].active.
|
111
|
-
@node.sub_elements[1].active.
|
112
|
-
@node.active.
|
110
|
+
expect(@node.sub_elements[0].active).to eq true
|
111
|
+
expect(@node.sub_elements[1].active).to eq false
|
112
|
+
expect(@node.active).to eq true
|
113
113
|
end
|
114
114
|
|
115
115
|
it 'works for route like urls as good as for Hash url params' do
|
@@ -118,15 +118,15 @@ describe SemanticNavigation::Core::Node do
|
|
118
118
|
@view_object.stub(:params).and_return({:controller => "controller1", :action => "action", :some_other_params => "blablabla"})
|
119
119
|
|
120
120
|
@node.mark_active
|
121
|
-
@node.sub_elements[0].active.
|
122
|
-
@node.sub_elements[1].active.
|
123
|
-
@node.active.
|
121
|
+
expect(@node.sub_elements[0].active).to eq true
|
122
|
+
expect(@node.sub_elements[1].active).to eq false
|
123
|
+
expect(@node.active).to eq true
|
124
124
|
end
|
125
125
|
|
126
126
|
it 'is active if at least one url in passed array is active' do
|
127
127
|
@view_object.stub(:params).and_return(:controller => 'node_controller2', :action => 'action')
|
128
128
|
@node.mark_active
|
129
|
-
@node.active.
|
129
|
+
expect(@node.active).to eq true
|
130
130
|
end
|
131
131
|
|
132
132
|
it 'accepts array like urls with other urls' do
|
@@ -11,7 +11,7 @@ describe SemanticNavigation::HelperMethods do
|
|
11
11
|
describe "#navigation_for" do
|
12
12
|
|
13
13
|
before :each do
|
14
|
-
SemanticNavigation::Configuration.
|
14
|
+
allow(SemanticNavigation::Configuration).to receive(:new).and_return (@config_instance = double)
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'default renderer is :list' do
|
@@ -17,10 +17,8 @@ describe 'SemanticNavigation::Deprecations' do
|
|
17
17
|
puts e
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
21
|
-
(SomeRenderer.
|
22
|
-
SemanticNavigation::Renderers::MixIn::RenderHelpers
|
23
|
-
) rescue false).should be_true
|
20
|
+
|
21
|
+
expect(SomeRenderer).to be_include(SemanticNavigation::Renderers::MixIn::RenderHelpers)
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
@@ -38,9 +36,7 @@ describe 'SemanticNavigation::Deprecations' do
|
|
38
36
|
end
|
39
37
|
end
|
40
38
|
|
41
|
-
(SomeRenderer.
|
42
|
-
SemanticNavigation::Renderers::MixIn::ActsAsBreadcrumb
|
43
|
-
) rescue false).should be_true
|
39
|
+
expect(SomeRenderer).to be_include(SemanticNavigation::Renderers::MixIn::ActsAsBreadcrumb)
|
44
40
|
end
|
45
41
|
end
|
46
42
|
|
@@ -58,9 +54,7 @@ describe 'SemanticNavigation::Deprecations' do
|
|
58
54
|
end
|
59
55
|
end
|
60
56
|
|
61
|
-
(SomeRenderer.
|
62
|
-
SemanticNavigation::Renderers::MixIn::ActsAsList
|
63
|
-
) rescue false).should be_true
|
57
|
+
expect(SomeRenderer).to be_include(SemanticNavigation::Renderers::MixIn::ActsAsList)
|
64
58
|
end
|
65
59
|
end
|
66
60
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: semantic_navigation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Gribovski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|