Sha256: 0cdaeb96051948ad527cd2a2fd1b0dfc508294efedab21266523b563ccd3f10e
Contents?: true
Size: 936 Bytes
Versions: 3
Compression:
Stored size: 936 Bytes
Contents
class MockHttpAdapter def self.connection(url = nil) Faraday.new(:url => url) do |faraday| faraday.adapter :test, self.stubs end end def self.stubs Faraday::Adapter::Test::Stubs.new do |stub| stub.get(uri('recipe/French-Onion-Soup-The-Pioneer-Woman-Cooks-_-Ree-Drummond-41364')) {[ 200, {}, response("get_recipe.json") ]} stub.get(uri('recipe/missing-recipe-1234')) {[ 404, {}, nil ]} stub.get(uri('recipe/permission-denied')) {[ 409, {}, "Permission denied. Please check your app id and app key and try again later." ]} stub.get(uri('recipe/internal-error')) {[ 500, {}, "BOOM!" ]} end end def self.uri(path_fragment) "/#{Yummly::API_VERSION}/api/#{path_fragment}?_app_id=#{Yummly.configuration.app_id}&_app_key=#{Yummly.configuration.app_key}" end def self.response(name) path = File.expand_path("spec/fixtures/#{name}") File.open(path, 'rb').read end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
yummly-0.0.13 | spec/support/mock_http_adapter.rb |
yummly-0.0.12 | spec/support/mock_http_adapter.rb |
yummly-0.0.11 | spec/support/mock_http_adapter.rb |