From 42d120561ba83d151cf1cd0446f5fdbf50b4d604 Mon Sep 17 00:00:00 2001 From: Holger Just Date: Sat, 10 Feb 2018 14:12:11 +0100 Subject: [PATCH] Clarify the error message when trying to fetch invalid specs from a ClassRegistry --- lib/rackstash/class_registry.rb | 3 ++- spec/rackstash/class_registry_spec.rb | 6 +++--- spec/rackstash/encoder_spec.rb | 6 +++--- spec/rackstash/filter_spec.rb | 6 +++--- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/rackstash/class_registry.rb b/lib/rackstash/class_registry.rb index a3dff1e..1f08733 100644 --- a/lib/rackstash/class_registry.rb +++ b/lib/rackstash/class_registry.rb @@ -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 diff --git a/spec/rackstash/class_registry_spec.rb b/spec/rackstash/class_registry_spec.rb index b3c68d2..f7ca786 100644 --- a/spec/rackstash/class_registry_spec.rb +++ b/spec/rackstash/class_registry_spec.rb @@ -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 diff --git a/spec/rackstash/encoder_spec.rb b/spec/rackstash/encoder_spec.rb index 2f235ed..6d9c2bd 100644 --- a/spec/rackstash/encoder_spec.rb +++ b/spec/rackstash/encoder_spec.rb @@ -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 diff --git a/spec/rackstash/filter_spec.rb b/spec/rackstash/filter_spec.rb index 641a503..0c8fa1d 100644 --- a/spec/rackstash/filter_spec.rb +++ b/spec/rackstash/filter_spec.rb @@ -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