[rspec-users] "user" received unexpected message :created_at with (no args)

S Ahmed sahmed1020 at gmail.com
Wed Jun 29 13:21:07 EDT 2011


My method looks like:

def self.can_do_this(user)
  return false if user.nil?
  (  (Time.now >= user.created_at) ? true : false  )
end

my spec:

it "should allow you to do this" do
  user = stub("user")
  user.stub(:nil?).and_return(false)
  user.stub(:created_at).and_return(Time.now)

  res = User.can_do_this(user)
  res.should == true
end

Running the spec I get:

Failer/Error: res = User.can_do_this(user)
Stub "user" received unexpected message :created_at with (no args)


Any ideas?

Thanks allot for the help!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110629/88768fe5/attachment.html>


More information about the rspec-users mailing list