にもかかわらず、私は自分のアプリケーションのモデル、accepts_nested_attributes_for(:user)
のモデルテストを書いているaccept_nested_attributes_forに失敗しました。ここで失敗のテストです:RSpecの+のshouldaテストは関係
describe UserApplication, "associations" do
it { should belong_to(:user) }
it { should accept_nested_attributes_for(:user) }
end
そして、ここでは、モデルの:
class UserApplication < ActiveRecord::Base
#attr_accessible all the fields
belongs_to :user
accepts_nested_attributes_for :user
end
私はshoulda-マッチャ2.8とRSpecのを使用していて、私の研究から、これはすべて正常に動作する必要があります。春も、他の奇妙さもありません。私が見ているエラーは次のとおりです。
1) UserApplication association
Failure/Error: it { should accept_nested_attributes_for(:user) }
NoMethodError:
undefined method `accept_nested_attributes_for' for #<RSpec::Core::ExampleGroup::Nested_2:0x007fec5c641a40>
# ./spec/models/user_application_spec.rb:25:in `block (2 levels) in <top (required)>'
何が原因か分かりません。これは奇妙な宝石紛争の嫌悪者かもしれないか、私は何か明白な行方不明ですか?
should-matcherを最新バージョンにアップグレードしてもう一度試してみることはできますか?その特定のバージョンのドキュメントを見ることができません –
@AnezioCampos shoulda-matcherを3.0にアップデートすると、私は現時点ではできないactivesupportを4.0にアップデートする必要があります。私はしばらくの間、レール3.2で立ち往生しています。 – octopushugs
これは 'accept_nested_attributes_for(:user)}'は '' accepts_nested_attributes_for(:user)} ''でなければなりません。 '' accepts''に 's'がありません... ' ' – Hackerman