[rspec-users] [RSpec] implicit receiver for should problem when helper predicate methods are in use

juuuser jarmo.p at gmail.com
Thu May 7 14:14:37 EDT 2009

I just upgraded RSpec and noticed that some of my specs started to fail and
it is caused by the 1.1.2 update where implicit receiver for should is

Here is one sample example group, which works with older versions naturally.

describe "example group" do
	it "example" do
         should be_ok
	def ok?

And gets NoMethodError of course. I tried different things to set as
subject, but was unlucky. For example, subject {self} caused
SystemStackError although I hoped that this does the trick, since self has
method ok? as expected.

I also noticed that there is accessor for subject, so I tried something like
this instead of def ok?:

def subject.ok?

Why doesn't it work? It works when doing like this:
s = "str"
def s.ok?; true; end
s.ok? # true

I found only one way to fix them like this:
class String
    def ok?

Of course I'm not happy with that solution :)

What are my options to fix these specs? It seems to me that most logical
functionality to this problem would be to make the subject {self} line to
work as expected.

View this message in context: http://www.nabble.com/-RSpec--implicit-receiver-for-should-problem-when-helper-predicate-methods-are-in-use-tp23432383p23432383.html
Sent from the rspec-users mailing list archive at Nabble.com.

More information about the rspec-users mailing list