class SkullIsland::RSpec::FakeRestClient
A Fake Rest Client for RSpec
testing
Attributes
responses[R]
Public Class Methods
new()
click to toggle source
# File lib/skull_island/rspec/fake_rest_client.rb, line 9 def initialize @responses = {} end
Public Instance Methods
[](uri)
click to toggle source
# File lib/skull_island/rspec/fake_rest_client.rb, line 27 def [](uri) FakeClient::Request.new(self, uri) end
hash(data)
click to toggle source
# File lib/skull_island/rspec/fake_rest_client.rb, line 13 def hash(data) if data Digest::MD5.hexdigest(data.sort.to_s) else '' end end
response_for(type, uri, data: nil, response: {})
click to toggle source
# File lib/skull_island/rspec/fake_rest_client.rb, line 21 def response_for(type, uri, data: nil, response: {}) @responses[type.to_s] ||= {} key = data ? uri.to_s + hash(data) : uri.to_s @responses[type.to_s][key] = JSON.dump(response) end