Sha256: ae92356ef1661d50a1698d79acb9ba8916fe017bc2da1db978d2d17c04bc0810

Contents?: true

Size: 1.56 KB

Versions: 4

Compression:

Stored size: 1.56 KB

Contents

if RUBY_VERSION >= '1.9.3'
  require 'minitest_helper'
  require File.expand_path(File.dirname(__FILE__) + '/apps/grape_simple')

  describe Grape do
    before do
      clear_all_traces
    end

    it "should trace a request to a simple grape stack" do
      @app = GrapeSimple

      r = get "/json_endpoint"

      traces = get_all_traces
      traces.count.must_equal 4

      validate_outer_layers(traces, 'rack')

      traces[1]['Layer'].must_equal "grape"
      traces[2]['Layer'].must_equal "grape"
      traces[2].has_key?('Controller').must_equal true
      traces[2].has_key?('Action').must_equal true
      traces[3]['Label'].must_equal "exit"

      # Validate the existence of the response header
      r.headers.key?('X-Trace').must_equal true
      r.headers['X-Trace'].must_equal traces[3]['X-Trace']
    end

    it "should trace a request with an error" do
      @app = GrapeSimple

      begin
        r = get "/break"
      rescue Exception => e
        # Do not handle/raise this error so
        # we can continue to test
      end

      traces = get_all_traces
      traces.count.must_equal 5

      validate_outer_layers(traces, 'rack')

      traces[1]['Layer'].must_equal "grape"
      traces[2]['Layer'].must_equal "grape"
      traces[2].has_key?('Controller').must_equal true
      traces[2].has_key?('Action').must_equal true
      traces[3]['Label'].must_equal "error"
      traces[3]['ErrorClass'].must_equal "Exception"
      traces[3]['ErrorMsg'].must_equal "This should have http status code 500!"
      traces[4]['Label'].must_equal "exit"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
oboe-2.7.10.1-java test/frameworks/grape_test.rb
oboe-2.7.10.1 test/frameworks/grape_test.rb
oboe-2.7.9.6-java test/frameworks/grape_test.rb
oboe-2.7.9.6 test/frameworks/grape_test.rb