Permalink
Browse files

Passing features and adjusting Hoe to new versions.

Hugo
  • Loading branch information...
1 parent 0db92c5 commit a222c3ecfaedaf5ca822ce082674fc4d6500cb2e @hugocorbucci hugocorbucci committed Dec 31, 2009
Showing with 28 additions and 5 deletions.
  1. +4 −1 Rakefile
  2. +0 −1 features/extract_method.feature
  3. +2 −3 lib/rfactor/code.rb
  4. +22 −0 spec/code_spec.rb
View
5 Rakefile
@@ -4,9 +4,11 @@ require 'hoe'
# Generate all the Rake tasks
# Run 'rake -T' to see list of generated tasks (from gem root directory)
-$hoe = Hoe.new('rfactor', Rfactor::VERSION) do |p|
+$hoe = Hoe.spec('rfactor') do |p|
p.developer('Fabio Kung', 'fabio.kung@gmail.com')
+ p.developer('Hugo Corbucci', 'hugo.corbucci@gmail.com')
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
+ p.readme_file = 'README.rdoc'
p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
p.rubyforge_name = p.name # TODO this is default value
p.extra_deps = [
@@ -20,6 +22,7 @@ $hoe = Hoe.new('rfactor', Rfactor::VERSION) do |p|
path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
p.rsync_args = '-av --delete --ignore-errors'
+ p.summary = "Common refactorings for Ruby code, written in Ruby"
end
require 'newgem/tasks' # load /tasks/*.rake
View
1 features/extract_method.feature
@@ -28,7 +28,6 @@ Feature: Extract Method
puts /to be/
puts 'refactored'
end
-
"""
Scenario: Simple code, no variables, many methods
View
5 lib/rfactor/code.rb
@@ -44,13 +44,12 @@ def extract_method(args)
new_code << "#{$1} = " if is_assignment
new_code << "#{method_call}\n"
- elsif line_number == method_lines.last + 1
- new_code << "\n#{identation}def #{method_call}\n#{method_contents}#{identation}end\n"
+ elsif line_number == method_lines.last
+ new_code << "#{identation}end\n\n#{identation}def #{method_call}\n#{method_contents}"
end
new_code << line unless selected_lines.include? line_number
end
- new_code << new_method_code unless method_lines.last < @code.size
new_code
end
View
22 spec/code_spec.rb
@@ -45,6 +45,28 @@ def long_method()
end
end
+ it "should extract method and add it even if the method is the last thing of the code" do
+ rfactor = Rfactor::Code.new("""
+ def the_method(firstArg, secondArg)
+ puts \"some\"
+ puts :code
+ puts /to be/
+ puts 'refactored'
+ end""")
+ new_code = rfactor.extract_method(:name => "print", :start => 3, :end => 5)
+ new_code.should == """
+ def the_method(firstArg, secondArg)
+ print()
+ puts 'refactored'
+ end
+
+ def print()
+ puts \"some\"
+ puts :code
+ puts /to be/
+ end"""
+ end
+
context "no parameters method extraction" do
before(:each) do
@rfactor = Rfactor::Code.new(NO_PARAMETER_CODE)

0 comments on commit a222c3e

Please sign in to comment.