Sha256: 89d5121858a0adc1eba78dee322e163770933b6f78e970c0db6a43235338c24d

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'

describe 'Mutating arrays' do
  context 'for an instance method' do
    context 'that contains [1,2,3]' do
      before do
        write_file 'thing.rb', """
          class Thing
            def to_a
              [1,2,3]
            end
          end
        """
      end

      context 'with an expectation that the array is [1,2,3]' do
        before do
          write_file 'spec/thing_spec.rb', """
            $: << '.'
            require 'thing'

            describe 'Thing#to_a' do
              specify { Thing.new.to_a.should eq([1,2,3]) }
            end
          """
          mutate 'Thing#to_a spec/thing_spec.rb'
        end

        specify 'the mutation passes' do
          all_output.should include('passed')
        end
      end

      context 'with an expectation that the array responds to length' do
        before do
          write_file 'spec/thing_spec.rb', """
            $: << '.'
            require 'thing'

            describe 'Thing#to_a' do
              specify { Thing.new.to_a.should respond_to(:length) }
            end
          """
          mutate 'Thing#to_a spec/thing_spec.rb'
        end

        specify 'the mutation fails' do
          all_output.should include('failed')
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mutant-0.1.1 spec/functional/instance_method/array_spec.rb
mutant-0.1.0 spec/functional/instance_method/array_spec.rb