Created
June 30, 2010 10:31
-
-
Save bogdan/458497 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "named scope" do | |
describe "#similar_to" do | |
let(:category) { Factory.create(:category) } | |
let(:product) { | |
Factory.create( | |
:product, :categories => [category] | |
) | |
} | |
subject { described_class.similar_to(product) } | |
let(:similar_product) { | |
Factory.create(:product, :categories => [category]) | |
} | |
let(:not_similar_product) { | |
Factory.create(:product, :categories => [Factory.create(:category)]) | |
} | |
it { should discover(similar_product.group) } | |
it { should_not discover(not_similar_product.group) } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ultimate rspec matcher to test ActiveRecord named scopes