making two requests to the same controller in rails integrations specs

后端 未结 5 2043
鱼传尺愫
鱼传尺愫 2021-02-12 19:17

I\'m having problem making two requests to the same url in a rails integration test, with rspec

it \'does something\' do

  # get \'/something\', {:status=>\'         


        
5条回答
  •  一向
    一向 (楼主)
    2021-02-12 19:45

    You have to clear your instance variables, or maybe the only necessary one. Let's pretend you use @book in your controller.

    get '/something'
    assert ...
    controller.instance_variable_set(:@book, nil)
    get '/something'
    assert ...
    

    If you are using inherit_resources

    get '/something'
    assert ...
    controller.send(:set_resource_ivar, nil)
    get '/something'
    assert ...
    

提交回复
热议问题