How to specifiy the query string in an RSpec test of a Rails controller action? How to specifiy the query string in an RSpec test of a Rails controller action? ruby ruby

How to specifiy the query string in an RSpec test of a Rails controller action?


In newer versions for RSpec, you must declare query string params using the params key:

get :yearly_csv, params: { demand: 'true' }


In an RSpec controller spec, specify query parameters as a hash argument to get:

describe YourController  describe '#yearly_csv'    # set up    get :yearly_csv, demand: 'true'    # assert results  endend