Sha256: 990fc7b9934e399d75d3238108f3dcc26349c8c8f34b34b8958d473515e8803a

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'

describe Masheri::RestClient do
  let(:service_key) do
    "12345"
  end

  let(:url) do
    Masheri::RestClient::Query.new(query_params).url
  end

  let(:query_params) do
    {service_id: service_key}.merge(options)
  end


  context "reasonable date range" do
    let(:options) do
      {
        start_date: 1.day.ago,
        end_date:   0.days.ago,
        resource:   "developer_activity"
      }
    end

    it "should request the service data, given a service key" do
      ::RestClient.should_receive(:get).with(url).and_return("whatever")
      Masheri.activity("developer_activity", service_key, options).should == "whatever"
    end
  end

  context "invalid date range" do
    let(:options) do
      {
        start_date: 8.day.ago,
        end_date:   0.days.ago,
        resource:   "developer_activity"
      }
    end

    it "should raise an InvalidDateRange error" do
      expect do
        Masheri.activity("developer_activity", service_key, options)
      end.to raise_error(Masheri::InvalidDateRange)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
masheri-0.6.1 spec/masheri/rest_client_spec.rb
masheri-0.6.0 spec/masheri/rest_client_spec.rb