Sha256: 9b385ed4b1f5b67246190b8660e2979e7764a9beade268a4f3044b704e8c45d1

Contents?: true

Size: 1.28 KB

Versions: 12

Compression:

Stored size: 1.28 KB

Contents

require 'spec_helper'
describe NSConnector::Config do
	before(:each) do
		# Reset our 'global' config
		# Yes, it's kinda not nice to have a global configuration like
		# this, but it's better than passing the damned thing around
		# everywhere. Thread safety should be fine for reads.
		NSConnector::Config.set_config!({})
	end

	it 'sets a valid config' do
		NSConnector::Config.set_config!(valid_config)
		expect(NSConnector::Config.check_valid!).to be_true
	end

	it 'sets an invalid config' do
		NSConnector::Config.set_config!(:invalid => true)
		expect{NSConnector::Config.check_valid!}.to raise_error
	end

	it 'allows reading of keys' do
		expect(NSConnector::Config[:account_id]).to be_nil

		NSConnector::Config.set_config!(valid_config)

		expect(NSConnector::Config[:account_id]).to eql('account_id')
		expect(NSConnector::Config['account_id']).to eql('account_id')
	end

	it 'allows writing of keys' do
		expect(NSConnector::Config[:account_id]).to be_nil
		NSConnector::Config[:account_id] = 'account_id'
		expect(NSConnector::Config[:account_id]).to eql('account_id')

		NSConnector::Config['account_id'] = nil
		expect(NSConnector::Config[:account_id]).to be_nil
	end

	it 'has defaults' do
		expect(NSConnector::Config['use_threads']).
			to eql(!!NSConnector::Config['use_threads'])
	end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ns_connector-0.0.17 spec/config_spec.rb
ns_connector-0.0.16 spec/config_spec.rb
ns_connector-0.0.15 spec/config_spec.rb
ns_connector-0.0.14 spec/config_spec.rb
ns_connector-0.0.13 spec/config_spec.rb
ns_connector-0.0.12 spec/config_spec.rb
ns_connector-0.0.11 spec/config_spec.rb
ns_connector-0.0.10 spec/config_spec.rb
ns_connector-0.0.9 spec/config_spec.rb
ns_connector-0.0.8 spec/config_spec.rb
ns_connector-0.0.7 spec/config_spec.rb
ns_connector-0.0.6 spec/config_spec.rb