Now I use rr gem to stub Project model count method, and then I replicate index action to check the count method is called or not. I'm planning to use mocha gem but I don't figure out what is the equivalent of assert_received
method in mocha gem. Following code is one of the example of my tests.
require 'test_helper'
class ProjectsControllerTest < ActionController::TestCase
context "on GET to index" do
setup do
stub(Project).count { 30000 }
get :index
end
should "load up the number of gems, users, and downloads" do
assert_received(Project) { |subject| subject.count }
end
end
end
Aucun commentaire:
Enregistrer un commentaire