Skip to content

Commit 19c26c6

Browse files
committed
[chore] Use non-deprecated constant to determine Rack presence and define rack.version
This is more forward compatible with Rack 3.x.
1 parent cc05031 commit 19c26c6

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

src/main/ruby/jruby/rack/rack_ext.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
require 'rack'
1010
rescue LoadError
1111
require 'vendor/rack'
12-
end unless defined?(::Rack::VERSION)
12+
end unless defined?(::Rack::RELEASE)
1313

1414
# Servlet API friendly extensions to Rack
1515
# Allows for forwarding the request to another servlet/JSP

src/main/ruby/rack/handler/servlet/default_env.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def load_variable(env, key)
231231

232232
def load_builtin(env, key)
233233
case key
234-
when 'rack.version' then env[key] = ::Rack::VERSION
234+
when 'rack.version' then env[key] = ::Rack::RELEASE
235235
when 'rack.multithread' then env[key] = true
236236
when 'rack.multiprocess' then env[key] = false
237237
when 'rack.run_once' then env[key] = false

src/spec/ruby/jruby/rack/booter_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@
264264
# Booter.boot! run :
265265
should_not_eval_as_nil "ENV['RACK_ENV']"
266266
# rack got required :
267-
should_not_eval_as_nil "defined?(Rack::VERSION)"
267+
should_not_eval_as_nil "defined?(Rack::RELEASE)"
268268
should_not_eval_as_nil "defined?(Rack.release)"
269269
# check if it got loaded correctly :
270270
should_not_eval_as_nil "Rack::Request.new({}) rescue nil"
@@ -313,7 +313,7 @@
313313
should_not_eval_as_nil "ENV['RAILS_ENV']"
314314

315315
# rack not yet required (let bundler decide which rack version to load) :
316-
should_eval_as_nil "defined?(Rack::VERSION)"
316+
should_eval_as_nil "defined?(Rack::RELEASE)"
317317
should_eval_as_nil "defined?(Rack.release)"
318318
end
319319

src/spec/ruby/rack/application_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def newRuntime()
310310

311311
it "does not require 'rack' (until booter is called)" do
312312
@runtime = app_factory.newRuntime
313-
should_eval_as_nil "defined?(::Rack::VERSION)"
313+
should_eval_as_nil "defined?(::Rack::RELEASE)"
314314
end
315315

316316
it "loads specified version of rack via bundler", :lib => :stub do

src/spec/ruby/rack/handler/servlet_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def _env
4444

4545
it "creates a hash with the Rack variables in it" do
4646
hash = servlet.create_env(@servlet_env)
47-
expect(hash['rack.version']).to eq Rack::VERSION
47+
expect(hash['rack.version']).to eq Rack::RELEASE
4848
expect(hash['rack.multithread']).to eq true
4949
expect(hash['rack.multiprocess']).to eq false
5050
expect(hash['rack.run_once']).to eq false
@@ -204,7 +204,7 @@ def _env
204204
end
205205

206206
env = servlet.create_env @servlet_env
207-
expect(env["rack.version"]).to eq Rack::VERSION
207+
expect(env["rack.version"]).to eq Rack::RELEASE
208208
expect(env["CONTENT_TYPE"]).to eq "text/html"
209209
expect(env["HTTP_HOST"]).to eq "serverhost"
210210
expect(env["HTTP_ACCEPT"]).to eq "text/*"

0 commit comments

Comments
 (0)