Rspec: testing assignment of instance variable

前端 未结 2 1568
天涯浪人
天涯浪人 2021-02-03 19:43

Using Rspec with Factory Girl. Trying to check out what data is being assigned in my controller (and test against it). Every post I\'ve read says I should be able to get someth

2条回答
  •  遥遥无期
    2021-02-03 20:03

    You have to invoke the action first

    
    describe StickiesController do
      describe "GET index" do
        it "should assign stickies" do
          get :index
          assigns(:stickies).should_not be_nil
        end
      end
    end
    

提交回复
热议问题