Sha256: 02a4eeeffbff9e976a79ab4be7d9116f0c712770fc564009db51e8085c119ea4
Contents?: true
Size: 1.05 KB
Versions: 2
Compression:
Stored size: 1.05 KB
Contents
require 'spec_helper' module Finitio describe Attribute, "fetch_on" do let(:attr){ Attribute.new(:red, intType) } subject{ attr.fetch_on(arg) } context 'with an object that does not support fetch' do let(:arg){ 12 } it 'should raise an error' do ->{ subject }.should raise_error(ArgumentError, "Object responding to `fetch` expected") end end context 'with a hash with symbol keys' do let(:arg){ { red: 233 } } it{ should eq(233) } end context 'with a hash with string keys' do let(:arg){ { "red" => 233 } } it{ should eq(233) } end context 'when the key is missing and no block' do let(:arg){ { other: 123 } } it 'should raise an error' do ->{ attr.fetch_on(arg) }.should raise_error(KeyError) end end context 'when the key is missing and a block' do let(:arg){ { other: 123 } } it 'should yield the block' do attr.fetch_on(arg){ "none" }.should eq("none") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
finitio-0.4.1 | spec/unit/attribute/test_fetch_on.rb |
finitio-0.4.0 | spec/unit/attribute/test_fetch_on.rb |