Error in running RSpec. 2.13.1

73 views Asked by At

I have written a spec file for update function of one controller. I am using ruby-1.9.3 p194, Rails 3.2.13 and rspec 2.13.1 and data mapper version ~> 1.2.0'. I am calling update function in my spec as follows:

put :update, :id=>@xyz.id, :xyz=> {key1:val1, key2:val2}

In update function of my xyz controller I have accessed id as follows:

def update
 params[:xyz][:id] = params[:id]  #This line is working fine and params[:id] is not nil
 params = params[:xyz]
 id = params[:id]               
end

Problem is that while I am running the same file without any change twice at a time, it is giving two different errors. Once it is giving the following error:

/home/joy/.rvm/gems/ruby-1.9.3-p194@packageName/gems/dm-core-1.2.0/lib/dm-           
 core/collection.rb:1302: in resource undefined method 'saved?' for nil:NilClass 
(NoMethodError) 
....

Next time, while running, it is giving the following error:

NoMethodError:
  undefined_method 'id' for "57":string"
# ./app/controllers/xyz_controller.rb : in line number 3 of update where I am setting the id is giving error.

Is this the case the ruby version or the rspec or data-mapper version I am using is unstable or there is any other problem that I could not figure out. Please help.

0

There are 0 answers