Created
July 24, 2013 03:52
-
-
Save JunichiIto/6067960 to your computer and use it in GitHub Desktop.
Refactoring of http://dev.yukashikado.co.jp/post/56232324090/rails-ec-spree
This file contains 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
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