Search code examples
ruby-on-railsrubyrspecairborne

How to pass params into spec with airborne gem?


I try to write specs for api with gem airborne

How can i pass params into test?

The documentation says:

For requests that require Query params you can pass a params hash into headers.

post 'http://example.com/api/v1/my_api', { }, { 'params' => {'param_key' => 'param_value' } *

But when i try to run simple test with params like this:

    it 'returns correctly status filtered tickets' do
      get 'http://localhost:3000/api/v1/users', { }, { 'params' => {'param_key' => 'param_value' } }
      expect_status(200)
    end

i get error:

ArgumentError:
       wrong number of arguments (given 3, expected 1)`

Solution

  • I changed
    get 'http://localhost:3000/api/v1/users', { }, { 'params' => {'param_key' => 'param_value' } } to get 'http://localhost:3000/api/v1/users', params => {'param_key' => 'param_value' } } and it works.