Sha256: ed7ff8c85c540e1651319509d89c3f209d97616fd4519336e46a1bdcb38e7959

Contents?: true

Size: 1.41 KB

Versions: 9

Compression:

Stored size: 1.41 KB

Contents

require 'spec_helper'

describe BaseCRM::ProductsService do
  describe 'Responds to' do
    subject { client.products  }

    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.products.all()).to be_instance_of BaseCRM::PaginatedResource
    end
  end

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

  describe :create do
    it "returns instance of Product class" do
      @product = build(:product)
      expect(client.products.create(@product)).to be_instance_of BaseCRM::Product
    end
  end

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

    it "returns an instance of Product class" do
      expect(client.products.find(@product.id)).to be_instance_of BaseCRM::Product
    end
  end

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

  describe :destroy do
    it "returns true on success" do
      @product = create(:product)
      expect(client.products.destroy(@product.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/products_service_spec.rb
basecrm-1.3.10 spec/services/products_service_spec.rb
basecrm-1.3.9 spec/services/products_service_spec.rb
basecrm-1.3.8 spec/services/products_service_spec.rb
basecrm-1.3.7 spec/services/products_service_spec.rb
basecrm-1.3.6 spec/services/products_service_spec.rb
basecrm-1.3.5 spec/services/products_service_spec.rb
basecrm-1.3.4 spec/services/products_service_spec.rb
basecrm-1.3.3 spec/services/products_service_spec.rb