有誰知道如何規定主動支持通知?以下似乎並不奏效。它檢測到默認的rails框架通知,但不是我的自定義框架通知。使用rspec測試ActiveSupport ::通知
it 'sends a "product.search" notification to any subscribers listening'
ActiveSupport::Notifications.should_receive(:instrument).with("product.search", :search => search)
get :search, ...
end
如果我改變規格,檢查用戶的代碼它傳遞(創建數據庫記錄時,例如記錄數的變化)的結果。這證實它工作正常。但是,規定用戶在這裏做什麼似乎是錯誤的,我只想規定通知正在發送。任何想法將不勝感激。
編輯:
這裏是我試圖符合規範的控制器代碼:
ActiveSupport::Notifications.instrument("product.search", :search => 'test')
是你的標籤'rpsec'是一個錯字? [可能是'rspec'? – Shad