2016-06-30 4 views
0

내 응용 프로그램 모델에 대한 모델 테스트 인 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 

을 그리고 여기 모델의 : 여기에 실패한 것 테스트입니다 나는이해야 모든 작업의 ​​벌금을 했어야 - 정합 기 2.8 RSpec에 사용, 내 연구에서있어

class UserApplication < ActiveRecord::Base 
    #attr_accessible all the fields 

    belongs_to :user 
    accepts_nested_attributes_for :user 
end 

. 봄이나 다른 이상한 것도 없습니다. 내가보고있는 오류는 다음과 같습니다.

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)>' 

나는 이것을 일으킬 수 있는지 잘 모르겠습니다. 이게 이상한 보석 갈등의 헛소리가 될 수 있을까?

+0

should-matcher를 최신 버전으로 업그레이드하고 다시 시도 할 수 있습니까? 특정 버전의 문서를 볼 수 없습니다. –

+0

@AnezioCampos 3.0으로 shoulda-matcher를 업데이트하려면 4.0으로 activesupport를 업데이트해야합니다. 현재로서는 불행히도 할 수 없습니다. 나는 레일 3.2에 당분간 붙어있다. – octopushugs

+0

이'it accept_nested_attributes_for (: user)}'는'accepts_nested_attributes_for (: user)}'에 있어야합니다. ('accepts'에's'가 없습니다 ... – Hackerman

답변

0

좋아요, 그래서 저는 틀린 것을보기 위해 @PeterAlfvin에게 도구를 주어야합니다. 내 gemfile은 gem 'shoulda-matchers'으로 지정되었지만 버전 1.0 만로드되었으므로 accepts_nested_attributes_for에 대한 지원이 없습니다. 그의 제안은 https://stackoverflow.com/a/2954632/1008891을 통해 올바른 방향으로 나를 가리켰다. 2.8.0을 지정하면 즉시 문제가 해결되지 않고 문제가 해결되었습니다.