Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add missing singleton method spec for if nodes

  • Loading branch information...
commit 8793c9e44ee42bacec903a9d5146449d4bc0685d 1 parent b3432d9
@txus authored
Showing with 57 additions and 0 deletions.
  1. +57 −0 spec/functional/singleton_method/if_spec.rb
View
57 spec/functional/singleton_method/if_spec.rb
@@ -0,0 +1,57 @@
+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 self.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.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.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
Please sign in to comment.
Something went wrong with that request. Please try again.