Let me preface this be saying that I'm newb to both TDD and Ruby on Rails.
I'm using Rspec to perform unit testing of my data layer and to ensure that my database is rejecting invalid input.
My rspec code looks as follows:
it "should fail at saving without name" do
@my_data.attributes = valid_my_data_attributes.except(:name)
@my_data.save_with_validation( false ).should be_false
end
My database (Postgres) is correctly rejecting the data, but rather than returning false, it is throwing an error. How would I correctly catch that error and pass the test?
Thanks!