Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tolerate empty response bodies better, helps with #28

  • Loading branch information...
commit d149643cca16ccb4c9f1b9c45a2e0460cf16ba2c 1 parent 439c81d
@rkbodenner rkbodenner authored
View
2  lib/tinder/campfire.rb
@@ -31,7 +31,7 @@ def initialize(subdomain, options = {})
# Get an array of all the available rooms
# TODO: detect rooms that are full (no link)
def rooms
- connection.get('/rooms.json')['rooms'].map do |room|
+ (connection.get('/rooms.json')['rooms'] || []).map do |room|
Room.new(connection, room)
end
end
View
6 lib/tinder/connection.rb
@@ -74,12 +74,12 @@ def token
def get(url, *args)
response = connection.get(url, *args)
- response.body
+ response.body || {}
end
def post(url, body = nil, *args)
response = connection.post(url, body, *args)
- response.body
+ response.body || {}
end
def raw_post(url, body = nil, *args)
@@ -88,7 +88,7 @@ def raw_post(url, body = nil, *args)
def put(url, body = nil, *args)
response = connection.put(url, body, *args)
- response.body
+ response.body || {}
end
# Is the connection to campfire using ssl?
View
12 spec/tinder/campfire_spec.rb
@@ -25,6 +25,18 @@
end
end
+ describe "rooms when unauthorized" do
+ before do
+ stub_connection(@campfire.connection) do |stub|
+ stub.get('/rooms.json') {[403, {}, '']}
+ end
+ end
+
+ it "should return an empty list" do
+ @campfire.rooms.size.should be == 0
+ end
+ end
+
describe "find_by_id" do
before do
stub_connection(@campfire.connection) do |stub|
Please sign in to comment.
Something went wrong with that request. Please try again.