Sha256: c3272db61d2cb7dfca5a2933fac1bc625a76d791a07813b40585473ca738f308
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
require 'spec_helper' module Qrb describe AdType, 'dress' do let(:type){ AdType.new(Color, rgb: [intType, ->(i){ i*2 }, Qrb::IDENTITY ], hex: [floatType, ->(f){ f*3 }, Qrb::IDENTITY ]) } subject{ type.dress(arg) } context 'with a color' do let(:arg){ Color.new(12, 13, 15) } it{ should be(arg) } end context 'with an integer' do let(:arg){ 12 } it{ should eq(24) } end context 'with a float' do let(:arg){ 12.0 } it{ should eq(36.0) } end context 'with an unrecognized' do let(:arg){ "foo" } it 'should raise an error' do ->{ subject }.should raise_error(TypeError, "Invalid value `foo` for Color") end end context 'when the upper raises an error' do let(:type){ AdType.new(Color, rgb: [ intType, ->(t){ raise ArgumentError }, Qrb::IDENTITY ]) } it 'should hide the error' do err = type.dress(12) rescue $! err.should be_a(TypeError) err.message.should eq("Invalid value `12` for Color") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
qrb-0.3.0 | spec/unit/type/ad_type/test_dress.rb |