Skip to content

Instantly share code, notes, and snippets.

@bogdan
Created June 30, 2010 10:31
Show Gist options
  • Save bogdan/458497 to your computer and use it in GitHub Desktop.
Save bogdan/458497 to your computer and use it in GitHub Desktop.
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
@bogdan
Copy link
Author

bogdan commented Jun 30, 2010

Ultimate rspec matcher to test ActiveRecord named scopes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment