Skip to content
Browse files

Merge branch 'class_method_bug'

  • Loading branch information...
2 parents 9b1a21a + 38b9821 commit fee699adbbd241c06095fee15f9d283b3f75488e @hugocorbucci hugocorbucci committed Jan 2, 2010
Showing with 22 additions and 5 deletions.
  1. +10 −4 lib/rfactor/line_finder.rb
  2. +12 −1 spec/line_finder_spec.rb
View
14 lib/rfactor/line_finder.rb
@@ -1,7 +1,5 @@
module Rfactor
-
class LineFinder
-
def initialize(ast)
@ast = ast
end
@@ -33,7 +31,15 @@ def process_defn(exp)
@last_method_line = exp.endline
end
exp
- end
+ end
+
+ def process_defs(exp)
+ current = exp.line
+ if current > @method_line && current < @line
+ @method_line = current
+ @last_method_line = exp.last.line
+ end
+ exp
+ end
end
-
end
View
13 spec/line_finder_spec.rb
@@ -8,6 +8,10 @@ def my_method
3+2
end
+ def self.my_class_method
+ puts "everything"
+ end
+
def my_other_method
puts "anything"
end
@@ -30,7 +34,14 @@ def my_other_method
end
it "it should find method end line even if the method is the last" do
+ @finder.method_lines(13).last.should == 14
+ end
+
+ it "should find a class method start line" do
+ @finder.method_lines(9).first.should == 8
+ end
+
+ it "should find a class method end line" do
@finder.method_lines(9).last.should == 10
end
-
end

0 comments on commit fee699a

Please sign in to comment.
Something went wrong with that request. Please try again.