Sha256: 86959a8a5979a5c8768c4adfaefd8eadf3d53d994da40bf01c2f0a32567c280b
Contents?: true
Size: 1.58 KB
Versions: 2
Compression:
Stored size: 1.58 KB
Contents
require File.expand_path('../../../lib/heracles-wrapper/exceptions', __FILE__) require 'minitest/autorun' require 'ostruct' describe Heracles::Wrapper::RequestFailure do describe 'well formed response' do subject { Heracles::Wrapper::RequestFailure.new(response) } let(:response) { OpenStruct.new(:code => expected_code, :body => expected_body) } let(:expected_code) { 123 } describe 'without errors' do let(:expected_body) { "{\"hello\":\"world\"}" } it('has #code') { subject.code.must_equal expected_code } it('has #errors') { subject.errors.must_equal({}) } it('has #response') { subject.response.must_equal response } it('has #to_s') { subject.to_s.must_equal "code: #{expected_code}" } end describe 'with errors' do let(:expected_body) { "{\"errors\": {\"world\": 1}}" } it('has #code') { subject.code.must_equal expected_code } it('has #errors') { subject.errors.fetch('world').must_equal 1 } it('has #response') { subject.response.must_equal response } it('has #to_s') { subject.to_s.must_equal "code: #{expected_code}" } end end describe 'poorly formed response as per a timeout' do subject { Heracles::Wrapper::RequestFailure.new(response) } let(:response) { Object.new } let(:expected_code) { 500 } let(:expected_body) { '' } it('has #code') { subject.code.must_equal expected_code } it('has #errors') { subject.errors.must_equal({}) } it('has #response') { subject.response.must_equal response } it('has #to_s') { subject.to_s.must_equal "code: #{expected_code}" } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
heracles-wrapper-0.0.3 | spec/heracles-wrapper/exceptions_spec.rb |
heracles-wrapper-0.0.2 | spec/heracles-wrapper/exceptions_spec.rb |