Sha256: fb3ff65e7eea828d5df2e6d86acce1d6abb5e0d36324b870207ae3daa3f383b6

Contents?: true

Size: 1.41 KB

Versions: 9

Compression:

Stored size: 1.41 KB

Contents

require 'spec_helper'

describe BaseCRM::ContactsService do
  describe 'Responds to' do
    subject { client.contacts  }

    it { should respond_to :all }
    it { should respond_to :create }
    it { should respond_to :destroy }
    it { should respond_to :find }
    it { should respond_to :update }
    it { should respond_to :where }
  end

  describe :all do
    it "returns a PaginatedResource" do
      expect(client.contacts.all()).to be_instance_of BaseCRM::PaginatedResource
    end
  end

  describe :where do
    it "returns an array" do
      expect(client.contacts.where(page: 1)).to be_an Array
    end
  end

  describe :create do
    it "returns instance of Contact class" do
      @contact = build(:contact)
      expect(client.contacts.create(@contact)).to be_instance_of BaseCRM::Contact
    end
  end

  describe :find do
    before :each do
      @contact = create(:contact)
    end

    it "returns an instance of Contact class" do
      expect(client.contacts.find(@contact.id)).to be_instance_of BaseCRM::Contact
    end
  end

  describe :update do
    it "returns an updated instance of Contact class" do
      @contact = create(:contact)
      expect(client.contacts.update(@contact)).to be_instance_of BaseCRM::Contact
    end
  end

  describe :destroy do
    it "returns true on success" do
      @contact = create(:contact)
      expect(client.contacts.destroy(@contact.id)).to be_truthy
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
basecrm-2.0.0 spec/services/contacts_service_spec.rb
basecrm-1.3.10 spec/services/contacts_service_spec.rb
basecrm-1.3.9 spec/services/contacts_service_spec.rb
basecrm-1.3.8 spec/services/contacts_service_spec.rb
basecrm-1.3.7 spec/services/contacts_service_spec.rb
basecrm-1.3.6 spec/services/contacts_service_spec.rb
basecrm-1.3.5 spec/services/contacts_service_spec.rb
basecrm-1.3.4 spec/services/contacts_service_spec.rb
basecrm-1.3.3 spec/services/contacts_service_spec.rb