On Fri, Jun 7, 2013 at 5:02 AM, Oliver Jesus <oliverjesus2...@yahoo.com>wrote:
> Hello, I am new to RSpec and I've got error something like this: > You have a nil object when you didn't expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.collect > > In my controller: > > def new > @employee_mst = EmployeeMst.new > @branch_mst = BranchMst.all(:group => "branch_code") > @department_mst = DepartmentMst.all > > respond_to do |format| > format.html # new.html.erb > format.xml { render :xml => @employee_mst } > format.xml { render :xml => @branch_mst } > format.xml { render :xml => @department_mst } I've never seen more than one use of the same format in a respond_to block like this. I don't know if it's related to your issue, but I'm curious if you saw this documented somewhere as being supported. > end > end > > In my RSpec controller: > > describe "GET new" do > it "assigns a new employee_mst as @employee_mst" do > get :new > assigns(:employee_mst).should be_a_new(EmployeeMst) > end > end > > > I think something is missing in RSpec controller, because I've add 4 lines > of codes: > @branch_mst = BranchMst.all(:group => "branch_code") > @department_mst = DepartmentMst.all > format.xml { render :xml => @branch_mst } > format.xml { render :xml => @department_mst } > > Please help me regarding this error. I greatly appreciated all those > answers. Please run the example with the backtrace flag: rspec spec/controllers --backtrace and then post the full backtrace so we can see where that error is being raised.
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users