File tree Expand file tree Collapse file tree 3 files changed +17
-5
lines changed
spec/core/middleware/response Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -12,4 +12,7 @@ script:
1212 - bundle exec rake
1313 - bundle exec rubocop
1414
15+ branches :
16+ only : master
17+
1518sudo : false
Original file line number Diff line number Diff line change 1+ # tested via spec/core/middleware/response/raise_error_spec.rb
12module ZendeskAPI
23 module Error
34 class ClientError < Faraday ::Error ::ClientError
45 attr_reader :wrapped_exception
6+
7+ def to_s
8+ "#{ super } -- #{ response . method } #{ response . url } "
9+ end
510 end
611
712 class RecordInvalid < ClientError
8- attr_accessor :response , : errors
13+ attr_accessor :errors
914
10- def initialize ( response )
11- @response = response
15+ def initialize ( * )
16+ super
1217
1318 if response [ :body ] . is_a? ( Hash )
1419 @errors = response [ :body ] [ "details" ] || response [ :body ] [ "description" ]
@@ -18,7 +23,7 @@ def initialize(response)
1823 end
1924
2025 def to_s
21- "#{ self . class . name } : #{ @errors . to_s } "
26+ "#{ self . class . name } : #{ @errors } "
2227 end
2328 end
2429
Original file line number Diff line number Diff line change 6666 context "with status in 3XX" do
6767 let ( :status ) { 302 }
6868
69- it "should raise NetworkError" do
69+ it "raises NetworkError" do
7070 expect { client . connection . get "/non_existent" } . to raise_error ( ZendeskAPI ::Error ::NetworkError )
7171 end
72+
73+ it "tells the user what was going on" do
74+ expect { client . connection . get "/non_existent" } . to raise_error ( "the server responded with status 302 -- get https://my.zendesk.com/non_existent" )
75+ end
7276 end
7377
7478 context "with status = 422" do
You can’t perform that action at this time.
0 commit comments