Reiss Johnson
Reiss Johnson

Reputation: 1509

Rspec/Rails test that a method has been called on an object within a controller

If I have the following code...

class Controller
  def create
    object = Foo.new
    object.bar("string")
  end
end

How might I rspec test that my Foo object received my bar method?

Upvotes: 0

Views: 98

Answers (1)

SnehaT
SnehaT

Reputation: 309

If you want to check whether your Foo object has reached your bar method or not, you need to verify whatever the bar method returns or does. If that verification passes, it means your bar method was reached and executed successfully.

Upvotes: 1

Related Questions