Sha256: 7dfc3457d61935b542330bc9fb49f3ca85f0d2448724555beb02ec68b8fe3417

Contents?: true

Size: 645 Bytes

Versions: 13

Compression:

Stored size: 645 Bytes

Contents

require 'introspective_grape/camel_snake'
module RequestHelpers
  def json
    @json ||= JSON.parse(response.body).with_snake_keys(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

13 entries across 13 versions & 1 rubygems

Version Path
introspective_grape-0.3.2 spec/support/request_helpers.rb
introspective_grape-0.3.1 spec/support/request_helpers.rb
introspective_grape-0.3.0 spec/support/request_helpers.rb
introspective_grape-0.2.9 spec/support/request_helpers.rb
introspective_grape-0.2.8 spec/support/request_helpers.rb
introspective_grape-0.2.7 spec/support/request_helpers.rb
introspective_grape-0.2.6 spec/support/request_helpers.rb
introspective_grape-0.2.5 spec/support/request_helpers.rb
introspective_grape-0.2.4 spec/support/request_helpers.rb
introspective_grape-0.2.3 spec/support/request_helpers.rb
introspective_grape-0.2.2 spec/support/request_helpers.rb
introspective_grape-0.2.0 spec/support/request_helpers.rb
introspective_grape-0.1.9 spec/support/request_helpers.rb