[rspec-users] Validations aren't being performed when running 'rspec spec'

Tom Milewski tmilewski at gmail.com
Fri Feb 25 11:58:14 EST 2011


Thanks for all of your insight guys.

As it turned out the culprit was
".any_instance.stubs(:valid?).returns(false)" which was being run in
the controllers.
I changed some things around any now everything is working as
expected.

I was using the following:

Rails 3.0.0
RSpec 2.4.0
RSpec Rails 2.4.1
Factory Girl 2.0.0.beta1

Thanks again!

On Feb 24, 2:26 pm, Craig Demyanovich <cdemyanov... at gmail.com> wrote:
> On Thu, Feb 24, 2011 at 2:07 PM, Tom Milewski <tmilew... at gmail.com> wrote:
> > Thanks for the replies.
>
> > Here's the error I'm seeing when running all specs (.build
> > and .create):
>
> > Agent while creating should ensure that name is present
> >     Failure/Error: Factory(:public_agent, :name => nil).should
> > have(1).error_on(:name)
> >        expected 1 error on :name, got 0
> >     # ./spec/models/agent_spec.rb:35:in `block (3 levels) in <top
> > (required)>'
>
> > Here's what I'm seeing when running model specs with .create:
>
> > Agent while creating should ensure that name is present
> >     Failure/Error: Factory(:public_agent, :name => nil).should
> > have(1).error_on(:name)
> >      ActiveRecord::RecordInvalid:
> >       Validation failed: Name can't be blank
> >     # ./spec/models/agent_spec.rb:35:in `block (3 levels) in <top
> > (required)>'
>
> > Everything passes when running model specs with .build.
>
> Have you tried with Agent.new and/or Agent.create? Maybe factory_girl is
> doing something strange.
>
> Also, what versions of rails, rspec-rails, rspec and factory_girl are you
> using?
>
> Craig
>
> _______________________________________________
> rspec-users mailing list
> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users


More information about the rspec-users mailing list