Skip to content

Commit

Permalink
remove rspec warnings by adding raised error and expected message
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrunberg committed May 12, 2021
1 parent 444928d commit 422104f
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion spec/simple_navigation/adapters/rails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ module Adapters
before { adapter.instance_variable_set(:@template, nil) }

it 'raises an exception' do
expect{ adapter.context_for_eval }.to raise_error
expect{ adapter.context_for_eval }.to raise_error(RuntimeError, 'no context set for evaluation the config file')
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/simple_navigation/adapters/sinatra_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
context "when adapter's context is not set" do
it 'raises an exception' do
allow(adapter).to receive_messages(context: nil)
expect{ adapter.context_for_eval }.to raise_error
expect{ adapter.context_for_eval }.to raise_error(RuntimeError, 'no context set for evaluation the config file')
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/simple_navigation/config_file_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module SimpleNavigation

context 'and no navigation.rb file is found in the paths' do
it 'raises an exception' do
expect{ finder.find(context) }.to raise_error
expect { finder.find(context) }.to raise_error(RuntimeError, /Config file 'navigation.rb' not found in path\(s\)/)
end
end
end
Expand All @@ -41,7 +41,7 @@ module SimpleNavigation

context 'and no other_navigation.rb file is found in the paths' do
it 'raise an exception' do
expect{ finder.find(context) }.to raise_error
expect{ finder.find(context) }.to raise_error(RuntimeError, /Config file 'other_navigation.rb' not found in path\(s\)/)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/simple_navigation/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ module SimpleNavigation
let(:provider) { double(:provider) }

it 'raises an exception' do
expect{ config.items(provider) {} }.to raise_error
expect{ config.items(provider) {} }.to raise_error(RuntimeError, 'please specify either items_provider or block, but not both')
end
end

Expand Down Expand Up @@ -139,7 +139,7 @@ module SimpleNavigation

context 'when items_provider is not specified' do
it "raises an exception" do
expect{ config.items }.to raise_error
expect{ config.items }.to raise_error(RuntimeError, 'please specify either items_provider or block, but not both')
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/simple_navigation/helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ module SimpleNavigation
it 'raises an exception' do
expect{
controller.render_navigation(level: :invalid)
}.to raise_error
}.to raise_error(ArgumentError, 'Invalid navigation level: invalid')
end
end
end
Expand All @@ -408,7 +408,7 @@ module SimpleNavigation
before { allow(SimpleNavigation).to receive_messages(primary_navigation: nil) }

it 'raises an exception' do
expect{controller.render_navigation}.to raise_error
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')
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/simple_navigation/item_container_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ module SimpleNavigation
it 'raises an error' do
expect{
item_container.item('key', 'name', 'url', { if: 'text' })
}.to raise_error
}.to raise_error(ArgumentError, ':if or :unless must be procs or lambdas')
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/simple_navigation/item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ module SimpleNavigation
let(:options) {{ highlights_on: :hello }}

it 'raises an exception' do
expect{ item.selected? }.to raise_error
expect{ item.selected? }.to raise_error(ArgumentError, ':highlights_on must be a Regexp, Proc or :subpath')
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/simple_navigation/items_provider_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module SimpleNavigation
let(:provider) { double(:provider) }

it 'raises an exception' do
expect{ items_provider.items }.to raise_error
expect{ items_provider.items }.to raise_error(RuntimeError, /items_provider either must be a symbol .*, an object .* or an enumerable/)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/simple_navigation/renderer/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module Renderer

describe '#render' do
it "raise an exception to indicate it's a subclass responsibility" do
expect{ base.render(:container) }.to raise_error
expect{ base.render(:container) }.to raise_error(NotImplementedError, 'subclass responsibility')
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/simple_navigation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@

context "when the config file for the context doesn't exists" do
it 'raises an exception' do
expect{ subject.load_config }.to raise_error
expect{ subject.load_config }.to raise_error(RuntimeError, /Config file 'navigation.rb' not found in path\(s\)/)
end
end
end
Expand Down Expand Up @@ -152,7 +152,7 @@
it 'raises an exception' do
expect{
subject.active_item_container_for('something else')
}.to raise_error
}.to raise_error(ArgumentError, 'Invalid navigation level: something else')
end
end
end
Expand Down

0 comments on commit 422104f

Please sign in to comment.