Sha256: 850993efc0d7364c9392c3e8636fe3d4fa6607689b13845d201e832fc750aa6d

Contents?: true

Size: 999 Bytes

Versions: 2

Compression:

Stored size: 999 Bytes

Contents

require 'spec_helper'
require 'stats_whisper/parser'

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

  describe "#parse" do


    context "when req path is empty" do
      it "resolves base uri" do
        path = "/"
        expect(ctxt.parse(path)).to eq("home_page")
      end
    end

    context "when req path is root path" do
      it "resolves root path" do
        path = "/en"
        expect(ctxt.parse(path)).to eq("home_page")
      end
    end

    context "when req path points to a resource" do
      it "resolves resource path" do
        path = "/en/dashboard"
        expect(ctxt.parse(path)).to eq("dashboard")

        path = "/2015-2016/pl/treasuries/academy_units/offer"
        expect(ctxt.parse(path)).to eq("treasuries.academy_units.offer")
      end
    end
  end

  describe "#build_key" do
    it "generates valid Graphite key" do
      expect(ctxt.build_key("bleh", 'blah', "dash")).to eq("bleh.blah.dash")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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