Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add #inspect

  • Loading branch information...
commit cc9189fa30679fbdf87c5260afdf7c82a20371fa 1 parent 5376ece
@kachick authored
Showing with 14 additions and 0 deletions.
  1. +8 −0 lib/instancevalue.rb
  2. +6 −0 test/test_instancevalue.rb
View
8 lib/instancevalue.rb
@@ -71,6 +71,14 @@ def instance_values
singleton_class::VALUES.keys
end
+ def inspect
+ super.sub(/>\z/){
+ singleton_class::VALUES.map{|name, value|
+ " #{name}=#{value.inspect}"
+ }.join + '>'
+ }
+ end
+
private
def initialize_copy(original)
View
6 test/test_instancevalue.rb
@@ -62,4 +62,10 @@ def test_clone
assert_same false, (person.instance_values == person2.instance_values)
end
+
+ def test_inspect
+ person = Person.new 9753
+ person.instance_variable_set :@var, 1234
+ assert_equal true, !!(/\A#<TestBasicCase::Person:\w+ @var=1234 birthday=9753>\z/ =~ person.inspect)
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.