The Ultimation
2011-Feb-08 17:25 UTC
[rspec-users] Model validation failing in rspec for unknown reason
Hi, i''m getting the following error when running a spec on my controller for my Equipment model. it "edit action should render edit template" do get :edit, :id => Factory(:equipment) response.should render_template(:edit) end Failure/Error: get :edit, :id => Factory(:equipment) ActiveRecord::RecordInvalid: Validation failed: The test is very simple, it builds an Equipment factory and tests to see if the edit template loads. This test works for every other model, and I tried removing all validations from this model but still no luck. Everything works on the webpage, just not in this test. I even created the factory successfully in command line without error. I''m just stumped as to what''s going on. When i use --backtrace, it doesn''t really shed any light either. It''s just not saving because of an unknown validation failure. The only thing I can think of that might be causing an issue is an inflection that i use for this model. Here it is: ActiveSupport::Inflector.inflections do |inflect| inflect.irregular ''equipment'', ''equipments'' end Any help would be greatly appreciated. Thanks! -- Posted via http://www.ruby-forum.com/.
Nick
2011-Feb-08 19:04 UTC
[rspec-users] Model validation failing in rspec for unknown reason
On Tuesday, February 8, 2011 12:25:30 PM UTC-5, The Ultimation wrote:> > Hi, i''m getting the following error when running a spec on my controller > for my Equipment model. > > it "edit action should render edit template" do > get :edit, :id => Factory(:equipment) >Shouldn''t you pass an ID to the "id" key, rather than a model instance? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110208/883e47e0/attachment.html>
The Ultimation
2011-Feb-08 19:17 UTC
[rspec-users] Model validation failing in rspec for unknown reason
Nick Hoffman wrote in post #980380:> On Tuesday, February 8, 2011 12:25:30 PM UTC-5, The Ultimation wrote: >> >> Hi, i''m getting the following error when running a spec on my controller >> for my Equipment model. >> >> it "edit action should render edit template" do >> get :edit, :id => Factory(:equipment) >> > Shouldn''t you pass an ID to the "id" key, rather than a model instance?I''ve tried every method of passing the id in, still same error :/ -- Posted via http://www.ruby-forum.com/.
jnimety
2011-Mar-20 00:35 UTC
[rspec-users] Model validation failing in rspec for unknown reason
I just ran into this. I had added a bit of code to allow reload Factories in the rails console. This was causing the Factories to reload on every request, resetting my factory sequences, causing the validation errors. Hope this helps. On Feb 8, 3:17?pm, The Ultimation <li... at ruby-forum.com> wrote:> Nick Hoffman wrote in post #980380: > > > On Tuesday, February 8, 2011 12:25:30 PM UTC-5, The Ultimation wrote: > > >> Hi, i''m getting the following error when running a spec on my controller > >> for my Equipment model. > > >> ? ? it "edit action should render edit template" do > >> ? ? ? get :edit, :id => Factory(:equipment) > > > Shouldn''t you pass an ID to the "id" key, rather than a model instance? > > I''ve tried every method of passing the id in, still same error :/ > > -- > Posted viahttp://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users