Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

when response is not a 200, it now returns the response instead of an…

… empty hash
  • Loading branch information...
commit 197c4808dec357c2a49a149fc2885fa84cdad6b1 1 parent 3e91ffc
@justinhill justinhill authored
Showing with 15 additions and 5 deletions.
  1. +4 −4 lib/load_balance_client.rb
  2. +11 −1 test/client_test.rb
View
8 lib/load_balance_client.rb
@@ -7,7 +7,7 @@ def self.get(url)
when 200
JSON.parse(response.body)
else
- {}
+ response
end
end
rescue Errno::ECONNREFUSED => e
@@ -24,7 +24,7 @@ def self.put(url, body)
when 200
JSON.parse(response.body)
else
- {}
+ response
end
end
rescue Errno::ECONNREFUSED => e
@@ -41,7 +41,7 @@ def self.post(url, body)
when 200
JSON.parse(response.body)
else
- {}
+ response
end
end
rescue Errno::ECONNREFUSED => e
@@ -58,7 +58,7 @@ def self.delete(url)
when 200
JSON.parse(response.body)
else
- {}
+ response
end
end
rescue Errno::ECONNREFUSED => e
View
12 test/client_test.rb
@@ -11,7 +11,7 @@ def test_bad_node_for_put
assert_equal ['http://localhost:9200'], LoadBalanceClient.server_list
end
-def test_bad_node_for_post
+ def test_bad_node_for_post
LoadBalanceClient.server_list=['http://localhost:9200', 'http://localhost:46250']
10.times do
LoadBalanceClient.post '/igodigital/users/abc123', {'foo'=>'bar'}.to_json
@@ -37,4 +37,14 @@ def test_bad_node_for_delete
assert_equal 1, LoadBalanceClient.server_list.length
assert_equal ['http://localhost:9200'], LoadBalanceClient.server_list
end
+
+ def test_responses
+ LoadBalanceClient.server_list=['http://localhost:9200']
+ response = LoadBalanceClient.get '/'
+
+ assert_equal 200, response['status']
+
+ response = LoadBalanceClient.get '/thisshouldneverwork'
+ assert_equal 'No handler found for uri [/thisshouldneverwork] and method [GET]', response
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.