Sha256: b840a9d1e630ae170bfc34f51993f988b9d79414a45c89d05ccf6156f1df9368
Contents?: true
Size: 1.76 KB
Versions: 2
Compression:
Stored size: 1.76 KB
Contents
describe Mrkt::CrudCampaigns do include_context 'with an initialized client' describe '#request_campaign' do subject(:action) { client.request_campaign(id, lead_ids, tokens) } let(:id) { 42 } let(:lead_ids) { [1234, 5678] } let(:tokens) do [{ name: '{{my.message}}', value: 'Updated message' }, { name: '{{my.other token}}', value: 'Value for other token' }] end before do stub_request(:post, "https://#{host}/rest/v1/campaigns/#{id}/trigger.json") .with(body: { input: { leads: lead_ids.map { |id| { id: id } }, tokens: tokens } }) .to_return(json_stub(response_stub)) end context 'with an invalid campaign id' do let(:response_stub) do { requestId: 'a9b#14eb6771358', success: false, errors: [{ code: '1013', message: 'Campaign not found' }] } end it 'raises an Error' do expect { action }.to raise_error(Mrkt::Errors::ObjectNotFound) end end context 'with valid campaign id' do context 'with invalid lead id' do let(:response_stub) do { requestId: '7cdc#14eb6ae8a86', success: false, errors: [{ code: '1004', message: 'Lead [1234] not found' }] } end it 'raises an Error' do expect { action }.to raise_error(Mrkt::Errors::LeadNotFound) end end context 'with valid lead ids' do let(:response_stub) do { requestId: 'e42b#14272d07d78', success: true } end it { is_expected.to eq(response_stub) } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mrkt-1.2.2 | spec/concerns/crud_campaigns_spec.rb |
mrkt-1.2.1 | spec/concerns/crud_campaigns_spec.rb |