Sha256: 3648164e6f76a5f9fc66a37528c3f05118c136e038312e1ccaac216c88c16baa

Contents?: true

Size: 956 Bytes

Versions: 9

Compression:

Stored size: 956 Bytes

Contents

require 'test_helper'

class ErrorTest < Minitest::Test
  describe "Server is misbehaving" do
    before do
      api_url = 'http://api.sailthru.com'
      @secret = 'my_secret'
      @api_key = 'my_api_key'
      @sailthru_client = Sailthru::Client.new(@api_key, @secret, api_url)
      @api_call_url = sailthru_api_call_url(api_url, 'blast')
    end

    it "raises an error when server misbehaves" do
      stub_exception(@api_call_url, 'blast_post_update_valid.json')
      assert_raises Sailthru::ClientError do
        @sailthru_client.cancel_blast(123)
      end
    end

    it "shows the true origin of the exception" do
      stub_exception(@api_call_url, 'blast_post_update_valid.json')
      begin
        @sailthru_client.cancel_blast(123)
      rescue => e
        assert_match /Exception from FakeWeb/, e.message
        assert_match /Exception from FakeWeb/, e.cause.message if e.respond_to?(:cause) # Ruby 2.1
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sailthru-client-4.3.0 test/sailthru/error_test.rb
sailthru-client-4.2.0 test/sailthru/error_test.rb
sailthru-client-4.1.0 test/sailthru/error_test.rb
sailthru-client-4.0.7 test/sailthru/error_test.rb
sailthru-client-4.0.6 test/sailthru/error_test.rb
sailthru-client-4.0.3 test/sailthru/error_test.rb
sailthru-client-4.0.2 test/sailthru/error_test.rb
sailthru-client-4.0.1 test/sailthru/error_test.rb
sailthru-client-4.0.0 test/sailthru/error_test.rb