1
0
mirror of https://github.com/meineerde/rackstash.git synced 2025-10-17 14:01:01 +00:00

Clarify the error message when trying to fetch invalid specs from a ClassRegistry

This commit is contained in:
Holger Just 2018-02-10 14:12:11 +01:00
parent 2d04ccb6c9
commit 42d120561b
4 changed files with 11 additions and 10 deletions

View File

@ -62,7 +62,8 @@ module Rackstash
raise KeyError, "No #{@object_type} was registered for #{spec.inspect}"
end
else
raise TypeError, "#{spec.inspect} can not be used to describe #{@object_type}s"
raise TypeError, "#{spec.inspect} can not be used to describe " \
"#{@object_type} classes"
end
end

View File

@ -80,11 +80,11 @@ describe Rackstash::ClassRegistry do
it 'raises a TypeError on invalid names' do
expect { registry.fetch(0) }
.to raise_error(TypeError, '0 can not be used to describe values')
.to raise_error(TypeError, '0 can not be used to describe value classes')
expect { registry.fetch(nil) }
.to raise_error(TypeError, 'nil can not be used to describe values')
.to raise_error(TypeError, 'nil can not be used to describe value classes')
expect { registry.fetch(true) }
.to raise_error(TypeError, 'true can not be used to describe values')
.to raise_error(TypeError, 'true can not be used to describe value classes')
end
end

View File

@ -62,11 +62,11 @@ describe Rackstash::Encoder do
it 'raises a TypeError with invalid spec types' do
expect { described_class.build(123) }
.to raise_error(TypeError, '123 can not be used to describe encoders')
.to raise_error(TypeError, '123 can not be used to describe encoder classes')
expect { described_class.build(nil) }
.to raise_error(TypeError, 'nil can not be used to describe encoders')
.to raise_error(TypeError, 'nil can not be used to describe encoder classes')
expect { described_class.build(true) }
.to raise_error(TypeError, 'true can not be used to describe encoders')
.to raise_error(TypeError, 'true can not be used to describe encoder classes')
end
it 'raises a KeyError for undefined encoders' do

View File

@ -135,11 +135,11 @@ describe Rackstash::Filter do
it 'raises a TypeError with invalid spec types' do
expect { described_class.build(123) }
.to raise_error(TypeError, '123 can not be used to describe filters')
.to raise_error(TypeError, '123 can not be used to describe filter classes')
expect { described_class.build(nil) }
.to raise_error(TypeError, 'nil can not be used to describe filters')
.to raise_error(TypeError, 'nil can not be used to describe filter classes')
expect { described_class.build(true) }
.to raise_error(TypeError, 'true can not be used to describe filters')
.to raise_error(TypeError, 'true can not be used to describe filter classes')
end
it 'raises a KeyError for undefined filters' do