Sha256: 0d271745896a5ba051e398106fe70b8e23a2e6f51ba806a5c91522f6de3bfeed

Contents?: true

Size: 888 Bytes

Versions: 2

Compression:

Stored size: 888 Bytes

Contents

require 'spec_helper'

describe Appsignal::Grape::Middleware do

  class TestAPI < Grape::API
    prefix "api"
    version "v1"
    use Appsignal::Grape::Middleware

    resource :hello do
      get ':name' do
        "hello #{params['name']}"
      end
    end
  end

  def app; TestAPI; end

  let(:event) { @events.pop }
  subject { event.payload }

  before(:all) do
    @events     = []
    ActiveSupport::Notifications.subscribe('process_action.grape.api.v1.hello.mark') do |*args|
      @events << ActiveSupport::Notifications::Event.new(*args)
    end
  end

  before(:each) do
    get "api/v1/hello/mark"
  end

  it do
    should == { method: "GET" , path: "api/:version/hello/:name", action: "GET.api.v1.hello.mark"}
  end

  context "verify the api request" do
    subject{ last_response }

    its(:body){ should == "hello mark" }
    its(:status){ should == 200 }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
grape-appsignal-0.1.1 spec/grape-appsignal/middleware_spec.rb
grape-appsignal-0.1.0 spec/grape-appsignal/middleware_spec.rb