Sha256: 1f915752d21b2ced40f8de9ea81980fbbb76d01c61d9f38f8f0ae7a5b53741f1
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
require 'spec_helper' RSpec.describe SparkPost::Request do describe '#request' do api_url = 'https://api.sparkpost.com/api/' let(:api_key) { '123' } let(:request) { SparkPost::Request.request } context 'when was successful' do response = {results: {"total_rejected_recipients"=>0, "total_accepted_recipients"=>1, "id"=>"102238681582044821"} } before do stub_request(:post, api_url).to_return(body: response.to_json, status: 200) end it { expect(SparkPost::Request.request(api_url, '123', {})).to eq(response[:results]) } end context 'when was not successful' do response = {errors: {message: 'end of world'} } before do stub_request(:post, api_url).to_return(body: response.to_json, status: 500) end it { expect { SparkPost::Request.request(api_url, '123', {})}.to raise_error(SparkPost::DeliveryException).with_message(/end of world/) } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sparkpost-0.1.2 | spec/lib/sparkpost/request_spec.rb |
sparkpost-0.1.1 | spec/lib/sparkpost/request_spec.rb |
sparkpost-0.1.0 | spec/lib/sparkpost/request_spec.rb |