require 'spec_helper'
describe MachineGamesController do
describe 'GET search' do
it 'blah blah' do`
get :search, name: 'some_machine_games'
expect(response).to be_redirected_to(machine_game_path('some_machine_games'))
end
end
以上是我用來測試控制器的rspec。它也放置在/ spec/controllers /目錄中。我得到一個NoMethodError:未定義的方法`redirected_to?
NoMethodError:
undefined method `redirected_to?' for #<ActionController::TestResponse:0x007fce065ba640>
有沒有人知道爲什麼?
,如果我嘗試,我應該得到以下錯誤未定義的方法'應該」的#<:: RSpec的期望:: ExpectationTarget:0x007ff983ad1a90> – 2013-02-28 18:56:05
有趣的嘗試...這個:expect(response).to redirect_to(machine_game_path('some_machine_games')) – Nobita 2013-02-28 19:05:35
預期的響應是<:redirect>,但是<200>是我現在得到的。有什麼我做錯了嗎? – 2013-02-28 19:15:47