Sha256: 10ac72c41b9911b0994de6d6dd394778db7541a12e920486bd4ed90b2326d4dd

Contents?: true

Size: 1.21 KB

Versions: 18

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

describe Mutant::Subject, '#each' do
  subject { object.each { |item| yields << item }   }

  let(:object)   { described_class.new(matcher, context, ast) }
  let(:matcher)  { mock('Matcher')                            }
  let(:root)     { mock('Root AST')                           }
  let(:ast)      { mock('AST')                                }
  let(:context)  { mock('Context', :root => root)             }
  let(:mutant)   { mock('Mutant')                             }
  let(:mutation) { mock('Mutation')                           }
  let(:yields)   { []                                         }

  before do
    Mutant::Mutator.stub(:each).with(ast).and_yield(mutant).and_return(Mutant::Mutator)
    Mutant::Mutation.stub(:new => mutation)
  end

  it_should_behave_like 'an #each method'

  it 'should initialize mutator with ast' do
    Mutant::Mutator.should_receive(:each).with(ast).and_yield(mutation).and_return(Mutant::Mutator)
    subject
  end

  it 'should yield mutations' do
    expect { subject }.to change { yields.dup }.from([]).to([mutation])
  end

  it 'should initialize mutation' do
    Mutant::Mutation.should_receive(:new).with(object, mutant).and_return(mutation)
    subject
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

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