Skip to content

Commit

Permalink
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kernel/common/kernel.rb
Original file line number Diff line number Diff line change
@@ -195,6 +195,10 @@ def ===(other)
equal?(other) || self == other
end

def itself
self
end

def abort(msg=nil)
Process.abort msg
end
9 changes: 9 additions & 0 deletions spec/ruby/core/kernel/itself_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require File.expand_path('../../../spec_helper', __FILE__)

describe "Kernel#itself" do
it "should return the receiver" do
num = 2

num.itself.should = num

This comment has been minimized.

Copy link
@jemc

jemc Sep 20, 2014

Member

Did you run this spec? .should= shouldn't work.

You need to be using .should == (or in this case, I would say .should equal). I would also suggest some other object than a number - as these are kind of a special case for testing equality.

Incidentally, I already have a PR pending at rubyspec for this test:
https://github.com/rubyspec/rubyspec/pull/287

This comment has been minimized.

Copy link
@tak1n

tak1n Sep 20, 2014

Member

Yep, right.
Could have used a fixture class, but thought nah just use an Integer..
And the .should == error is kinda embarrassing ^^

Should I fix the spec or undo this commit and awaiting approval for your rubyspec pr?

This comment has been minimized.

Copy link
@yorickpeterse

yorickpeterse Sep 20, 2014

Contributor

Just fixing the spec is fine since it's already pushed.

end
end

0 comments on commit 73ddfc2

Please sign in to comment.