1require_relative '../../spec_helper' 2require_relative 'fixtures/classes' 3 4describe "Kernel#inspect" do 5 it "returns a String" do 6 Object.new.inspect.should be_an_instance_of(String) 7 end 8 9 it "returns a tainted string if self is tainted" do 10 Object.new.taint.inspect.tainted?.should be_true 11 end 12 13 it "returns an untrusted string if self is untrusted" do 14 Object.new.untrust.inspect.untrusted?.should be_true 15 end 16 17 it "does not call #to_s if it is defined" do 18 # We must use a bare Object here 19 obj = Object.new 20 inspected = obj.inspect 21 22 obj.stub!(:to_s).and_return("to_s'd") 23 24 obj.inspect.should == inspected 25 end 26 27 it "returns a String with the object class and object_id encoded" do 28 obj = Object.new 29 obj.inspect.should =~ /^#<Object:0x[0-9a-f]+>$/ 30 end 31end 32