Sha256: 137581dcacf74fc7a2f0b67a9ee6cd5e974d3d6d419964c448f6fa3c189ae16c

Contents?: true

Size: 943 Bytes

Versions: 1

Compression:

Stored size: 943 Bytes

Contents

ENV['RACK_ENV'] ||= 'test'

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))

require 'rack/test'
require 'grape-datadog'

RSpec.configure do |config|
  config.include Rack::Test::Methods
end

class MockStatsd < Statsd
  def timing(stat, ms, opts={}); super(stat, 333, opts); end
  def flush_buffer; end
  alias :send_stat :send_to_buffer
end

class VersionedTestAPI < Grape::API
  version 'v1'
  prefix  'api'

  get('versioned') { "OK" }
end

class TestAPI < Grape::API
  get 'echo/:key1/:key2' do
    "#{params['key1']} #{params['key2']}"
  end

  namespace :sub do
    mount VersionedTestAPI

    namespace :secure do
      get("/resource") { error!("forbidden", 403) }
    end
  end
end

Grape::Datadog.install! do |c|
  c.hostname = "test.host"
  c.statsd   = MockStatsd.new(nil, nil, {}, 10000)
  c.tags     = ["custom:tag", lambda{|e| "format:#{e.env['api.format']}" }]
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grape-datadog-1.3.2 spec/spec_helper.rb