Sha256: aa102293630441a0da002b82582b5e425f99386d8bb345dbab392bfa8474905e

Contents?: true

Size: 1.86 KB

Versions: 3

Compression:

Stored size: 1.86 KB

Contents

require "spec_helper"

describe BaseCrm::Session do

  let(:token) { "OMGTOKEN" }

  subject do
    BaseCrm::Session.new(token)
  end

  describe "passing of headers" do
    let(:scope) { mock }
    let(:scope_class) { mock }

    before do
      scope_class.should_receive(:headers).with({
        "X-Pipejump-Auth" => token
      }).and_return(scope)
      scope.should_receive(:headers).with({
        "X-Futuresimple-Token" => token
      })
    end

    describe "#contacts" do
      let(:scope_class) { BaseCrm::Contact }

      it "queries the contacts with the right header" do
        subject.contacts
      end

    end

    describe "#deals" do
      let(:scope_class) { BaseCrm::Deal }

      it "queries the deals with the right header" do
        subject.deals
      end

    end

    describe "#sources" do
      let(:scope_class) { BaseCrm::Source }

      it "queries the sources with the right header" do
        subject.sources
      end

    end

    describe "#notes" do
      let(:scope_class) { BaseCrm::Note }

      it "queries the notes with the right header" do
        subject.notes
      end

    end

    describe "#tasks" do
      let(:scope_class) { BaseCrm::Task }

      it "queries the tasks with the right header" do
        subject.tasks
      end

    end

    describe "#leads" do
      let(:scope_class) { BaseCrm::Lead }

      it "queries the leads with the right header" do
        subject.leads
      end

    end


  end

  describe "#account" do

    it "gets the account" do
      BaseCrm::Account.should_receive(:headers).with({
        "X-Pipejump-Auth" => token
      }).and_return(BaseCrm::Account)
      BaseCrm::Account.should_receive(:headers).with({
        "X-Futuresimple-Token" => token
      }).and_return(BaseCrm::Account)
      BaseCrm::Account.should_receive(:fetch).with('/api/v1/account.json')
      subject.account
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
basecrm-0.0.3 spec/base_crm/session_spec.rb
basecrm-0.0.2 spec/base_crm/session_spec.rb
basecrm-0.0.1 spec/base_crm/session_spec.rb