Sha256: 025b7bd54b38768cde674b027198f90f3ba7361020b08926411e84dba63ca20c
Contents?: true
Size: 1.42 KB
Versions: 1
Compression:
Stored size: 1.42 KB
Contents
require 'spec_helper' describe 'Veritas::Optimizer.chain' do let(:operation) { mock('Operation') } let(:object) { Optimizer } let(:noop) { object::Noop } let(:optimizer_class) { Class.new(Optimizer) } context 'with no optimizers' do subject { object.chain } it { should equal(noop) } it 'returns a block that returns the operation' do subject.call(operation).should equal(operation) end end context 'with an optimizer that can optimize the operation' do subject { object.chain(optimizer_class) } let(:optimized) { mock('Optimized') } before do optimized = self.optimized optimizer_class.send(:define_method, :optimizable?) { true } optimizer_class.send(:define_method, :optimize) { optimized } end it { should_not equal(noop) } it { should be_kind_of(Proc) } it 'returns a block that optimizes the operation' do subject.call(operation).should equal(optimized) end end context 'with an optimizer that cannot optimize the operation' do subject { object.chain(optimizer_class) } before do optimizer_class.send(:define_method, :optimizable?) { false } end it { should_not equal(noop) } it { should be_kind_of(Proc) } it 'returns a block that calls the successor (Noop) with the operation' do subject.call(operation).should equal(operation) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
veritas-0.0.2 | spec/unit/veritas/optimizer/class_methods/chain_spec.rb |