Sha256: 0d3a7d82717502a1b43f62b6a5970f76d12e7479b430221aeb7b3745677b6752

Contents?: true

Size: 802 Bytes

Versions: 1

Compression:

Stored size: 802 Bytes

Contents

require 'spec_helper'

describe Metric do
  before do
    reset_config
  end

  it "composes the request url" do
    Metric.compose("hits").should == "http://api.metric.io/track?api_key=spec&metric=hits"
  end

  it "gets correct url when tracking" do
    Metric.should_receive(:compose).with("hits", {})
    Metric.track("hits")
  end

  it "encodes the request url" do
    Metric.parse_metric("hits and spaces").should == "&metric=hits+and+spaces"
  end

  it "sends trigger param" do
    url = "http://api.metric.io/track?api_key=spec&metric=hits&trigger=1"
    Metric.compose("hits", {:trigger => true}).should == url
  end

  it "sends custom amount" do
    url = "http://api.metric.io/track?api_key=spec&metric=hits&amount=42"
    Metric.compose("hits", {:amount => 42}).should == url
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
metric-0.0.5 spec/metric_spec.rb