Sha256: 58b981b9ebafd04fe1dd7c6a6c5d0a66eee5e686ceb58c60d2ed48ef0f0c6211

Contents?: true

Size: 1.53 KB

Versions: 7

Compression:

Stored size: 1.53 KB

Contents

require 'spec_helper'

describe AngellistApi::Configuration do
  class ExtendedClass; extend  AngellistApi::Configuration; end
  class IncludedClass; include AngellistApi::Configuration; end

  describe "#extended" do
    it "has all configuration variables set to the default values by default" do
      AngellistApi::Configuration::VALID_OPTIONS_KEYS.each do |key|
        ExtendedClass.send(key).should == AngellistApi::Configuration.const_get("DEFAULT_#{key.to_s.upcase}")
      end
    end
  end

  describe "#configure" do
    it "allows configuration variables to be set in a block" do
      object = IncludedClass.new
      object.configure do |o|
        o.access_token = "my oauth token"
      end
      object.access_token.should == "my oauth token"
    end
  end

  describe "#options" do
    it "returns a hash of all configuration options" do
      object = IncludedClass.new
      config = { :access_token => "123-token" }
      config.each { |k,v| object.send("#{k.to_s}=", v) }
      config.each { |k,v| object.options[k].should == v }
    end
  end

  describe "#reset" do
    it "sets all config variables to the defaults" do
      object = IncludedClass.new
      AngellistApi::Configuration::VALID_OPTIONS_KEYS.each_with_index do |key, i|
        object.send("#{key}=", i)
        object.send(key).should == i
      end

      object.reset

      AngellistApi::Configuration::VALID_OPTIONS_KEYS.each do |key|
        object.send(key).should == AngellistApi::Configuration.const_get("DEFAULT_#{key.to_s.upcase}")
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
angellist_api-1.1.0 spec/unit/lib/angellist_api/configuration_spec.rb
angellist_api-1.0.7 spec/unit/lib/angellist_api/configuration_spec.rb
angellist_api-1.0.6 spec/unit/lib/angellist_api/configuration_spec.rb
angellist_api-1.0.5 spec/unit/lib/angellist_api/configuration_spec.rb
angellist_api-1.0.4 spec/unit/lib/angellist_api/configuration_spec.rb
angellist_api-1.0.3 spec/unit/lib/angellist_api/configuration_spec.rb
angellist_api-1.0.2 spec/unit/lib/angellist_api/configuration_spec.rb