以下是我遇到的问题。我不确定如何将正确的参数传递给此控制器操作。
def get_standards
@standard_children, @temp = Standard.browse(params[:guid])
@parent_standard = params[:guid]
respond_to do |format|
format.js
end
end
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
Failure/Error: assigns(:standard_children).should == @stateOne
expected: #<Standard:0x3ffed4e53d88 @name="Standard_1001">
got: nil (using ==)
答案 0 :(得分:8)
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