I should also note that if I replace ".should have(1).error_on(:name)"
with, simply, ".should be_valid". The same issues occur. All specs
(except when only running models) pass when they shouldn't be.

On Feb 24, 8:48 am, David Chelimsky <dchelim...@gmail.com> wrote:
> On Feb 23, 2011, at 9:29 AM, Tom Milewski wrote:
>
>
>
>
>
>
>
>
>
> > Hello,
>
> > When I run 'rspec spec/models' everything runs beautifully.
> > When I run 'rspec spec/controllers' everything also runs beautifully.
> > When I run 'rspec spec' the models seem to forget that the records
> > need to pass the validations before being saved to the database.
>
> > This is consistent across all model tests which are checking
> > validations.
>
> > Model:
>
> > validates_presence_of :name, :location, :email...
>
> > Test:
>
> > it "should ensure that name is present" do
> >      Factory.build(:public_agent, :name => nil).should 
> > have(1).error_on(:name)
>
> Factory.build ^^ doesn't even save records to the database in the first 
> place, so it would be surprising if this were the example that is causing 
> trouble.
>
> Do you have any other specs besides models and controllers? helpers, mailers, 
> requests, etc? I've seen cases in which data was set up in before(:all) 
> (which does not run in a transaction and is therefore not rolled back), and 
> uniqueness validations would fail in other places.
>
> What specific failure messages are you seeing?
>
> > end
>
> > All of these tests do not return errors and do add the invalid records
> > to the database.
>
> > Has anyone else had this happen? Suggestions?
>
> > Thanks!
> > _______________________________________________
> > rspec-users mailing list
> > rspec-us...@rubyforge.org
> >http://rubyforge.org/mailman/listinfo/rspec-users
>
> Cheers,
> David
>
> _______________________________________________
> rspec-users mailing list
> rspec-us...@rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to