Sha256: b0cbf78d92dad2fe521efbdb3434e0f87042d5efd1d90d2862f273c50ce967c7

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

require "spec_helper"

describe BaseCrm::Lead do

  subject do
    BaseCrm::Lead.new({ :id => 1234 })
  end

  it_behaves_like "noteable", "Lead"
  it_behaves_like "taskable", "Lead"

  describe "endpoint" do

    it "uses the production endpoint" do
      BaseCrm::Lead.scope.instance_eval do
        @endpoint.should == "https://leads.futuresimple.com"
      end
    end

  end

  describe "simplify_custom_fields" do

    it "converts a hash into the value" do
      subject.custom_fields = {
        'test' => { 'value' => 'yes!' }
      }
      result = subject.simplify_custom_fields
      result.should == { 'test' => 'yes!' }
    end
  end

  describe "response parsing" do
    let(:response) do
      {}
    end

    context "collection" do
      let(:items) { double }
      let(:response) do
        { "items" => items }
      end

      it "extracts the items" do
        BaseCrm::Lead.should_receive(:build_many).with(items)
        BaseCrm::Lead.build(response)
      end

    end

    context "single" do

      it "extracts the items" do
        BaseCrm::Lead.should_receive(:build_one).with(response)
        BaseCrm::Lead.build(response)
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
basecrm-0.1.0 spec/base_crm/lead_spec.rb