Sha256: f0df2787a00d3ee27c88ae4ef4bd526bb58554dab0de5eee479ac4e26bf1abe5

Contents?: true

Size: 1 KB

Versions: 3

Compression:

Stored size: 1 KB

Contents

require "spec_helper"

describe Yummly::Connection do

  let(:app_id) { "123456" }
  let(:app_key) { "ABCDEFG123456" }

  before do
    Yummly.configure do |config|
      config.app_id = app_id
      config.app_key = app_key
      config.http_adapter = MockHttpAdapter
    end
  end

  describe "get" do
    it "parses a successful response" do
      response = Yummly::Connection.get("recipe/French-Onion-Soup-The-Pioneer-Woman-Cooks-_-Ree-Drummond-41364")
      response.should be_a(Hash)
    end

    it "returns nil when a 404 is encountered" do
      response = Yummly::Connection.get("recipe/missing-recipe-1234")
      response.should be_nil
    end

    it "raises a permission exception when access is denied" do
      expect { Yummly::Connection.get("recipe/permission-denied") }.to raise_error(Yummly::PermissionError)
    end

    it "raises an exception when an internal error occurs" do
      expect { Yummly::Connection.get("recipe/internal-error") }.to raise_error(Yummly::InternalServerError)
    end
  end


end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
yummly-0.0.13 spec/connection_spec.rb
yummly-0.0.12 spec/connection_spec.rb
yummly-0.0.11 spec/connection_spec.rb