Rspec Controller Passing Params

controllers, rspec, ruby-on-rails-3

Solution

describe "Get Standards" do
 it "should return correct values" do
   @stateOne = mock_model(Standard, description: "beta")
   Standard.stub!(:browse).and_return(@stateOne, "temp")     

   get :get_standards, :guid => 'one'
   assigns(:parent_standard).should == 'one' 
   assigns(:standard_children).should == @stateOne             
 end
end  

Problem

Below is the problem I am having. I am not sure how to pass the correct params to this controller action. The code ``` def get_standards @standard_children, @temp = Standard.browse(params[:guid]) @parent_standard = params[:guid] respond_to do |format| format.js end end ``` The Rspec ``` describe "Get Standards" do it "should return correct values" do @stateOne = mock_model(Standard, description: "beta") Standard.stub!(:browse).and_return(@stateOne, "temp") assigns(:standard_children).should == @stateOne assigns(:parent_standard).should == 'one' get :get_standards, :params => {guid: 'one'} end end ``` The Error ``` Failure/Error: assigns(:standard_children).should == @stateOne expected: #<Standard:0x3ffed4e53d88 @name="Standard_1001"> got: nil (using ==) ```

Original source