アプリ: Sinatra + ActiveRecord
ベスト プラクティスを使用して関連付けの存在をテストしようとしています。
私は Shoulda の構文がとても気に入っています。
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)>'
ヒントはありますか?
Shoulda アソシエーション テストは Rails アプリ (rspec-rails を使用) でのみ機能しますか?
ありがとうございました。