Days ago i was writing an Rspec macro to gracefully handle authenticated api via a token. At the start i begun creating a couple of methods, each for every Rest verb: module RequestMacros def get_authorized(uri, user) get uri, nil, {'X-Api-Token' => user.api_token} end

  def post_authorized(uri, data, user, headers = {})
    post uri, data, headers.merge({'X-Api-Token' => user.api_token})
  end
Read on