Permalink
Browse files

Update error message to use #inspect only

  • Loading branch information...
dkubb committed Nov 26, 2012
1 parent 701ffd6 commit 26f68aaf5788c103f7deb0d9150697fd7ae4f464
View
@@ -1,3 +1,3 @@
---
threshold: 15
total_score: 32
threshold: 18
total_score: 35
View
@@ -32,7 +32,7 @@ module ClassMethods
# @api public
def new(*)
if superclass.equal?(Object)
raise NotImplementedError, "#{self} is an abstract type"
raise NotImplementedError, "#{inspect} is an abstract type"
else
super
end
@@ -90,9 +90,9 @@ def abstract_singleton_method(*names)
# @api private
def create_abstract_singleton_method(name)
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def self.#{name}(*) # def self.name(*)
raise NotImplementedError, "\#{name || inspect}.\#{__method__} is not implemented" # raise NotImplementedError, 'MyClass#name is not implemented'
end # end
def self.#{name}(*) # def self.name(*)
raise NotImplementedError, "\#{inspect}.#{name} is not implemented" # raise NotImplementedError, '\#{inspect}.name is not implemented'
end # end
RUBY
end
@@ -106,9 +106,9 @@ def self.#{name}(*)
# @api private
def create_abstract_instance_method(name)
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{name}(*) # def name(*)
raise NotImplementedError, "\#{self.class.name || self.class.inspect}#\#{__method__} is not implemented" # raise NotImplementedError, 'MyClass.name is not implemented'
end # end
def #{name}(*) # def name(*)
raise NotImplementedError, "\#{self.class.inspect}##{name} is not implemented" # raise NotImplementedError, "\#{self.class.inspect}#name is not implemented"
end # end
RUBY
end
@@ -13,10 +13,16 @@
end
end
let(:class_under_test)do
Class.new(abstract_type) do
def self.name; 'TheClassName'; end
end
let(:class_under_test) do
Class.new(abstract_type)
end
before do
TheClassName = class_under_test
end
after do
Object.class_eval { remove_const(:TheClassName) }
end
let(:object) { class_under_test.new }
@@ -10,11 +10,17 @@
include AbstractType
abstract_singleton_method :some_method
def self.name; 'TheClassName'; end
end
end
before do
TheClassName = object
end
after do
Object.class_eval { remove_const(:TheClassName) }
end
it 'creates an abstract method' do
expect { subject }.to raise_error(NotImplementedError, 'TheClassName.some_method is not implemented')
end

0 comments on commit 26f68aa

Please sign in to comment.