Sha256: 24445d73f1aaf01f197d31f7a079e1e18670055c3cb6ad8b96a3ce4dc3d35847

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'
require 'stats_whisper/caller'
require_relative 'statsd_helper'

describe StatsWhisper::Caller do
  subject { Class.new { extend StatsWhisper::Caller } }

  before do
    Rails = double(:root => Pathname.new("spec/fixtures"))
  end

  after do
    Object.send(:remove_const, :Rails)
  end

  describe "#gather_stats" do
    before do
      allow(Rails).to receive(:env).and_return("production")

      StatsWhisper.backend = ::StatsD.new

    end

    it "adds timing stats" do
      subject.gather_stats({'REQUEST_PATH' => '/en/main',
                            'REQUEST_METHOD' => 'GET'}, 234)
      expect(StatsWhisper.backend.timing_key).to eq('bar.http.GET.main.response_time')
      expect(StatsWhisper.backend.increment_key).to eq('bar.http.visits')
      expect(StatsWhisper.backend.increment_key).to eq('bar.http.main.visits')
    end

  end

  describe "#timing_allowed?" do

    context "when whitelist is given" do
      it "allows only certain paths" do
        expect(subject.timing_allowed?("/en/main")).to eq(true)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stats_whisper-0.2.3 spec/integration/caller_spec.rb