<commit_before># encoding: utf-8

require 'spec_helper'

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

  let(:described_class) { Class.new { include Optimizer::Optimizable, Immutable } }
  let(:object)          { described_class.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
      described_class.optimizer = optimizer
      optimized.stub!(:optimize).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 '#optimize the optimized object' do
      optimized.should_receive(:optimize).with(no_args).and_return(optimized)
      should equal(optimized)
    end
  end
end<commit_msg>Fixed failing spec for Optimizable#optimize due to changes in veritas<commit_after># encoding: utf-8

require 'spec_helper'

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

  let(:described_class) { Class.new { include Optimizer::Optimizable, Immutable } }
  let(:object)          { described_class.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', :frozen? => true)   }
    let(:optimizer) { mock('Optimizer', :call => optimized) }

    before do
      described_class.optimizer = optimizer
      optimized.stub!(:optimize).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 '#optimize the optimized object' do
      optimized.should_receive(:optimize).with(no_args).and_return(optimized)
      should equal(optimized)
    end
  end
end
{'fraction_non_alphanumeric': 0.09696969696969697, 'fraction_numerical': 0.0008658008658008658, 'mean_word_length': 3.104795737122558, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5523888', 'n_tokens_mistral': 708, 'n_tokens_neox': 677, 'n_words': 180}