0

How I can test ActiveRecord model relationship let's say:

class Order < ActiveRecord::Base
  belongs_to :bucket
end

I would like to use Rspec + NullDB to test bucket association, so I need to test it without touching db.

Leszek Andrukanis
  • 2,114
  • 2
  • 19
  • 30

1 Answers1

0

Take a look at this question: Correct way of testing "associations" with Rspec?

I believe shoulda gem will help you.

You will be able to write something like that using it.

describe Order do
  it { should belong_to(:bucket) }
end
Community
  • 1
  • 1
Victor Ronin
  • 22,758
  • 18
  • 92
  • 184