Sha256: 12ab53bd6678c42fb34d1bae9b47dbeedb7f6f4bcf951b5c55798d5a3f709c19

Contents?: true

Size: 1.25 KB

Versions: 4

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

RSpec.describe Chartmogul::V1::Customers do

  let(:client) { Chartmogul::Client.new }

  describe '#attributes' do
    subject { client.customers.attributes }

    it { expect(subject).to be_a Chartmogul::V1::Customers::Attributes }
    it { expect(subject.client).to eq client }
  end

  describe '::Attributes' do
    describe '#create' do
      let(:url) { 'https://api.chartmogul.com/v1/customers/customer-id/attributes/custom' }
      let(:body)  { [ {foo: 'bar'} ] }
      let(:query) { {} }

      before do
        stub_request(:post, url).with(body: { custom: body }.to_json).to_return(status: 200)
      end

      subject { client.customers.attributes.create('customer-id', body) }

      it_should_behave_like 'a base ChartMogul API V1 requests', method: :post
    end

    describe '#update' do
      let(:url) { 'https://api.chartmogul.com/v1/customers/customer-id/attributes/custom' }
      let(:body)  { [ {foo: 'bar'} ] }
      let(:query) { {} }

      before do
        stub_request(:put, url).with(body: { custom: body }.to_json).to_return(status: 200)
      end

      subject { client.customers.attributes.update('customer-id', body) }

      it_should_behave_like 'a base ChartMogul API V1 requests', method: :put
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
chartmogul_client-0.0.6 spec/chartmogul/v1/customers_spec.rb
chartmogul_client-0.0.5 spec/chartmogul/v1/customers_spec.rb
chartmogul_client-0.0.4 spec/chartmogul/v1/customers_spec.rb
chartmogul_client-0.0.3 spec/chartmogul/v1/customers_spec.rb