tolerate empty string result from Fiken API
This commit is contained in:
+2
-1
@@ -12,7 +12,8 @@ module Fiken
|
||||
class Object
|
||||
def initialize(attributes = {})
|
||||
@attributes = {}
|
||||
(attributes || {}).each { |key, value| @attributes[key.to_sym] = wrap(value) }
|
||||
attributes = {} unless attributes.is_a?(Hash)
|
||||
attributes.each { |key, value| @attributes[key.to_sym] = wrap(value) }
|
||||
end
|
||||
|
||||
def [](key)
|
||||
|
||||
@@ -46,4 +46,8 @@ RSpec.describe Fiken::Object do
|
||||
expect(object.key?(:invoiceNumber)).to be(true)
|
||||
expect(object.key?(:missing)).to be(false)
|
||||
end
|
||||
|
||||
it "treats a non-Hash body (e.g. empty string from a 204 response) as empty" do
|
||||
expect(described_class.new("").keys).to eq([])
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user