deep
deep

Reputation: 97

Rspec Controller Passing Params

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 ==)

Upvotes: 2

Views: 7724

Answers (1)

Rustam Gasanov
Rustam Gasanov

Reputation: 15781

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  

Upvotes: 8

Related Questions