Sha256: 27733318a91e63b88260fb14c47cf5052d1dae810dcf67702e387a6396520acf

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'

describe Metric::Receive do
  it "generates correct hash via secret_token" do
    Metric::Receive.generate_token("hits").should == "c6daa87bcf8bf7cb4d1c74d872793e5e"
  end

  it "gets total" do
    request = "http://api.metric.io/receive?api_key=spec&token=c6daa87bcf8bf7cb4d1c74d872793e5e&metric=hits&range=total"
    Metric::Receive.compose("hits", "total").should == request
  end

  it "gets today" do
    request = "http://api.metric.io/receive?api_key=spec&token=c6daa87bcf8bf7cb4d1c74d872793e5e&metric=hits&range=today"
    Metric::Receive.compose("hits", "today").should == request
  end

  it "gets week" do
    request = "http://api.metric.io/receive?api_key=spec&token=c6daa87bcf8bf7cb4d1c74d872793e5e&metric=hits&range=week"
    Metric::Receive.compose("hits", "week").should == request
  end

  it "gets month" do
    request = "http://api.metric.io/receive?api_key=spec&token=c6daa87bcf8bf7cb4d1c74d872793e5e&metric=hits&range=month"
    Metric::Receive.compose("hits", "month").should == request
  end

  it "grabs actual data" do
    stub_request(:get, "http://api.metric.io/receive?api_key=spec&metric=hits&range=today&token=c6daa87bcf8bf7cb4d1c74d872793e5e").
      to_return(:status => 200, :body => "{\"total\":\"1\"}", :headers => {})
    Metric::Receive.receive("hits", "today").should == {"total" => "1"}
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
metric-0.0.7 spec/metric/receive_spec.rb