Sha256: 32d46a0e5e5a103a7ec6b92ba2bbf9a46bdb80906692944da7a147b21a73348c

Contents?: true

Size: 1.07 KB

Versions: 19

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

describe Mutant::Mutator, '#emit_new' do
  subject { object.send(:emit_new) { generated } }

  class Block
    def arguments; @arguments; end

    def called?
      defined?(@arguments)
    end

    def call(*arguments)
      @arguments = arguments
    end
  end

  let(:object) { class_under_test.new(input, block) }
  let(:block)  { Block.new                          }
  let(:input)  { :input                             }

  let(:class_under_test) do
    Class.new(described_class) do
      def dispatch
        #noop
      end
    end
  end

  context 'when new object generated' do
    let(:generated) { :generated }

    it 'should call block' do
      subject
      block.should be_called
    end

    it 'should call block with generated object' do
      subject
      block.arguments.should eql([generated])
    end
  end

  context 'when new AST could not be generated' do
    let(:generated) { input }

    it 'should raise error' do
      expect { subject }.to raise_error(RuntimeError, 'New AST could not be generated after 3 attempts')
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
mutant-0.3.0.beta2 spec/unit/mutant/mutator/emit_new_spec.rb
mutant-0.2.20 spec/unit/mutant/mutator/emit_new_spec.rb
mutant-0.2.17 spec/unit/mutant/mutator/emit_new_spec.rb
mutant-0.2.16 spec/unit/mutant/mutator/emit_new_spec.rb
mutant-0.2.15 spec/unit/mutant/mutator/emit_new_spec.rb
mutant-0.2.14 spec/unit/mutant/mutator/emit_new_spec.rb
mutant-0.2.13 spec/unit/mutant/mutator/emit_new_spec.rb
mutant-0.2.12 spec/unit/mutant/mutator/emit_new_spec.rb
mutant-0.2.11 spec/unit/mutant/mutator/emit_new_spec.rb
mutant-0.2.9 spec/unit/mutant/mutator/emit_new_spec.rb
mutant-0.2.8 spec/unit/mutant/mutator/emit_new_spec.rb
mutant-0.2.7 spec/unit/mutant/mutator/emit_new_spec.rb
mutant-0.2.6 spec/unit/mutant/mutator/emit_new_spec.rb
mutant-0.2.5 spec/unit/mutant/mutator/emit_new_spec.rb
mutant-0.2.4 spec/unit/mutant/mutator/emit_new_spec.rb
mutant-0.2.3 spec/unit/mutant/mutator/emit_new_spec.rb
mutant-0.2.2 spec/unit/mutant/mutator/emit_new_spec.rb
mutant-0.2.1 spec/unit/mutant/mutator/emit_new_spec.rb
mutant-0.2.0 spec/unit/mutant/mutator/emit_new_spec.rb