应用: Sinatra + ActiveRecord describe Bar do end
但是,RSpec似乎找不到belong_to方法。method `belong_to' for #<RSpec::Core::ExampleGroup::Nested_1:0x00000103ac6760>
我有三个模型组成了一个基本的has_many through关系: validates_presence_of :user, :ridethrough: :bookingsendRSpec.describeBooking, type: :model do
it { should belong_to</em
我有两个通过belongs_to和has_many关系链接在一起的模型,如下所示。Baseend
has_many other_models我现在有了相应的测试来验证它们之间的关系是否正确RSpec.describe MyModel, type: :model do it {should respond_t
我正在使用rspec-rails测试我的rails应用程序,尤其是对于模型,应该使用-matcher。当我在本地运行这些测试时,它们都运行得很好,但是当我部署到Team City服务器时,每个使用shoulda-matcher的测试都会失败,因为它找不到应该由shoulda-matcher提供的方法。例如,一个规范以以下代码开头:describe Availability do
it { should belong_to</
我得到了这个: Failure/Error: it { should belong_to(:user) } undefinedmethod `belong_to' for #<RSpec::ExampleGroups::Image_2:0x007fde82448d70 @__memoized=nil>
# .的关联。所以安装了一个名为'mongoid-rspec‘的</em
我的模型有default_scope(:order => 'created_at‘)我的测试(rspec,factory girl,shoulda等)包括: subject { Factory.build(:cat_membership) } it { should belong_to:cat}
it { should <em