Still following my rails book (more like, adapting to my project as I
go). My first attempt at a unit test failed. Adapting the example in the
book, I came up with this:
class RecordingTest < ActiveSupport::TestCase
test “record attributes must not be empty” do
recording = Recording.new
Which gives me:
is not true.
1 tests, 1 assertions, 1 failures, 0 errors
Command failed with status (1): [/usr/bin/ruby -I"lib:test"
The idea was to test my validation code from the model:
class Recording < ActiveRecord::Base
validate :title, :speaker, :date_of_event, :file, :presence => true
validate :title, :file, :uniqueness => true
From the little I understand, I’m not sure why the record object is not
showing up as invalid as it should, having no data added yet. The only
thing I can note is that I’m using rails 2.3.5, whereas I think the book
is meant for 3.