0
現在我用rr gem來存根項目模型計數方法,然後我複製索引動作來檢查計數方法是否被調用。我打算使用摩卡寶石,但我不知道什麼是assert_received
方法摩卡寶石的等值。以下代碼是我測試的例子之一。rm gem assert_remived當前在摩卡寶石
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