Sha256: 1600f30669859230e5c3b50f70599747bd8caa3fd3376b2bdd22d014417036d1

Contents?: true

Size: 1.7 KB

Versions: 3

Compression:

Stored size: 1.7 KB

Contents

#!/usr/bin/env ruby

BEGIN {
	require 'pathname'
	basedir = Pathname.new( __FILE__ ).dirname.parent.parent

	libdir = basedir + "lib"

	$LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
	$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
}

require 'tempfile'
require 'logger'
require 'fileutils'
require 'rspec'

require 'spec/lib/helpers'

require 'configurability'
require 'configurability/deferredconfig'


#####################################################################
###	C O N T E X T S
#####################################################################
describe Configurability::DeferredConfig do

	before( :all ) do
		setup_logging( :fatal )
	end

	after( :each ) do
		Configurability.configurable_objects.clear
		Configurability.reset
	end

	it "calls Configurability.install_config with itself when a 'configure' method is defined" do
		config = { :testing => :testing_config }
		Configurability.configure_objects( config )

		a_class = Class.new do
			extend Configurability::DeferredConfig
			class << self; attr_accessor :config_object; end
			def self::config_key; "testing"; end
			def self::configure( config )
				self.config_object = config
			end
		end

		a_class.config_object.should == :testing_config
	end


	it "includes defaults when configuring" do
		config = { :testing => :testing_config }
		Configurability.configure_objects( config )

		a_class = Class.new do
			extend Configurability::DeferredConfig
			class << self; attr_accessor :config_object; end
			def self::config_key; "testing"; end
			def self::configure( config )
				self.config_object = config
			end
		end

		a_class.config_object.should == :testing_config
	end

end

# vim: set nosta noet ts=4 sw=4:

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
configurability-2.0.2 spec/configurability/deferredconfig_spec.rb
configurability-2.0.1 spec/configurability/deferredconfig_spec.rb
configurability-2.0.0 spec/configurability/deferredconfig_spec.rb