First of all, thank you for this amazing book. I’m really enjoying reading. But I’m pretty new to Ruby and specially Rails. However, reading the book about the unit testing I’m a little confused about what output should I be getting.
# Unique title test "product is not valid without a unique title" do product = Product.new(:title => products(:ruby).title, :description => "My description", :price => 1, :image_url => 'lala.jpg') assert !product.save assert_equal I18n.translate('activerecord.errors.messages.taken'), product.errors[:title].join("; ") end
Shouldn’t this give me one failure ? It actually goes without raising none. I even tried to had this:
product = Product.new(:title => products(:ruby).title, :description => "My description", :price => 1, :image_url => 'lala.jpg') product.save
so I knew that it would actually got a duplicated title, but it went fine. I have “validates :title, :uniqueness => true” just so you know.
I’m using OSX Snow, Rails 3.0.1, Ruby 1.9.2p0, rake: 0.8.7
What am I doing wrong here ?