Sha256: b28e6940a76a60cc3c37d29154d3bda13ab066e15f500f0374d308e203978147
Contents?: true
Size: 876 Bytes
Versions: 6
Compression:
Stored size: 876 Bytes
Contents
require 'spec_helper' describe Rules::Parameters::Attribute do let (:user) do stub('user', name: 'terry').tap do |u| u.stub_chain(:account, :balance).and_return(100) end end let(:attribute) { Rules::Parameters::Attribute.new(key: 'test_key') } describe '#evaluate' do it 'retrieves the attribute value from the given hash' do attribute.evaluate(key_1: 1, key_2: 'john', test_key: 'carol').should == 'carol' end context 'when the attribute is missing' do it 'returns nil by default' do attribute.evaluate(key_1: 1, key_2: 'john').should be_nil end it 'raises an error if set in the configuration settings' do Rules.config.stub(missing_attributes_are_nil?: false) expect { attribute.evaluate(key_1: 1, key_2: 'john') }.to raise_error KeyError end end end end
Version data entries
6 entries across 6 versions & 1 rubygems