I’ve heard about TDD, read about TDD, and now I’m trying to practice it.
However, I’m getting stuck trying to do a simple test in rails 2.2.2.
I’ve decided to try writing a simple functional test to test the
‘add_item’ action of my cart controller.
However, I got as far as this before my test was already not running:
test “should add an item to the cart” do
end
My cart controller uses two ‘fake’ models (cart_session,
cart_session_line_item) that aren’t activerecords. however i’m getting
this error message:
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table:
cart_sessi
on_line_items: DELETE FROM “cart_session_line_items” WHERE 1=1
for the life of me, I don’t understand why my test would be hitting the
database yet when my test body is blank and why it thinks that
cart_session_line_item is an activerecord when it’s not wired up as
such.
i know TDD is a good thing, and any help would be greatly appreciated!
On Tuesday 20 January 2009 03:50 am, Roderick van Domburg wrote:
I take that back and you are right. Must have had my head up in the
clouds at that time of writing.
Maybe me too–I’ve been watching this thread waiting for a clue as to
what TDD is–my out of the blue guess is Top Down Design, but I’ll do
better to ask…?
Randy K.
I didn’t have time to write a short letter, so I created a video
instead.–with apologies to Cicero, et.al.
On Tuesday 20 January 2009 03:50 am, Roderick van Domburg wrote:
I take that back and you are right. Must have had my head up in the
clouds at that time of writing.
Maybe me too–I’ve been watching this thread waiting for a clue as to
what TDD is–my out of the blue guess is Top Down Design, but I’ll do
better to ask…?
Randy K.
not a bad guess, but try Test Driven Design/Development.
Well, I figured it out, so I’m going to update my thread and hopefully
help someone in the future.
The problem was in test_helper.rb on this line:
fixtures :all
Anyways, thanks for everyone’s responses. And thanks to Phlip’s
suggestion about starting out with unit tests. They were much easier to
start with, and now I feel more comfortable with tests.
Randy K. wrote:
On Tuesday 20 January 2009 08:19 am, Matt H. wrote:
not a bad guess, but try Test Driven Design/Development.