On Sat, Jul 11, 2009 at 10:42 AM, Michael<magic6...@gmail.com> wrote: > Simply testing that my validations are working for a model called > Project. > > MODEL > class Project < ActiveRecord::Base > validates_presence_of :brief > end > > SPEC > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') > > describe Project do > before(:each) do > �...@project = Project.new(:title => "project title", :brief => > "project brief") > end > > it "should create a new instance given valid attributes" do > �...@project.should be_valid > end > end > > ERROR > ActiveRecord::RecordInvalid in 'Project should create a new instance > given valid attributes' > Validation failed: Brief can't be blank > > > POST > How on earth can that be failing? its driving me nuts, i have a few > other tests that check the exact same way(method taken from the Rspec > book) so why all the sudden would it stop working on a new model. Blah > thanks for any help.
The fact that it's raising an error suggests that something is trying to save the Project. Otherwise you'd just get back something like "expected valid? to be true". Since rspec-rails doesn't try to save the record, my guess is that there is some other code introducing itself. Either in the application code, a plugin, or perhaps an rspec extension library that has its own be_valid matcher. Any of that feasible? > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users