Sha256: b1115010c404d3d178488be46e57c30aaed74f25652f1e12862bad57a966ca66
Contents?: true
Size: 1.04 KB
Versions: 2
Compression:
Stored size: 1.04 KB
Contents
require 'spec_helper' describe 'Veritas::Optimizable#optimize' do subject { object.optimize } let(:klass) { Class.new { include Optimizable, Immutable } } let(:object) { klass.new } context 'when there is no optimizer for the class' do it { should equal(object) } it_should_behave_like 'an optimize method' end context 'when there is an optimizer for the class' do let(:optimized) { mock('Optimized') } let(:optimizer) { mock('Optimizer', :call => optimized) } before do klass.optimizer = optimizer optimized.stub!(:memoize).and_return(optimized) end it { should equal(optimized) } it 'calls the optimizer with the object' do optimizer.should_receive(:call).with(object).and_return(optimized) should equal(optimized) end it "memoizes the optimized value for it's own #optimize" do optimized.should_receive(:memoize).with(:optimize, optimized).and_return(optimized) should equal(optimized) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
veritas-0.0.2 | spec/unit/veritas/optimizable/optimize_spec.rb |
veritas-0.0.1 | spec/unit/veritas/optimizable/optimize_spec.rb |