I’ve been banging my head on this for about 2 days now… absolutely LOVE rails. But need better direction when it comes to debugging tests..
I’m working through implementing the “test_buying_a_product” Integration Test (test_user_stories.rb)
However.. every time I run it. It fails and says:
<1> expected but was
assert_equal 1, orders.size
So its going through everything fine. Adds an item to the cart, proceeds to checkout, checks out, empties the cart, but the order itself doesn’t save to the test database? (sqlite3)
Here’s the store#checkout action which saves the checkout form from the store controller. *Note: I merged the checkout & save order actions into one:
def checkout if @cart.items.empty? redirect_to_index else @order = Order.new(params[:order]) if request.post? and params[:order] @order.add_line_items( @cart.get_cart_items) @order.save session[:cart] = nil redirect_to_index(“Thanks for your order!!”) else render :action => ‘checkout’ end end end
As if this isn’t odd enough… it works fine via the live app. Is there some issue with the test database maybe? I queried test.sqlite3 from the command line and selected * from orders to SEE if they were any orders in the database and this is what it returned:
953125641|MyString|MyText|MyString|2009-04-20 18:12:40|2009-04-20 18:12:40|MyString
996332877|MyString|MyText|MyString|2009-04-20 18:12:40|2009-04-20 18:12:40|MyString
Odd. It has to Orders, yet the columns are filled with “Mystring” “MyText” is this common in the test database?
Any ideas? Help! -=D