Sha256: 8cde18d16a4a0ac1b3592f97dbb4eddfc7b619e9e5d14fcf1a116509b43a7389

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe Highrise::Person do
  subject { Highrise::Person.new(:id => 1) }

  it { should be_a_kind_of Highrise::Subject }

  it_should_behave_like "a paginated class"
  it_should_behave_like "a taggable class"
  it_should_behave_like "a searchable class"

  describe "#company" do
    it "returns nil when it doesn't have a company" do
      subject.should_receive(:company_id).and_return(nil)
      subject.company.should be_nil
    end

    it "delegate to Highrise::Company when have company_id" do
      subject.should_receive(:company_id).at_least(2).times.and_return(1)
      Highrise::Company.should_receive(:find).with(1).and_return("company")
      subject.company.should == "company"
    end
  end

  it "#name" do
    subject.should_receive(:first_name).and_return("Marcos")
    subject.should_receive(:last_name).and_return("Tapajós     ")
    subject.name.should == "Marcos Tapajós"
  end

  describe "#tags" do
    before(:each) do
      (@tags = []).tap do
        @tags << {'id' => "414578", 'name' => "cliente"}
        @tags << {'id' => "414580", 'name' => "ged"}
        @tags << {'id' => "414579", 'name' => "iepc"}
      end
      subject.attributes["tags"] = @tags
    end
    it {
      subject.tags.should == @tags
    }
  end

  it { subject.label.should == 'Party' }
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
highrise-3.1.6 spec/highrise/person_spec.rb
highrise-3.1.5 spec/highrise/person_spec.rb
highrise-3.1.2 spec/highrise/person_spec.rb