Skip to content

Commit

Permalink
Merge pull request rack#397 from ConradIrwin/line-in-rackup
Browse files Browse the repository at this point in the history
Set __LINE__ correctly for rackup files.
  • Loading branch information
raggi committed Aug 26, 2012
2 parents d749c46 + 2fbf04b commit 279e6d2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rack/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions test/builder/line.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
run lambda{ |env| [200, {'Content-Type' => 'text/plain'}, [__LINE__.to_s]] }
6 changes: 6 additions & 0 deletions test/spec_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.