Permalink
Browse files

Add another failing spec.

@bishboria this should help drive out tightening up the search for
usages :)
  • Loading branch information...
1 parent d8cb470 commit efb9d50286f5fcf7d283d74d6be46900dc76eab6 @mattwynne committed Jul 5, 2012
Showing with 36 additions and 11 deletions.
  1. +36 −11 spec/raffle/refactorings/remove_unused_temp_spec.rb
@@ -2,26 +2,26 @@
require_relative '../../../lib/raffle/refactorings/remove_unused_temp'
describe Raffle::Refactorings::RemoveUnusedTemp do
- let(:input) do
- %{
+ context 'when the temp is not used anywhere else in the same method' do
+ let(:input) { <<-CODE }
def thing
fred = 35
42
end
- }
- end
+ CODE
- it 'returns an s-expression with the temp removed' do
- refactor(input, 'fred').should == "def thing\n42\nend"
- end
+ it 'removes the temp' do
+ refactor(input, 'fred').should == "def thing\n42\nend"
+ end
- context 'when the temp is not found' do
- it 'returns the s-expression unchanged' do
- refactor(input, 'jim').should == "def thing\nfred = 35\n42\nend"
+ context 'when the temp is not found' do
+ it 'returns the s-expression unchanged' do
+ refactor(input, 'jim').should == "def thing\nfred = 35\n42\nend"
+ end
end
end
- context 'when the temp is used' do
+ context 'when the temp is used within the same method scope' do
it 'returns the s-expression unchanged' do
input = %{
def thing
@@ -36,6 +36,31 @@ def thing
end
end
+ context "when the temp's name is used as the name of another method" do
+ let(:input) { <<-CODE }
+ def thing
+ fred = 35
+ 42
+ end
+
+ def fred
+ "something unrelated"
+ end
+ CODE
+
+ it 'removes the temp from the first method' do
+ refactor(input, 'fred').should == <<-CODE
+def thing
+42
+end
+
+def fred
+"something unrelated"
+end
+ CODE
+ end
+ end
+
context 'when the temp is the return value' do
it 'returns the original return value'
end

0 comments on commit efb9d50

Please sign in to comment.