Sha256: 0219332a9e3d6c4ea69e05e10cd613ffb40e783fd468e0cfb977c9aa505a432a

Contents?: true

Size: 1.65 KB

Versions: 8

Compression:

Stored size: 1.65 KB

Contents

require 'spec_helper'

describe Restforce do
  after do
    Restforce.instance_variable_set :@configuration, nil
  end

  describe '#configuration' do
    subject { Restforce.configuration }

    it { should be_a Restforce::Configuration }

    context 'by default' do
      its(:api_version)  { should eq '24.0' }
      its(:host)         { should eq 'login.salesforce.com' }
      [:username, :password, :security_token, :client_id, :client_secret,
       :oauth_token, :refresh_token, :instance_url].each do |attr|
        its(attr) { should be_nil }
      end
    end
  end

  describe '#configure' do
    [:username, :password, :security_token, :client_id, :client_secret,
     :oauth_token, :refresh_token, :instance_url, :api_version, :host].each do |attr|
      it "allows #{attr} to be set" do
        Restforce.configure do |config|
          config.send("#{attr}=", 'foobar')
        end
        Restforce.configuration.send(attr).should eq 'foobar'
      end
    end
  end

  describe '#log?' do
    subject { Restforce.log? }

    context 'by default' do
      it { should be_false }
    end
  end

  describe '#log' do
    after do
      Restforce.log = false
    end

    context 'with logging disabled' do
      before do
        Restforce.log = false
        Restforce.configuration.logger.should_not_receive(:debug)
      end

      it 'doesnt log anytning' do
        Restforce.log 'foobar'
      end
    end
    
    context 'with logging enabled' do
      before do
        Restforce.log = true
        Restforce.configuration.logger.should_receive(:debug).with('foobar')
      end

      it 'logs something' do
        Restforce.log 'foobar'
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
restforce-0.0.8 spec/lib/config_spec.rb
restforce-0.0.7 spec/lib/config_spec.rb
restforce-0.0.6 spec/lib/config_spec.rb
restforce-0.0.5 spec/lib/config_spec.rb
restforce-0.0.4 spec/lib/config_spec.rb
restforce-0.0.3 spec/lib/config_spec.rb
restforce-0.0.2 spec/lib/config_spec.rb
restforce-0.0.1 spec/lib/config_spec.rb