Sha256: ffa07d335da2c614701c8f47ea16ca5bb3053519c0d408fe041cb49c4084bfb7
Contents?: true
Size: 1.8 KB
Versions: 3
Compression:
Stored size: 1.8 KB
Contents
# frozen_string_literal: true require 'spec_helper' describe Sinclair::ConfigFactory::MethodsBuilder do describe '#build' do let(:config_class) { Class.new(Sinclair::Config) } let(:config) { config_class.new } let(:code_block) { proc { builder.build } } let(:setter_block) do proc do |value| config.instance_variable_set(:@name, value) end end context 'when not initializing defaults' do subject(:builder) { described_class.new(config_class, :name, 'password') } it_behaves_like 'a config methods builder adding config' it 'does not set a default value' do code_block.call expect(config.name).to be_nil end end context 'when initializing defaults' do subject(:builder) do described_class.new( config_class, name: 'Bobby', 'password' => 'abcdef' ) end it_behaves_like 'a config methods builder adding config' it 'sets a default value' do code_block.call expect(config.name).to eq('Bobby') end end context 'when mixing names and hash' do subject(:builder) do described_class.new( config_class, :name, 'password' => 'abcdef' ) end it_behaves_like 'a config methods builder adding config' it 'does not set a default value' do code_block.call expect(config.name).to be_nil end context 'when name and hash define same config' do subject(:builder) do described_class.new( config_class, :name, name: 'Bobby' ) end it_behaves_like 'a config methods builder adding config' it 'sets a default value' do code_block.call expect(config.name).to eq('Bobby') end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems