简体   繁体   中英

Rails: best way to log GET requests in specs

I am a complete Ruby and Rails newbie, so please excuse the question. Given a spec making a GET request: get :filter_by_foo, params: {Foo: Bar}

What is the best way to output the generated GET requests?

there should be two variables available to you in the test case called request and response . if i understand your question correctly, you'd want to p request inside your test case

describe SomeController do
  before(:each) { get :filter_by_foo, params: {Foo: Bar} }

  it 'should have some variables available' do
    p request
    # p response
    expect(true).to be(true)
  end
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM