2 require 'capybara/rails'
3 require 'capybara/poltergeist'
7 class ActionDispatch::IntegrationTest
8 # Make the Capybara DSL available in all integration tests
10 include ApiFixtureLoader
12 @@API_AUTHS = self.api_fixture('api_client_authorizations')
14 def page_with_token(token, path='/')
15 # Generate a page path with an embedded API token.
16 # Typical usage: visit page_with_token('token_name', page)
17 # The token can be specified by the name of an api_client_authorizations
18 # fixture, or passed as a raw string.
19 api_token = ((@@API_AUTHS.include? token) ?
20 @@API_AUTHS[token]['api_token'] : token)
21 sep = (path.include? '?') ? '&' : '?'
22 q_string = URI.encode_www_form('api_token' => api_token)
23 "#{path}#{sep}#{q_string}"