Skip to content

Commit

Permalink
Cleanup for #307
Browse files Browse the repository at this point in the history
  • Loading branch information
jodosha committed Mar 26, 2016
1 parent 2e1cc5e commit e126108
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/hanami/model/config/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Config
# @since 0.2.0
class AdapterNotFound < Hanami::Model::Error
def initialize(adapter_name, message)
super "Cannot find Hanami::Model adapter '#{adapter_name}' (#{message})"
super "Cannot find Hanami::Model adapter `Hanami::Model::Adapters::#{adapter_name}' (#{message})"
end
end

Expand Down Expand Up @@ -104,7 +104,7 @@ def instantiate_adapter(mapper)
klass = Hanami::Utils::Class.load!(class_name, Hanami::Model::Adapters)
klass.new(mapper, uri, options)
rescue => e
raise Error, e
raise Hanami::Model::Error.new(e)
end
end
end
Expand Down
6 changes: 4 additions & 2 deletions test/model/config/adapter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
let(:config) { Hanami::Model::Config::Adapter.new(type: :redis, uri: 'redis://not_exist') }

it 'raises an error' do
-> { config.build(mapper) }.must_raise(Hanami::Model::Error)
exception = -> { config.build(mapper) }.must_raise(Hanami::Model::Error)
exception.message.must_equal "Cannot find Hanami::Model adapter `Hanami::Model::Adapters::RedisAdapter' (cannot load such file -- hanami/model/adapters/redis_adapter)"
end
end

Expand All @@ -46,7 +47,8 @@

it 'raises an error' do
config.stub(:load_adapter, nil) do
-> { config.build(mapper) }.must_raise(Hanami::Model::Error)
exception = -> { config.build(mapper) }.must_raise(Hanami::Model::Error)
exception.message.must_equal "uninitialized constant Hanami::Model::Adapters::RedisAdapter"
end
end
end
Expand Down

0 comments on commit e126108

Please sign in to comment.