Permalink
Browse files

Merge pull request #397 from ConradIrwin/line-in-rackup

Set __LINE__ correctly for rackup files.
  • Loading branch information...
raggi committed Aug 26, 2012
2 parents d749c46 + 2fbf04b commit 279e6d25591fbd42d2d372c2bd9788d201aa616d
Showing with 8 additions and 1 deletion.
  1. +1 −1 lib/rack/builder.rb
  2. +1 −0 test/builder/line.ru
  3. +6 −0 test/spec_builder.rb
View
@@ -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
@@ -0,0 +1 @@
+run lambda{ |env| [200, {'Content-Type' => 'text/plain'}, [__LINE__.to_s]] }
View
@@ -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

0 comments on commit 279e6d2

Please sign in to comment.