Skip to content

Instantly share code, notes, and snippets.

@mattm
Created December 3, 2011 04:21
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 mattm/1426014 to your computer and use it in GitHub Desktop.
Save mattm/1426014 to your computer and use it in GitHub Desktop.
## Factory
Factory.define :promo, :class => Promotion do |promo|
promo.code "cm"
promo.quantity 100
promo.remaining 100
promo.description "for chris and mike"
end
## Spec
it "should decrement the promotion code's remaining value by one" do
promo = Factory.create(:promo)
get 'search', :q => 'flower -p cm'
Promotion.find(promo.id).remaining.should == promo.remaining - 1
end
@chrisconley
Copy link

Here's how I would test it:

it "should decrement the promotion code's remaining value by one" do
 promo = Factory.create(:promo, :remaining => 2)
 get 'search', :q => 'flower -p cm'
 promo.reload.remaining.should == 1
end

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