-3
_spec.rb導軌工廠女孩比較失敗
context 'find discount coupon' do
it 'if coupon suitable for use' do
coupon = Factory(:standart_discount_coupon)
DiscountCoupon.find_discount_coupon(coupon.coupon_no).should eql({:success => true, :error => nil, :coupon_id => coupon.id })
end
end
我有這樣的試驗,當我運行它,我遇到這個錯誤。
1) DiscountCoupon find discount coupon if coupon suitable for use
Failure/Error: DiscountCoupon.find_discount_coupon(coupon.coupon_no).should eql({:success => true, :error => nil, :coupon_id => coupon.id })
expected: {:success=>true, :error=>nil, :coupon_id=>1060}
got: {:success=>true, :error=>nil, :coupon_id=>1046}
(compared using eql?)
Diff:
@@ -1,4 +1,4 @@
-:coupon_id => 1060,
+:coupon_id => 1046,
:error => nil,
:success => true
爲什麼copon_id的不同?
這隻意味着您在數據庫中有多張優惠券,且coupon_no相同。在運行該測試之前,您可能想試試'DiscountCoupon.destroy_all'。 – 2013-04-07 18:41:46