Sha256: 800c64b6474293115788457117e664d5b6289e4377f796712db5299ac2931b67

Contents?: true

Size: 1.16 KB

Versions: 3

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) { mock }
      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

3 entries across 3 versions & 1 rubygems

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