Sha256: 819976a8da30cfbef2323bc423200198cff722aaeec242e708f60e4605f66d83

Contents?: true

Size: 1.48 KB

Versions: 2

Compression:

Stored size: 1.48 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe Viglink::Purchases do

  it "creates a Faraday::Connection" do
    purchases = Viglink::Purchases.new
    purchases.connection.should be_kind_of Faraday::Connection
  end

  describe "#find_purchases" do

    let(:purchases) { Viglink::Purchases.new }

    context "without search options" do

      before(:each) do
        @purchases_response = purchases.find_purchases
      end

      it "returns a Hash of purchases", vcr: true do
        @purchases_response.should be_kind_of Hash
      end

      it "retuns the total count of purchases", vcr: true do
        @purchases_response[:count].should_not be_nil
      end

      it "retuns an Array of purchases", vcr: true do
        @purchases_response.product.should_not be_nil
      end

    end

    context "with search options" do

      before(:each) do
        @purchases_response = purchases.find_purchases({period: 'week'})
      end

      it "returns a Hash of purchases", vcr: true do
        @purchases_response.should be_kind_of Hash
      end

      context "response resources of product" do
        it "returns the `results`", vcr: true do
          @purchases_response[:results].should_not be_nil
        end

        it "returns the `parameters`", vcr: true do
          @purchases_response[:parameters].should_not be_nil
        end

        it "returns an `purchases`", vcr: true do
          @purchases_response.results.purchases.should_not be_nil
        end
      end
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
viglink-api-0.1.1 spec/viglink_api/purchases_spec.rb
viglink-api-0.1.0 spec/viglink_api/purchases_spec.rb