diff --git a/lib/girffi/builder.rb b/lib/girffi/builder.rb
index <HASH>..<HASH> 100644
--- a/lib/girffi/builder.rb
+++ b/lib/girffi/builder.rb
@@ -19,12 +19,11 @@ module GirFFI
       sym = info.symbol
       argnames = info.args.map {|a| a.name}
 
-      code = <<-CODE
+      return <<-CODE
 	def #{info.name} #{argnames.join(', ')}
 	  Lib.#{sym} #{argnames.join(', ')}
 	end
       CODE
-      return code.gsub(/(^\s*|\s*$)/, "")
     end
 
     def function_introspection_data namespace, function
diff --git a/test/test_builder.rb b/test/test_builder.rb
index <HASH>..<HASH> 100644
--- a/test/test_builder.rb
+++ b/test/test_builder.rb
@@ -43,7 +43,7 @@ class BuilderTest < Test::Unit::TestCase
 
       should "build correct definition of Gtk.main" do
 	code = @builder.function_definition @go
-	assert_equal "def main\nLib.gtk_main\nend", code
+	assert_equal "def main\nLib.gtk_main\nend", code.gsub(/(^\s*|\s*$)/, "")
       end
 
       should "attach function to Whatever::Lib" do
Cleaning up whitespace is not functional.