Sha256: f14fd3effc3f4434dee99de0c94b6e6b387256fa4bfc56fc2de49a7b3325ecf3

Contents?: true

Size: 1.45 KB

Versions: 5

Compression:

Stored size: 1.45 KB

Contents

describe Mrkt::CrudLists do
  include_context 'initialized client'

  describe '#get_leads_by_list' do
    let(:list_id) { '1001' }
    let(:response_stub) do
      {
        requestId: 'ab12#12d6ab65024',
        result: [
          {
            id: 1,
            firstName: nil,
            lastName: nil,
            email: 'sample@example.com',
            updatedAt: '2015-05-19 13:50:57',
            createdAt: '2015-05-19 13:50:57'
          }
        ],
        success: true
      }
    end

    subject { client.get_leads_by_list(list_id) }

    before do
      stub_request(:get, "https://#{host}/rest/v1/list/#{list_id}/leads.json")
        .with(query: {})
        .to_return(json_stub(response_stub))
    end

    it { is_expected.to eq(response_stub) }
  end

  describe '#add_leads_to_list' do
    let(:list_id) { '1001' }
    let(:lead_ids) { ['1'] }
    let(:request_body) do
      {
        input: [
          { id: '1' }
        ]
      }
    end
    let(:response_stub) do
      {
        requestId: '16d3f#14d6da7449f',
        result: [
          {
            id: 1,
            status: 'added'
          }
        ],
        success: true
      }
    end
    subject { client.add_leads_to_list(list_id, lead_ids) }

    before do
      stub_request(:post, "https://#{host}/rest/v1/lists/#{list_id}/leads.json")
        .with(json_stub(request_body))
        .to_return(json_stub(response_stub))
    end

    it { is_expected.to eq(response_stub) }
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mrkt-0.9.0 spec/concerns/crud_lists_spec.rb
mrkt-0.8.0 spec/concerns/crud_lists_spec.rb
mrkt-0.7.0 spec/concerns/crud_lists_spec.rb
mrkt-0.6.2 spec/concerns/crud_lists_spec.rb
mrkt-0.6.1 spec/concerns/crud_lists_spec.rb