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.4 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 hashes' do
  context 'for an instance method' do
    context 'that contains {:foo => {:bar => 3}}' do
      before do
        write_file 'thing.rb', """
class Thing
def to_hash
{:foo => {:bar => 3}}
end
end
"""
      end

      context 'with an expectation that hash[:foo][:bar] is 3' do
        before do
          write_file 'spec/thing_spec.rb', """
$: << '.'
require 'thing'

describe 'Thing#to_hash' do
specify { Thing.new.to_hash[:foo][:bar].should eq(3) }
end
"""
          run_simple '../../bin/mutate Thing#to_hash spec/thing_spec.rb'
        end

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

      context 'with an expectation that hash[:foo][:bar] is a Fixnum' do
        before do
          write_file 'spec/thing_spec.rb', """
$: << '.'
require 'thing'

describe 'Thing#to_hash' do
specify { Thing.new.to_hash[:foo][:bar].should be_kind_of(Fixnum) }
end
"""
          run_simple '../../bin/mutate Thing#to_hash 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.