Sha256: 876a52a22f19099488a9e20604245e1a081af0ce7996b927ca166c62fc70f7da

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

describe 'Datadog Proxy' do
  include Rack::Test::Methods

  def app
    DatadogProxy::App
  end

  let(:client) do
    double(:client)
  end

  before do
    allow_any_instance_of(DatadogProxy::App).to receive(:client).and_return(client)
  end

  describe "GET /" do
    it "returns docuement in markdown" do
      get '/'
      expect(last_response).to be_ok
      expect(last_response.body).to match(/^# Datadog Proxy/)
    end
  end

  describe "GET /graphs/snapshot" do
    context "with query, start and end" do
      it "returns the url of a graph" do
        expect(client).to receive(:graph_snapshot_url).with(
          {
            query: 'query',
            start: Time.at(0),
            end: Time.at(1024),
          }
        ).and_return('http://example.com/graph')

        get '/graphs/snapshot', query: "query", start: "0", end: "1024"
        expect(last_response.status).to eq(302)
        expect(last_response.header['Location']).to eq('http://example.com/graph')
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
datadog_proxy-0.0.6 spec/app_spec.rb
datadog_proxy-0.0.5 spec/app_spec.rb
datadog_proxy-0.0.4 spec/app_spec.rb
datadog_proxy-0.0.3 spec/app_spec.rb
datadog_proxy-0.0.2 spec/app_spec.rb
datadog_proxy-0.0.1 spec/app_spec.rb