Sha256: ed05be9b9dbd08675b07c782f8b5e35d58029770965d15e24c64a2a3792fdffb

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'

describe PrivatePlease, 'configuring PrivatePlease' do
  module Config
    class Simple
      def public_m ;  private_m()   end
      def private_m; 'SUCCESS'      end
      private_please  :private_m
    end
  end

  def do_the_calls
    Config::Simple.new.tap do |o|
      o.public_m      # -> inside call
      o.private_m     # -> outside call
    end
  end

#--------------

  it 'is disabled by default' do
    PrivatePlease::Configuration.reset_before_new_test
    PrivatePlease.should_not be_active
  end
  let(:storage) { PrivatePlease.storage }

  context 'when disabled' do

    before { PrivatePlease.activate(false) }
    before { do_the_calls }

    it('is not active') { PrivatePlease.should_not be_active }

    it 'does NOT record the calls to candidates' do
      storage.inside_called_candidates[ 'Config::Simple'].to_a.should == []
      storage.outside_called_candidates['Config::Simple'].to_a.should == []
    end
  end

  context 'when enabled' do

    before { PrivatePlease.activate(true) }
    before { do_the_calls }

    it('is active') { PrivatePlease.should be_active }

    it 'DOES record the calls to candidates' do
      storage.inside_called_candidates[ 'Config::Simple'].to_a.should == [:private_m]
      storage.outside_called_candidates['Config::Simple'].to_a.should == [:private_m]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
private_please-0.0.2 spec/03_configuration_spec.rb