Use Kernel#inspect instead of #to_s #204

Merged
merged 1 commit into from Dec 10, 2012

Projects

None yet

2 participants

@sanemat

Kernel#inspect does not call #to_s anymore, on Ruby2.0.0

klass = Class.new do
  def self.to_s
    "MyClass"
  end
end

Ruby1.9.3
=> MyClass

Ruby2.0.0
=> #<Class:0x007ffe0c4c2ab8>
@sanemat sanemat Use Kernel#inspect instead of #to_s
Kernel#inspect does not call #to_s anymore, on Ruby2.0.0
394c14a
@myronmarston
RSpec member

@sanemat -- thanks. Do you know if it is an intentional decision to break this behavior in 2.0? Is there a chance they'll revert the behavior change?

@sanemat

I don't know actually yes, but I think yes, because https://github.com/ruby/ruby/blob/trunk/NEWS said:

  • Kernel
    • * Kernel#inspect does not call #to_s anymore
@sanemat

If this behavior does not include in 2.0, but Kernel#inspect can use 1.8.7, 1.9.3, 2.0.0, so this change is better.

@myronmarston myronmarston merged commit a209077 into rspec:master Dec 10, 2012

1 check passed

Details default The Travis build passed
@myronmarston
RSpec member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment