Sha256: 5810f87703216ac7e8a6e1f69461e773611d14083af2e800aa7310020ad23de7

Contents?: true

Size: 655 Bytes

Versions: 15

Compression:

Stored size: 655 Bytes

Contents

require 'introspective_grape/camel_snake'
module RequestHelpers

  def json
    @json ||= CamelSnakeKeys.snake_keys(JSON.parse(response.body), true)
  end

  def with_authentication(role=:superuser)
    return if @without_authentication
    current_user = User.new #double('User')
    allow(current_user).to receive(:admin?) { true }     if role == :superuser
    allow(current_user).to receive(:superuser?) { true } if role == :superuser

    # Stubbing API helper methods requires this very nearly undocumented invokation
    Grape::Endpoint.before_each do |endpoint|
      allow(endpoint).to receive(:current_user) { current_user }
    end
  end
end


Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
introspective_grape-0.5.7 spec/support/request_helpers.rb
introspective_grape-0.5.6 spec/support/request_helpers.rb
introspective_grape-0.5.5 spec/support/request_helpers.rb
introspective_grape-0.5.4 spec/support/request_helpers.rb
introspective_grape-0.5.2 spec/support/request_helpers.rb
introspective_grape-0.5.0 spec/support/request_helpers.rb
introspective_grape-0.4.3 spec/support/request_helpers.rb
introspective_grape-0.4.2 spec/support/request_helpers.rb
introspective_grape-0.4.1 spec/support/request_helpers.rb
introspective_grape-0.4.0 spec/support/request_helpers.rb
introspective_grape-0.3.9 spec/support/request_helpers.rb
introspective_grape-0.3.7 spec/support/request_helpers.rb
introspective_grape-0.3.6 spec/support/request_helpers.rb
introspective_grape-0.3.5 spec/support/request_helpers.rb
introspective_grape-0.3.3 spec/support/request_helpers.rb