I am actually a newbie in Ruby rails nd Rspec.. So it could be something basic.. Plz helpp This is my rspec test code:: describe "GET new" do it "assigns a new kase as @kase" do get :new assigns(:kase).should be_a_new(Kase) end end Its failing saying: KasesController GET new assigns a new kase as @kase Failure/Error: assigns(:kase).should be_a_new(Kase) expected nil to be a new Kase(id: integer, name: string, description: text, item_loc_id: integer, created_at: datetime, updated_at: datetime, previous_visit_id_cache: integer) # ./spec/controllers/kases_controller_spec.rb:37 -- Posted via http://www.ruby-forum.com/.
I think that maybe you are declaring your :kase in somewhere, but this assigns need to receive a new object, you could try pass Kase.new instead of :kase. regards 2012/4/4 Lunarose A. <lists at ruby-forum.com>> I am actually a newbie in Ruby rails nd Rspec.. So it could be something > basic.. Plz helpp > > > This is my rspec test code:: > > describe "GET new" do > it "assigns a new kase as @kase" do > get :new > assigns(:kase).should be_a_new(Kase) > end > end > > > Its failing saying: > > KasesController GET new assigns a new kase as @kase > Failure/Error: assigns(:kase).should be_a_new(Kase) > expected nil to be a new Kase(id: integer, name: string, > description: text, item_loc_id: integer, created_at: datetime, > updated_at: datetime, previous_visit_id_cache: integer) > # ./spec/controllers/kases_controller_spec.rb:37 > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-- thiagocifani http://thiagocifani.wordpress.com/ twitter.com/thiagocifani del.icio.us/thiagocifani <http://del.icio.us/thiagocifani> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20120404/0a72f498/attachment-0001.html>
On Wed, Apr 4, 2012 at 7:47 AM, Lunarose A. <lists at ruby-forum.com> wrote:> I am actually a newbie in Ruby rails nd Rspec.. So it could be something > basic.. Plz helpp > > > This is my rspec test code:: > > ?describe "GET new" do > ? ?it "assigns a new kase as @kase" do > ? ? ?get :new > ? ? ?assigns(:kase).should be_a_new(Kase) > ? ?end > ?end > > Its failing saying: > > ? KasesController GET new assigns a new kase as @kase > ? ? Failure/Error: assigns(:kase).should be_a_new(Kase) > ? ? ? expected nil to be a new Kase(id: integer, name: string, > description: text, item_loc_id: integer, created_at: datetime, > updated_at: datetime, previous_visit_id_cache: integer) > ? ? # ./spec/controllers/kases_controller_spec.rb:37This looks like the controller spec generated when you run `rails generate scaffold ...`. If so, did it fail immediately after generating it? Or did you change something in the controller since you generated it? Would you please post the controller code (at least the :new action)?