Sha256: 6935e87f030ccac6468a41dfbeeca157bb0654eb7919c0e41d039f8f77f1bfce

Contents?: true

Size: 1.28 KB

Versions: 10

Compression:

Stored size: 1.28 KB

Contents

require 'spec_helper'

describe Rearview::Statsd do
  before(:all) do
    Rearview.config.statsd_connection = { host: 'myhost', port: 123, namespace: 'mynamespace' }
  end
  let(:statsd) { Rearview::Statsd.new }
  context '.initialize' do
    it "sets the port from Rearview::Configuration" do
      expect(statsd.port).to eq(123)
    end
    it "sets the host from Rearview::Configuration" do
      expect(statsd.host).to eq('myhost')
    end
    it "sets the namespace from Rearview::Configuration" do
      expect(statsd.namespace).to eq('mynamespace')
    end
  end
  context '.statsd' do
    it "returns a shared instance" do
      expect(Rearview::Statsd.statsd).to eq(Rearview::Statsd.statsd)
      expect(Rearview::Statsd.statsd).not_to be_nil
    end
  end
  context '.report' do
    it "will yield to the block if stats are enabled" do
      Rearview.config.stubs(:stats_enabled?).returns(true)
      block_yielded = false
      Rearview::Statsd.report { |stats| block_yielded = true }
      expect(block_yielded).to be_true
    end
    it "will not yield to the block if stats are disabled" do
      Rearview.config.stubs(:stats_enabled?).returns(false)
      block_yielded = false
      Rearview::Statsd.report { |stats| block_yielded = true }
      expect(block_yielded).to be_false
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rearview-1.2.3-jruby spec/lib/rearview/statsd_spec.rb
rearview-1.2.2.rc.2-jruby spec/lib/rearview/statsd_spec.rb
rearview-1.2.2.rc.1-jruby spec/lib/rearview/statsd_spec.rb
rearview-1.2.1-jruby spec/lib/rearview/statsd_spec.rb
rearview-1.2.0-jruby spec/lib/rearview/statsd_spec.rb
rearview-1.1.2-jruby spec/lib/rearview/statsd_spec.rb
rearview-1.1.1-jruby spec/lib/rearview/statsd_spec.rb
rearview-1.1.0-jruby spec/lib/rearview/statsd_spec.rb
rearview-1.0.3.rc.4-jruby spec/lib/rearview/statsd_spec.rb
rearview-1.0.3.rc.3-jruby spec/lib/rearview/statsd_spec.rb