응용 프로그램 : Sinatra + ActiveRecord
모범 사례를 사용하여 연결 존재 여부를 테스트하려고합니다.비 Rails 응용 프로그램에서 Shoulda와 ActiveRecord 연관 검사
describe Bar do
it { should belong_to(:foo) }
end
그러나, RSpec에이 belong_to
방법을 찾을 수 없습니다 :
은 정말 진작 구문을 좋아한다.
1) ResOutcome
Failure/Error: it { should belong_to(:foo) }
NoMethodError:
undefined method `belong_to' for #<RSpec::Core::ExampleGroup::Nested_1:0x00000103ac6760>
# ./spec/models/bar_spec.rb:48:in `block (2 levels) in <top (required)>'
어떤 힌트가 있습니까?
연관 테스트는 Rails 앱에서만 작동합니까 (rspec-rails 포함)?
감사합니다.
예, 그렇지만 여전히 기쁨은 ... – jgpawletko
또 다른 아이디어가 있는데, 'spec_helper.rb'에'shoulda/matchers '를 요구하십시오. – luacassus