simple-navigation 4.0.3 → 4.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.travis.yml +20 -9
- data/CHANGELOG.md +29 -2
- data/LICENSE +1 -1
- data/README.md +31 -8
- data/Rakefile +28 -2
- data/gemfiles/rails-3-2-stable.gemfile +1 -0
- data/gemfiles/rails-4-1-stable.gemfile +1 -0
- data/gemfiles/rails-4-2-stable.gemfile +1 -1
- data/gemfiles/rails-5-2-stable.gemfile +7 -0
- data/gemfiles/rails-6-0-stable.gemfile +9 -0
- data/gemfiles/rails-6-1-stable.gemfile +9 -0
- data/generators/navigation_config/templates/config/navigation.rb +3 -2
- data/lib/simple_navigation.rb +1 -1
- data/lib/simple_navigation/adapters/rails.rb +15 -0
- data/lib/simple_navigation/item.rb +1 -0
- data/lib/simple_navigation/item_container.rb +3 -1
- data/lib/simple_navigation/version.rb +1 -1
- data/simple-navigation.gemspec +2 -2
- data/spec/fake_app/config/navigation.rb +2 -2
- data/spec/initializers/have_css_matcher.rb +2 -1
- data/spec/integration/rendering_navigation_spec.rb +2 -0
- data/spec/simple_navigation/adapters/rails_spec.rb +1 -1
- data/spec/simple_navigation/adapters/sinatra_spec.rb +1 -1
- data/spec/simple_navigation/config_file_finder_spec.rb +2 -2
- data/spec/simple_navigation/configuration_spec.rb +2 -2
- data/spec/simple_navigation/helpers_spec.rb +2 -2
- data/spec/simple_navigation/item_container_spec.rb +1 -1
- data/spec/simple_navigation/item_spec.rb +9 -1
- data/spec/simple_navigation/items_provider_spec.rb +1 -1
- data/spec/simple_navigation/renderer/base_spec.rb +1 -1
- data/spec/simple_navigation/renderer/breadcrumbs_spec.rb +3 -4
- data/spec/simple_navigation/renderer/links_spec.rb +4 -5
- data/spec/simple_navigation/renderer/list_spec.rb +2 -3
- data/spec/simple_navigation_spec.rb +2 -2
- data/spec/spec_helper.rb +4 -1
- metadata +14 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 32593dd3a7c2dd75f81fe21b56e89ec3fff2570b73461eac762b7911fc096297
|
4
|
+
data.tar.gz: afed0ee3fdf40f71edb92446191699482c52e8cea2bcaf5cf4a9430f55b4e0a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b70cf93db548b4521e4ee41d8df47c782f7ea1b849935e157dc5d1f686eb32b285daa42bad75a643c208b739097083ce94d90554c7826288cc38724198cba6a0
|
7
|
+
data.tar.gz: 5a376e9eeca42af65b8e23b37b30b3947c3b1d2554e55a3e2527705a80a077fd655d4fddff29b9f744b461f4affdd17ee2640a27fda924e3872882106bcbab8c
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,12 +1,23 @@
|
|
1
1
|
before_install:
|
2
2
|
- gem install bundler
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
- 2.
|
7
|
-
|
8
|
-
|
9
|
-
gemfile:
|
10
|
-
-
|
11
|
-
|
12
|
-
-
|
4
|
+
matrix:
|
5
|
+
include:
|
6
|
+
- rvm: 2.5.8
|
7
|
+
gemfile: gemfiles/rails-6-1-stable.gemfile
|
8
|
+
- rvm: 2.6.7
|
9
|
+
gemfile: gemfiles/rails-6-1-stable.gemfile
|
10
|
+
- rvm: 2.7.3
|
11
|
+
gemfile: gemfiles/rails-6-1-stable.gemfile
|
12
|
+
- rvm: 2.5.3
|
13
|
+
gemfile: gemfiles/rails-6-0-stable.gemfile
|
14
|
+
- rvm: 2.6.0
|
15
|
+
gemfile: gemfiles/rails-6-0-stable.gemfile
|
16
|
+
- rvm: 2.5.1
|
17
|
+
gemfile: gemfiles/rails-5-2-stable.gemfile
|
18
|
+
- rvm: 2.4.5
|
19
|
+
gemfile: gemfiles/rails-4-2-stable.gemfile
|
20
|
+
- rvm: 2.3.3
|
21
|
+
gemfile: gemfiles/rails-4-1-stable.gemfile
|
22
|
+
- rvm: 2.3.3
|
23
|
+
gemfile: gemfiles/rails-3-2-stable.gemfile
|
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,41 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 4.3.0
|
4
|
+
|
5
|
+
* removed warnings from rspec. Thanks mgrunberg.
|
6
|
+
* add compatibility with rails 6.1. Credits to mgrunberg.
|
7
|
+
* run specs against 6.1. Credits to mgrunberg.
|
8
|
+
|
9
|
+
## 4.2.0
|
10
|
+
|
11
|
+
* improvements to generator template. Credits to mgrunberg.
|
12
|
+
* be able to run 'rake spec:rails-6-0-stable'. Credits to mgrunberg.
|
13
|
+
|
14
|
+
## 4.1.0
|
15
|
+
|
16
|
+
* Delay rails6 initialization using on_load (getting rid of deprecation warnings in rails 6). Credits to Markus Benning.
|
17
|
+
* Fix link to wiki in README. Thanks to Greg Molnar.
|
18
|
+
* Fix uninitialized variable `@dom_attributes` warning. Credits to Johan Tell.
|
19
|
+
* Fixed tests for rails 5x. Credits to Eugene Gavrilov.
|
20
|
+
|
21
|
+
|
22
|
+
## 4.0.5
|
23
|
+
|
24
|
+
* Fix #188 Blank url and highligh_on_subpath = true causes error. Credits to Tristan Harmer (gondalez) and Ilia Pozhilov (ilyapoz).
|
25
|
+
|
26
|
+
## 4.0.4
|
27
|
+
|
28
|
+
* Fix #184 uninitialized constant Rails::Railtie (NameError). Credits to n-rodriguez.
|
29
|
+
|
3
30
|
## 4.0.3
|
4
31
|
|
5
32
|
* Fix #180 Check URL before invoking current_page?
|
6
33
|
|
7
34
|
## 4.0.2
|
8
35
|
|
9
|
-
* fixing current_page? when url is nil
|
36
|
+
* fixing current_page? when url is nil
|
10
37
|
|
11
|
-
## 4.0.1
|
38
|
+
## 4.0.1
|
12
39
|
|
13
40
|
* fixed padrino adapter
|
14
41
|
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
[![Code Climate](https://codeclimate.com/github/codeplant/simple-navigation.png)](https://codeclimate.com/github/codeplant/simple-navigation)
|
6
6
|
[![Coverage Status](https://coveralls.io/repos/codeplant/simple-navigation/badge.png)](https://coveralls.io/r/codeplant/simple-navigation)
|
7
7
|
|
8
|
-
Simple Navigation is a ruby library for creating navigations (with multiple levels) for your Rails
|
8
|
+
Simple Navigation is a ruby library for creating navigations (with multiple levels) for your Rails, Sinatra or Padrino applications. It runs with all ruby versions (including ruby 2.x).
|
9
9
|
|
10
10
|
## Documentation
|
11
11
|
|
12
|
-
For the complete documentation, take a look at the [project's wiki](
|
12
|
+
For the complete documentation, take a look at the [project's wiki](https://github.com/codeplant/simple-navigation/wiki).
|
13
13
|
|
14
14
|
## RDoc
|
15
15
|
|
@@ -29,12 +29,35 @@ Don't hesitate to come talk on the [project's group](http://groups.google.com/gr
|
|
29
29
|
|
30
30
|
## Contributing
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
Fork, fix, then send a Pull Request.
|
33
|
+
|
34
|
+
To run the test suite locally against all supported frameworks:
|
35
|
+
|
36
|
+
% bundle install
|
37
|
+
% rake spec:all
|
38
|
+
|
39
|
+
To target the test suite against one framework:
|
40
|
+
|
41
|
+
% rake spec:rails-4-2-stable
|
42
|
+
|
43
|
+
You can find a list of supported spec tasks by running rake -T. You may also find it useful to run a specific test for a specific framework. To do so, you'll have to first make sure you have bundled everything for that configuration, then you can run the specific test:
|
44
|
+
|
45
|
+
% BUNDLE_GEMFILE='gemfiles/rails-4-2-stable.gemfile' bundle install -j 4
|
46
|
+
% BUNDLE_GEMFILE='gemfiles/rails-4-2-stable.gemfile' bundle exec rspec ./spec/requests/users_spec.rb
|
47
|
+
|
48
|
+
### Rake and Bundler
|
49
|
+
|
50
|
+
If you use a shell plugin (like oh-my-zsh:bundler) that auto-prefixes commands with `bundle exec` using the `rake` command will fail.
|
51
|
+
|
52
|
+
Get the original command with `type -a rake`:
|
53
|
+
|
54
|
+
% type -a rake
|
55
|
+
rake is an alias for bundled_rake
|
56
|
+
rake is /Users/username/.rubies/ruby-2.2.3/bin/rake
|
57
|
+
rake is /usr/bin/rake
|
58
|
+
|
59
|
+
In this situation `/Users/username/.rubies/ruby-2.2.3/bin/rake` is the command you should use.
|
37
60
|
|
38
61
|
## License
|
39
62
|
|
40
|
-
Copyright (c)
|
63
|
+
Copyright (c) 2021 codeplant GmbH, released under the MIT license
|
data/Rakefile
CHANGED
@@ -1,10 +1,36 @@
|
|
1
|
-
require 'bundler
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'rspec/core'
|
2
5
|
require 'rspec/core/rake_task'
|
6
|
+
|
3
7
|
require 'rdoc/task'
|
4
8
|
|
5
9
|
RSpec::Core::RakeTask.new(:spec)
|
6
10
|
|
7
|
-
task default:
|
11
|
+
task default: 'spec'
|
12
|
+
|
13
|
+
namespace :spec do
|
14
|
+
mappers = %w[
|
15
|
+
rails-3-2-stable
|
16
|
+
rails-4-1-stable
|
17
|
+
rails-4-2-stable
|
18
|
+
rails-5-2-stable
|
19
|
+
rails-6-0-stable
|
20
|
+
rails-6-1-stable
|
21
|
+
]
|
22
|
+
|
23
|
+
mappers.each do |gemfile|
|
24
|
+
desc "Run Tests against #{gemfile}"
|
25
|
+
task gemfile do
|
26
|
+
sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle -j 4 --quiet"
|
27
|
+
sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle exec rake -t spec"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'Run Tests against all ORMs'
|
32
|
+
task all: mappers
|
33
|
+
end
|
8
34
|
|
9
35
|
RDoc::Task.new do |rdoc|
|
10
36
|
rdoc.rdoc_dir = 'rdoc'
|
@@ -24,7 +24,7 @@ SimpleNavigation::Configuration.run do |navigation|
|
|
24
24
|
# If you need to add custom html around item names, you can define a proc that
|
25
25
|
# will be called with the name you pass in to the navigation.
|
26
26
|
# The example below shows how to wrap items spans.
|
27
|
-
#navigation.name_generator = Proc.new {|name, item|
|
27
|
+
#navigation.name_generator = Proc.new {|name, item| tag.span(name) }
|
28
28
|
|
29
29
|
# Specify if the auto highlight feature is turned on (globally, for the whole navigation). Defaults to true
|
30
30
|
#navigation.auto_highlight = true
|
@@ -45,6 +45,7 @@ SimpleNavigation::Configuration.run do |navigation|
|
|
45
45
|
# url - the address that the generated item links to. You can also use url_helpers (named routes, restful routes helper, url_for etc.)
|
46
46
|
# options - can be used to specify attributes that will be included in the rendered navigation item (e.g. id, class etc.)
|
47
47
|
# some special options that can be set:
|
48
|
+
# :html - Specifies html attributes that will be included in the rendered navigation item
|
48
49
|
# :if - Specifies a proc to call to determine if the item should
|
49
50
|
# be rendered (e.g. <tt>if: -> { current_user.admin? }</tt>). The
|
50
51
|
# proc should evaluate to a true or false value and is evaluated in the context of the view.
|
@@ -67,7 +68,7 @@ SimpleNavigation::Configuration.run do |navigation|
|
|
67
68
|
# You can also specify a condition-proc that needs to be fullfilled to display an item.
|
68
69
|
# Conditions are part of the options. They are evaluated in the context of the views,
|
69
70
|
# thus you can use all the methods and vars you have available in the views.
|
70
|
-
primary.item :key_3, 'Admin', url, class: 'special', if: -> { current_user.admin? }
|
71
|
+
primary.item :key_3, 'Admin', url, html: { class: 'special' }, if: -> { current_user.admin? }
|
71
72
|
primary.item :key_4, 'Account', url, unless: -> { logged_in? }
|
72
73
|
|
73
74
|
# you can also specify html attributes to attach to this particular level
|
data/lib/simple_navigation.rb
CHANGED
@@ -12,7 +12,7 @@ require 'simple_navigation/items_provider'
|
|
12
12
|
require 'simple_navigation/renderer'
|
13
13
|
require 'simple_navigation/adapters'
|
14
14
|
require 'simple_navigation/config_file_finder'
|
15
|
-
require 'simple_navigation/railtie' if defined?(::Rails)
|
15
|
+
require 'simple_navigation/railtie' if defined?(::Rails::Railtie)
|
16
16
|
|
17
17
|
require 'forwardable'
|
18
18
|
|
@@ -5,6 +5,21 @@ module SimpleNavigation
|
|
5
5
|
|
6
6
|
def self.register
|
7
7
|
SimpleNavigation.set_env(::Rails.root, ::Rails.env)
|
8
|
+
|
9
|
+
# Autoloading in initializers is deprecated on rails 6.0
|
10
|
+
# This delays the hook initialization using the on_load
|
11
|
+
# hooks, but does not change behaviour for existing
|
12
|
+
# rails versions.
|
13
|
+
if ::Rails::VERSION::MAJOR >= 6
|
14
|
+
ActiveSupport.on_load(:action_controller_base) do
|
15
|
+
SimpleNavigation::Adapters::Rails.register_controller_helpers
|
16
|
+
end
|
17
|
+
else
|
18
|
+
register_controller_helpers
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.register_controller_helpers
|
8
23
|
ActionController::Base.send(:include, SimpleNavigation::Helpers)
|
9
24
|
SimpleNavigation::Helpers.instance_methods.each do |m|
|
10
25
|
ActionController::Base.send(:helper_method, m.to_sym)
|
@@ -16,6 +16,7 @@ module SimpleNavigation
|
|
16
16
|
@items ||= []
|
17
17
|
@renderer = SimpleNavigation.config.renderer
|
18
18
|
@auto_highlight = true
|
19
|
+
@dom_attributes = {}
|
19
20
|
end
|
20
21
|
|
21
22
|
def dom_attributes
|
@@ -24,7 +25,8 @@ module SimpleNavigation
|
|
24
25
|
id: dom_id,
|
25
26
|
class: dom_class
|
26
27
|
}.reject { |_, v| v.nil? }
|
27
|
-
|
28
|
+
|
29
|
+
@dom_attributes.merge(dom_id_and_class)
|
28
30
|
end
|
29
31
|
|
30
32
|
# Creates a new navigation item.
|
data/simple-navigation.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
15
15
|
"as explicit highlighting of the currently active " \
|
16
16
|
"navigation through regular expressions."
|
17
17
|
spec.summary = "simple-navigation is a ruby library for creating navigations "\
|
18
|
-
"(with multiple levels) for your
|
18
|
+
"(with multiple levels) for your Rails, Sinatra or " \
|
19
19
|
"Padrino application."
|
20
20
|
spec.homepage = 'http://github.com/codeplant/simple-navigation'
|
21
21
|
spec.license = 'MIT'
|
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
|
30
30
|
spec.add_runtime_dependency 'activesupport', '>= 2.3.2'
|
31
31
|
|
32
|
-
spec.add_development_dependency 'bundler'
|
32
|
+
spec.add_development_dependency 'bundler'
|
33
33
|
spec.add_development_dependency 'capybara'
|
34
34
|
spec.add_development_dependency 'coveralls', '~> 0.7'
|
35
35
|
spec.add_development_dependency 'guard-rspec', '~> 4.2'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
SimpleNavigation::Configuration.run do |navigation|
|
2
2
|
navigation.items do |nav|
|
3
|
-
nav.item :item_1, 'Item 1', '/item_1'
|
4
|
-
nav.item :item_2, 'Item 2', '/item_2'
|
3
|
+
nav.item :item_1, 'Item 1', '/item_1', html: {class: 'item_1'}, link_html: {id: 'link_1'}
|
4
|
+
nav.item :item_2, 'Item 2', '/item_2', html: {class: 'item_2'}, link_html: {id: 'link_2'}
|
5
5
|
end
|
6
6
|
end
|
@@ -186,7 +186,7 @@ module SimpleNavigation
|
|
186
186
|
before { adapter.instance_variable_set(:@template, nil) }
|
187
187
|
|
188
188
|
it 'raises an exception' do
|
189
|
-
expect{ adapter.context_for_eval }.to raise_error
|
189
|
+
expect{ adapter.context_for_eval }.to raise_error(RuntimeError, 'no context set for evaluation the config file')
|
190
190
|
end
|
191
191
|
end
|
192
192
|
end
|
@@ -9,7 +9,7 @@ describe SimpleNavigation::Adapters::Sinatra do
|
|
9
9
|
context "when adapter's context is not set" do
|
10
10
|
it 'raises an exception' do
|
11
11
|
allow(adapter).to receive_messages(context: nil)
|
12
|
-
expect{ adapter.context_for_eval }.to raise_error
|
12
|
+
expect{ adapter.context_for_eval }.to raise_error(RuntimeError, 'no context set for evaluation the config file')
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -23,7 +23,7 @@ module SimpleNavigation
|
|
23
23
|
|
24
24
|
context 'and no navigation.rb file is found in the paths' do
|
25
25
|
it 'raises an exception' do
|
26
|
-
expect{ finder.find(context) }.to raise_error
|
26
|
+
expect { finder.find(context) }.to raise_error(RuntimeError, /Config file 'navigation.rb' not found in path\(s\)/)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -41,7 +41,7 @@ module SimpleNavigation
|
|
41
41
|
|
42
42
|
context 'and no other_navigation.rb file is found in the paths' do
|
43
43
|
it 'raise an exception' do
|
44
|
-
expect{ finder.find(context) }.to raise_error
|
44
|
+
expect{ finder.find(context) }.to raise_error(RuntimeError, /Config file 'other_navigation.rb' not found in path\(s\)/)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -89,7 +89,7 @@ module SimpleNavigation
|
|
89
89
|
let(:provider) { double(:provider) }
|
90
90
|
|
91
91
|
it 'raises an exception' do
|
92
|
-
expect{ config.items(provider) {} }.to raise_error
|
92
|
+
expect{ config.items(provider) {} }.to raise_error(RuntimeError, 'please specify either items_provider or block, but not both')
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
@@ -139,7 +139,7 @@ module SimpleNavigation
|
|
139
139
|
|
140
140
|
context 'when items_provider is not specified' do
|
141
141
|
it "raises an exception" do
|
142
|
-
expect{ config.items }.to raise_error
|
142
|
+
expect{ config.items }.to raise_error(RuntimeError, 'please specify either items_provider or block, but not both')
|
143
143
|
end
|
144
144
|
end
|
145
145
|
end
|
@@ -382,7 +382,7 @@ module SimpleNavigation
|
|
382
382
|
it 'raises an exception' do
|
383
383
|
expect{
|
384
384
|
controller.render_navigation(level: :invalid)
|
385
|
-
}.to raise_error
|
385
|
+
}.to raise_error(ArgumentError, 'Invalid navigation level: invalid')
|
386
386
|
end
|
387
387
|
end
|
388
388
|
end
|
@@ -408,7 +408,7 @@ module SimpleNavigation
|
|
408
408
|
before { allow(SimpleNavigation).to receive_messages(primary_navigation: nil) }
|
409
409
|
|
410
410
|
it 'raises an exception' do
|
411
|
-
expect{controller.render_navigation}.to raise_error
|
411
|
+
expect{controller.render_navigation}.to raise_error(RuntimeError, 'no primary navigation defined, either use a navigation config file or pass items directly to render_navigation')
|
412
412
|
end
|
413
413
|
end
|
414
414
|
|
@@ -246,6 +246,14 @@ module SimpleNavigation
|
|
246
246
|
double(:config, auto_highlight: true, highlight_on_subpath: true, ignore_query_params_on_auto_highlight: true, ignore_anchors_on_auto_highlight: true)
|
247
247
|
end
|
248
248
|
|
249
|
+
context "but item has no url" do
|
250
|
+
let(:url) { nil }
|
251
|
+
|
252
|
+
it 'returns false' do
|
253
|
+
expect(item.selected?).to be false
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
249
257
|
context "and the current url is a sub path of the item's url" do
|
250
258
|
before do
|
251
259
|
allow(adapter).to \
|
@@ -338,7 +346,7 @@ module SimpleNavigation
|
|
338
346
|
let(:options) {{ highlights_on: :hello }}
|
339
347
|
|
340
348
|
it 'raises an exception' do
|
341
|
-
expect{ item.selected? }.to raise_error
|
349
|
+
expect{ item.selected? }.to raise_error(ArgumentError, ':highlights_on must be a Regexp, Proc or :subpath')
|
342
350
|
end
|
343
351
|
end
|
344
352
|
end
|
@@ -36,7 +36,7 @@ module SimpleNavigation
|
|
36
36
|
let(:provider) { double(:provider) }
|
37
37
|
|
38
38
|
it 'raises an exception' do
|
39
|
-
expect{ items_provider.items }.to raise_error
|
39
|
+
expect{ items_provider.items }.to raise_error(RuntimeError, /items_provider either must be a symbol .*, an object .* or an enumerable/)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -32,7 +32,7 @@ module SimpleNavigation
|
|
32
32
|
|
33
33
|
describe '#render' do
|
34
34
|
it "raise an exception to indicate it's a subclass responsibility" do
|
35
|
-
expect{ base.render(:container) }.to raise_error
|
35
|
+
expect{ base.render(:container) }.to raise_error(NotImplementedError, 'subclass responsibility')
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -5,8 +5,7 @@ module SimpleNavigation
|
|
5
5
|
|
6
6
|
let(:item) { nil }
|
7
7
|
let(:options) {{ level: :all }}
|
8
|
-
let(:output) {
|
9
|
-
let(:raw_output) { renderer.render(navigation) }
|
8
|
+
let(:output) { renderer.render(navigation) }
|
10
9
|
let(:renderer) { Breadcrumbs.new(options) }
|
11
10
|
|
12
11
|
before { select_an_item(navigation[item]) if item }
|
@@ -75,7 +74,7 @@ module SimpleNavigation
|
|
75
74
|
let(:item) { nil }
|
76
75
|
|
77
76
|
it "doesn't render the prefix before the breadcrumbs" do
|
78
|
-
expect(
|
77
|
+
expect(output).not_to match(/^<div.+>You are here: /)
|
79
78
|
end
|
80
79
|
end
|
81
80
|
|
@@ -83,7 +82,7 @@ module SimpleNavigation
|
|
83
82
|
let(:item) { :invoices }
|
84
83
|
|
85
84
|
it 'renders the prefix before the breadcrumbs' do
|
86
|
-
expect(
|
85
|
+
expect(output).to match(/^<div.+>You are here: /)
|
87
86
|
end
|
88
87
|
end
|
89
88
|
end
|
@@ -5,9 +5,8 @@ module SimpleNavigation
|
|
5
5
|
let!(:navigation) { setup_navigation('nav_id', 'nav_class') }
|
6
6
|
|
7
7
|
let(:item) { nil }
|
8
|
-
let(:options) {{ level: :all }}
|
9
|
-
let(:output) {
|
10
|
-
let(:raw_output) { renderer.render(navigation) }
|
8
|
+
let(:options) { { level: :all } }
|
9
|
+
let(:output) { renderer.render(navigation) }
|
11
10
|
let(:renderer) { Links.new(options) }
|
12
11
|
|
13
12
|
before { select_an_item(navigation[item]) if item }
|
@@ -29,7 +28,7 @@ module SimpleNavigation
|
|
29
28
|
end
|
30
29
|
|
31
30
|
it "renders the 'a' tags with the corresponding item's :html_options" do
|
32
|
-
expect(output).to have_css('a[style=float:right]')
|
31
|
+
expect(output).to have_css('a[style="float:right"]')
|
33
32
|
end
|
34
33
|
|
35
34
|
context 'when an item has a specified id' do
|
@@ -62,7 +61,7 @@ module SimpleNavigation
|
|
62
61
|
let(:options) {{ level: :all, join_with: ' | ' }}
|
63
62
|
|
64
63
|
it 'separates the items with the specified separator' do
|
65
|
-
expect(
|
64
|
+
expect(output.scan(' | ').size).to eq 3
|
66
65
|
end
|
67
66
|
end
|
68
67
|
|
@@ -4,9 +4,8 @@ module SimpleNavigation
|
|
4
4
|
let!(:navigation) { setup_navigation('nav_id', 'nav_class') }
|
5
5
|
|
6
6
|
let(:item) { nil }
|
7
|
-
let(:options) {{ level: :all }}
|
8
|
-
let(:output) {
|
9
|
-
let(:raw_output) { renderer.render(navigation) }
|
7
|
+
let(:options) { { level: :all } }
|
8
|
+
let(:output) { renderer.render(navigation) }
|
10
9
|
let(:renderer) { List.new(options) }
|
11
10
|
|
12
11
|
before { select_an_item(navigation[item]) if item }
|
@@ -104,7 +104,7 @@ describe SimpleNavigation do
|
|
104
104
|
|
105
105
|
context "when the config file for the context doesn't exists" do
|
106
106
|
it 'raises an exception' do
|
107
|
-
expect{ subject.load_config }.to raise_error
|
107
|
+
expect{ subject.load_config }.to raise_error(RuntimeError, /Config file 'navigation.rb' not found in path\(s\)/)
|
108
108
|
end
|
109
109
|
end
|
110
110
|
end
|
@@ -152,7 +152,7 @@ describe SimpleNavigation do
|
|
152
152
|
it 'raises an exception' do
|
153
153
|
expect{
|
154
154
|
subject.active_item_container_for('something else')
|
155
|
-
}.to raise_error
|
155
|
+
}.to raise_error(ArgumentError, 'Invalid navigation level: something else')
|
156
156
|
end
|
157
157
|
end
|
158
158
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -24,7 +24,10 @@ end
|
|
24
24
|
|
25
25
|
def setup_adapter_for(framework, context = double(:context))
|
26
26
|
if framework == :rails
|
27
|
-
|
27
|
+
# Rails 6.0 and 6.1 provide ActionView::Base.empty method that creates ActionView with an empty LookupContext.
|
28
|
+
# The method is not available on older versions
|
29
|
+
view_context = ActionView::Base.respond_to?(:empty) ? ActionView::Base.empty : ActionView::Base.new
|
30
|
+
allow(context).to receive_messages(view_context: view_context)
|
28
31
|
end
|
29
32
|
|
30
33
|
allow(SimpleNavigation).to receive_messages(framework: framework)
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-navigation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0
|
4
|
+
version: 4.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andi Schacke
|
8
8
|
- Mark J. Titorenko
|
9
9
|
- Simon Courtois
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-05-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -30,16 +30,16 @@ dependencies:
|
|
30
30
|
name: bundler
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- - "
|
33
|
+
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: '
|
35
|
+
version: '0'
|
36
36
|
type: :development
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- - "
|
40
|
+
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
42
|
+
version: '0'
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: capybara
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -175,6 +175,9 @@ files:
|
|
175
175
|
- gemfiles/rails-3-2-stable.gemfile
|
176
176
|
- gemfiles/rails-4-1-stable.gemfile
|
177
177
|
- gemfiles/rails-4-2-stable.gemfile
|
178
|
+
- gemfiles/rails-5-2-stable.gemfile
|
179
|
+
- gemfiles/rails-6-0-stable.gemfile
|
180
|
+
- gemfiles/rails-6-1-stable.gemfile
|
178
181
|
- generators/navigation_config/USAGE
|
179
182
|
- generators/navigation_config/navigation_config_generator.rb
|
180
183
|
- generators/navigation_config/templates/config/navigation.rb
|
@@ -239,7 +242,7 @@ homepage: http://github.com/codeplant/simple-navigation
|
|
239
242
|
licenses:
|
240
243
|
- MIT
|
241
244
|
metadata: {}
|
242
|
-
post_install_message:
|
245
|
+
post_install_message:
|
243
246
|
rdoc_options:
|
244
247
|
- "--inline-source"
|
245
248
|
- "--charset=UTF-8"
|
@@ -256,12 +259,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
256
259
|
- !ruby/object:Gem::Version
|
257
260
|
version: '0'
|
258
261
|
requirements: []
|
259
|
-
|
260
|
-
|
261
|
-
signing_key:
|
262
|
+
rubygems_version: 3.0.9
|
263
|
+
signing_key:
|
262
264
|
specification_version: 4
|
263
265
|
summary: simple-navigation is a ruby library for creating navigations (with multiple
|
264
|
-
levels) for your
|
266
|
+
levels) for your Rails, Sinatra or Padrino application.
|
265
267
|
test_files:
|
266
268
|
- spec/fake_app/config/navigation.rb
|
267
269
|
- spec/fake_app/rails_app.rb
|