diff --git a/lib/couchrest/model/associations.rb b/lib/couchrest/model/associations.rb index 889ff5c..ccebcf8 100644 --- a/lib/couchrest/model/associations.rb +++ b/lib/couchrest/model/associations.rb @@ -25,8 +25,8 @@ module CouchRest begin opts[:class] = opts[:class_name].constantize - rescue - raise "Unable to convert class name into Constant for #{self.name}##{attrib}" + rescue NameError + raise NameError, "Unable to convert class name into Constant for #{self.name}##{attrib}" end prop = property(opts[:foreign_key], opts) diff --git a/spec/couchrest/assocations_spec.rb b/spec/couchrest/assocations_spec.rb index fe16970..36e0e5d 100644 --- a/spec/couchrest/assocations_spec.rb +++ b/spec/couchrest/assocations_spec.rb @@ -44,11 +44,11 @@ describe "Assocations" do end it "should raise error if class name does not exist" do - lambda { + lambda do class TestBadAssoc < CouchRest::Model::Base belongs_to :test_bad_item end - }.should raise_error + end.should raise_error(NameError, /TestBadAssoc#test_bad_item/) end it "should allow override of foreign key" do