Skip to content

Commit

Permalink
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions spec/ruby/language/case_spec.rb
Original file line number Diff line number Diff line change
@@ -368,10 +368,10 @@ def bar; @calls << :bar; end

it "calls === even when private" do
klass = Class.new do
private
def ===(o)
!!o
true
end
private :===
end

case 1

4 comments on commit ac6268d

@nirvdrum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this change the semantics if o is nil or false?

@eregon
Copy link
Member Author

@eregon eregon commented on ac6268d Sep 15, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well it's only for that example

@nirvdrum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, I guess I should have looked at more context. I guess that explains the case 1, too. I realize you're not the original author, but I think this spec is a bit confusing. Having a comment as to what's really being tested would be helpful.

@eregon
Copy link
Member Author

@eregon eregon commented on ac6268d Sep 15, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The specdoc would ideally be enough 😃
But indeed it's not trivial and we need to redefine === otherwise it would just go to the else case.
A mock does not work so well as we need to make the method private and private singleton methods are a strange concept.

Please sign in to comment.