0

I have the following:

  setup do
    Capybara.current_driver = Capybara.javascript_driver
    @project.user = @user
    @project.save
    Project.any_instance.stubs(:price_all)
  end

And yet I have a test failing because the Project.price_all method is being run:

/Users/me/code/rails/myapp/app/models/project.rb:178:in `price_all'

This was working properly until I upgraded to Capybara 2 and the latest version of capybara-webkit.

Why is that method still being run? And how can I fix?

Vega
  • 27,856
  • 27
  • 95
  • 103
croceldon
  • 4,511
  • 11
  • 57
  • 92

1 Answers1

0

When you say "the Project.price_all method is being run", is that a typo, or is price_all really a class method? If it is indeed a class method, you'll want to use Project.stubs(:price_all) instead of including any_instance so the stub is directly on the Project class rather than an instance of Project. If that's not your issue, I'm not sure what else to suggest based on the code sample you've provided.

Cade
  • 3,151
  • 18
  • 22
  • It's not a class method. I just meant that the price_all method is being called on an instance of the Project class. – croceldon Jan 22 '13 at 19:24