Sha256: cea527daeb0569ea28df964f51716660d02c8528c4fedfb12a6e043aef0e1fc8

Contents?: true

Size: 792 Bytes

Versions: 2

Compression:

Stored size: 792 Bytes

Contents

require 'spec_helper'
require 'stats_whisper/caller'

describe StatsWhisper::Caller do
  let(:ctxt) { Class.new { extend StatsWhisper::Caller } }

  describe "#timing_allowed?" do

    context "when whitelist is empty" do
      it "allows to receive any path" do
        allow(ctxt).to receive(:whitelist).and_return([])
        expect(ctxt.timing_allowed?("/bleh/blah/ok")).to eq(true)
      end
    end

    context "when whitelist is not empty" do
      before do
        allow(ctxt).to receive(:whitelist).and_return(["/home.*"])
      end

      it "allows only certain paths" do
        expect(ctxt.timing_allowed?("/home/page")).to eq(true)
      end

      it "rejects not allowed paths" do
        expect(ctxt.timing_allowed?("/dashboard")).to eq(false)
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stats_whisper-0.2.3 spec/unit/caller_spec.rb
stats_whisper-0.2.2.1 spec/unit/caller_spec.rb