Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 83cb1b4992
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 54 lines (46 sloc) 1.333 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
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
"""
          run_simple '../../bin/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
"""
          run_simple '../../bin/mutate Thing#to_a spec/thing_spec.rb'
        end

        specify 'the mutation fails' do
          all_output.should include('failed')
        end
      end
    end
  end
end
Something went wrong with that request. Please try again.