Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Set __LINE__ correctly for rackup files.

Before this change the line numbers were off by one, which broke
debugging tools like Pry in addition to causing a smidgen of user
confusion.

Reported-At: pry/pry#571
  • Loading branch information...
commit 2fbf04b0f8282a2df0d2d4b06a2a1f4f9462c8d4 1 parent edc8b92
@ConradIrwin ConradIrwin authored
View
2  lib/rack/builder.rb
@@ -38,7 +38,7 @@ def self.parse_file(config, opts = Server::Options.new)
end
cfgfile.sub!(/^__END__\n.*\Z/m, '')
app = eval "Rack::Builder.new {\n" + cfgfile + "\n}.to_app",
- TOPLEVEL_BINDING, config
+ TOPLEVEL_BINDING, config, 0
else
require config
app = Object.const_get(::File.basename(config, '.rb').capitalize)
View
1  test/builder/line.ru
@@ -0,0 +1 @@
+run lambda{ |env| [200, {'Content-Type' => 'text/plain'}, [__LINE__.to_s]] }
View
6 test/spec_builder.rb
@@ -197,5 +197,11 @@ def config_file(name)
Rack::MockRequest.new(app).get("/").body.to_s.should.equal 'OK'
$:.pop
end
+
+ it "sets __LINE__ correctly" do
+ app, options = Rack::Builder.parse_file config_file('line.ru')
+ options = nil # ignored, prevents warning
+ Rack::MockRequest.new(app).get("/").body.to_s.should.equal '1'
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.