Sha256: c43c1c48d2e1cb79be3f107560c4f881cce4bddcd5448ac0b1f3f66379bafadd

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'

describe 'Mutating If clauses' do
  context 'for an instance method' do
    context 'that contains an if-else that returns 42' do
      before do
        write_file 'life.rb', """
          class Life
            def answer
              if true
                42
              else
                24
              end
            end
          end
        """
      end

      context 'with an expectation that the answer is 42' do
        before do
          write_file 'spec/life_spec.rb', """
            $: << '.'
            require 'life'

            describe 'Life#answer' do
              specify { Life.new.answer.should eq(42) }
            end
          """
          run_simple '../../bin/mutate Life#answer spec/life_spec.rb'
        end

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

      context 'with an expectation that the answer is a Fixnum' do
        before do
          write_file 'spec/life_spec.rb', """
            $: << '.'
            require 'life'

            describe 'Life#answer' do
              specify { Life.new.answer.should be_kind_of(Fixnum) }
            end
          """
          run_simple '../../bin/mutate Life#answer spec/life_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/if_spec.rb
mutant-0.1.0 spec/functional/instance_method/if_spec.rb