Sha256: 1ba7030b478f42c54e3983513cf4d9a644f5dd33fa6e44d1574ff1187ed0e512

Contents?: true

Size: 1.66 KB

Versions: 14

Compression:

Stored size: 1.66 KB

Contents

require "spec_helper"
require "rack/test"

describe Ping::API do
  include Rack::Test::Methods

  def app
    Ping::API
  end

  context "GET /api/ping" do
    let(:logger) { Grape::API.logger }

    specify do
      get "/api/ping"
      expect(last_response.body).to match(/PONG/)
    end

    it "logs something" do
      expect(logger).to receive(:info).with(
        method:       "GET",
        request_path: "/api/ping",
        format:       "json",
        status:       200,
        class_name:   "Ping::API",
        action:       "index",
        host:         "example.org",
        ip:           "127.0.0.1",
        ua:           nil,
        tags:         [],
        params:       {},
        runtimes:     a_hash_including(
                        total: kind_of(Float),
                        view:  kind_of(Float),
                        db:    kind_of(Float),
                      ),
      )

      get "/api/ping"
    end

    context "no routes defined" do
      it "logs something" do
        expect(logger).to receive(:info).with(
          method:       "GET",
          request_path: "/api/404",
          format:       "json",
          status:       404,
          class_name:   "Ping::API",
          action:       "index",
          host:         "example.org",
          ip:           "127.0.0.1",
          ua:           nil,
          tags:         [],
          params:       {},
          runtimes:     a_hash_including(
                          total: kind_of(Float),
                          view:  kind_of(Float),
                          db:    kind_of(Float),
                        ),
        )

        get "/api/404"
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
sapience-1.0.3 test_apps/grape/spec/lib/ping/api_spec.rb
sapience-1.0.2 test_apps/grape/spec/lib/ping/api_spec.rb
sapience-1.0.1 test_apps/grape/spec/lib/ping/api_spec.rb
sapience-1.0.0 test_apps/grape/spec/lib/ping/api_spec.rb
sapience-0.2.18 test_apps/grape/spec/lib/ping/api_spec.rb
sapience-0.2.17 test_apps/grape/spec/lib/ping/api_spec.rb
sapience-0.2.16 test_apps/grape/spec/lib/ping/api_spec.rb
sapience-0.2.15 test_apps/grape/spec/lib/ping/api_spec.rb
sapience-0.2.14 test_apps/grape/spec/lib/ping/api_spec.rb
sapience-0.2.13 test_apps/grape/spec/lib/ping/api_spec.rb
sapience-0.2.12 test_apps/grape/spec/lib/ping/api_spec.rb
sapience-0.2.11 test_apps/grape/spec/lib/ping/api_spec.rb
sapience-0.2.10 test_apps/grape/spec/lib/ping/api_spec.rb
sapience-0.2.9 test_apps/grape/spec/lib/ping/api_spec.rb