Report abuse

the test

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  describe ".process_aftersale" do
    before do
      @orders = [Order.make, Order.make]
      Order.stub!(:paid).and_return(@orders)
      @orders.stub!(:updated_on).and_return(@orders)
    end

    ....

    it "should send 1 week after sale letters" do
      @orders.should_receive(:updated_on).once.with([1.week.ago])
      Order.process_aftersale
    end

    ...
  end

The error - note that the dates are the same

1
2
3
4
1)
Spec::Mocks::MockExpectationError in 'Order.process_aftersale should send 1 week after sale letters'
#<Order:0xb4e8b3a4>#<Order:0xb4e69448> expected :updated_on with ([Wed, 09 Sep 2009 14:59:59 HKT +08:00]) but received it with ([Wed, 09 Sep 2009 14:59:59 HKT +08:00])
./spec/models/order_spec.rb:42:

the method in Order

1
2
3
4
5
  def self.process_aftersale
    self.paid.updated_on(1.week.ago).each do |o|
      MailingsWorker.asynch_deliver_order_aftersale_to_inquire(:order_id => o.id)
    end
  end