> Please make sure, when you ask a question, that you quote enough of
> the thread so that the readers can understand what you're asking.
Hmmm, I don't have this problem as I am using ruby-forum.com to browse
threads, it is x100 times more readable with basic color highlighting.
I'll do my best to include quotes for people who use regular mail
clients.
So here is my controller code:
--
def index
@items = Item.find_for_payment(session[:order_id], @site.id)
@cart.amount = @items.sum { |item| item.price.to_i *
item.quantity.to_i }
end
--
And my spec:
--
it "should display cart" do
@items = []
1.upto(2) do |i|
@items << mock_model(Item, :id => i, :price => 10 * i, :quantity
=> i, :order_id => 1)
end
Item.stub!(:find_for_payment).and_return(@items)
@cart = mock_model(Order, :id => 1, :amount => 0, :tax => 0)
Order.stub!(:find_cart).and_return(@cart)
Item.should_receive(:find_for_payment).with(1, 1).and_return(@items)
@cart.should_receive(:amount=).with(50)
@cart.amount.should eql(50)
get :index
end
--
This throws the error: expected 50, got 0 (using .eql?)
As I said, I don't actually save the @cart object in DB, I just
temporarily set its amount attribute so that it will print the value in
the corresponding view. I am now wondering why RSpec doesn't see it is
set to 50.
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users