Sha256: 37cf373ad1008b08ac9a7ae800f3a1bfdeb30dd641184f121f5d62b88a048c2a

Contents?: true

Size: 1.37 KB

Versions: 2

Compression:

Stored size: 1.37 KB

Contents

require 'spec_helper'

describe Koala::Facebook::APIError do
  it "is a StandardError" do
    Koala::Facebook::APIError.new.should be_a(StandardError)
  end

  [:fb_error_type, :fb_error_code, :fb_error_message, :raw_response].each do |accessor|
    it "has an accessor for #{accessor}" do
      Koala::Facebook::APIError.instance_methods.map(&:to_sym).should include(accessor)
      Koala::Facebook::APIError.instance_methods.map(&:to_sym).should include(:"#{accessor}=")
    end
  end

  it "sets raw_response to the provided error details" do
    error_response = {"type" => "foo", "other_details" => "bar"}
    Koala::Facebook::APIError.new(error_response).raw_response.should == error_response
  end

  {
    :fb_error_type => 'type',
    :fb_error_message => 'message',
    :fb_error_code => 'code'
  }.each_pair do |accessor, key|
    it "sets #{accessor} to details['#{key}']" do
      value = "foo"
      Koala::Facebook::APIError.new(key => value).send(accessor).should == value
    end
  end

  it "sets the error message details['type']: details['message']" do
    type = "foo"
    message = "bar"
    error = Koala::Facebook::APIError.new("type" => type, "message" => message)
    error.message.should =~ /#{type}/
    error.message.should =~ /#{message}/
  end
end

describe Koala::KoalaError do
  it "is a StandardError" do
     Koala::KoalaError.new.should be_a(StandardError)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
koala-1.5.0 spec/cases/error_spec.rb
koala-1.5.0rc1 spec/cases/error_spec.rb