Skip to content

Instantly share code, notes, and snippets.

@markprovan
Created April 9, 2012 15:20
Show Gist options
  • Select an option

  • Save markprovan/2344197 to your computer and use it in GitHub Desktop.

Select an option

Save markprovan/2344197 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe SearchRequest do
it { should validate_presence_of(:query) }
it { should have_many(:products) }
before do
@search_request = FactoryGirl.build(:search)
@recent_search = FactoryGirl.build(:recent_search)
end
it "should have a query" do
@search_request.query.should == "Black Hawk Down"
end
it "should update products if last search was more than 15 minutes ago" do
@search_request.outdated?.should be_true
end
it "should not update if last search was less then 15 minutes ago" do
@recent_search.outdated?.should be_false
end
context "when the search has products" do
before do
@search_with_products = FactoryGirl.create(:search_with_products, :product_count => 5)
end
it "should have products" do
@search_with_products.products.count.should == 5
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment