3
私が入れ子になっているリソースによって変更されません:仕様Iを実行している間asset_actions_controller_spec.rbテストネストされたリソースコントローラ - カウントが1つの
before(:each) do
@portfolio = Factory(:portfolio)
end
describe "POST create" do
describe "with valid params" do
it "creates a new AssetAction" do
expect {
post :create, :asset_action => valid_attributes, :portfolio_id => @portfolio.id
#@portfolio.asset_actions.create! valid_attributes #WORKS correctly, but this is Model
}.to change(@portfolio.asset_actions, :count).by(1)
end
end
end
:
resources :portfolios do
resources :asset_actions
end
そしてRSpecのコントローラ次次のエラーが発生しました:
Failure/Error: expect {
count should have been changed by 1, but was changed by 0
私は 'この失敗の理由を見つけることはできません。助言がありますか?
注: Railsの3.1.3、Rubyの1.9.3p5、RSpecの2.8.0
デストラクションアクションのテスト中に同じ問題が発生する – dpaluy