Skip to content

Instantly share code, notes, and snippets.

@JunichiIto
Created July 24, 2013 03:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JunichiIto/6067960 to your computer and use it in GitHub Desktop.
Save JunichiIto/6067960 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe Spree::Product do
let(:product) {FactoryGirl.create(:product)}
let(:variant) {product.master}
describe '#no_expires' do
let(:expired_products) {Spree::Product.no_expires}
before do
variant.expired_at = expired_at
variant.save!
end
context "when product is expired" do
let(:expired_at) { 1.month.ago }
it "should be empty" do
expect(expired_products).to be_empty
end
end
context "when product is not expired" do
let(:expired_at) { 1.month.from_now }
it "should be have 1 item" do
expect(expired_products).to have(1).item
end
end
context "when expired_at is not set" do
let(:expired_at) { nil }
it "should be have 1 item" do
expect(expired_products).to have(1).item
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment