Sha256: 9abc72cc990759effd9805e885e1b245241a559ff1d98a4eaccd79fa8a99dab7

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Optimizer::Optimizable, '#optimize' do
  subject { object.optimize }

  let(:described_class) { Class.new { include Optimizer::Optimizable, Adamantium } }
  let(:object)          { described_class.new                                      }

  context 'when there is no optimizer for the class' do
    it { should be(object) }

    it_should_behave_like 'an optimize method'
  end

  context 'when there is an optimizer for the class' do
    let(:optimized) { double('Optimized', :frozen? => true) }
    let(:optimizer) { double('Optimizer', call: optimized)  }

    before do
      described_class.optimizer = optimizer
      allow(optimized).to receive(:optimize).and_return(optimized)
    end

    it { should be(optimized) }

    it 'calls the optimizer with the object' do
      expect(optimizer).to receive(:call).with(object).and_return(optimized)
      should be(optimized)
    end

    it '#optimize the optimized object' do
      expect(optimized).to receive(:optimize).with(no_args).and_return(optimized)
      should be(optimized)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axiom-optimizer-0.2.0 spec/unit/axiom/optimizer/optimizable/optimize_spec.rb