1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Use Puma env detection helpers in tests. (#1156)

* Use Puma env detection helpers in tests.

* Check only once if environment is windows.

Same as #jruby?
This commit is contained in:
Francesco Rodriguez 2016-11-23 01:27:30 +01:00 committed by Nate Berkopec
parent b638dd1948
commit cc4e8105dc
5 changed files with 10 additions and 8 deletions

View file

@ -5,7 +5,9 @@ module Puma
IS_JRUBY
end
IS_WINDOWS = RUBY_PLATFORM =~ /mswin|ming|cygwin/
def self.windows?
RUBY_PLATFORM =~ /mswin|ming|cygwin/
IS_WINDOWS
end
end

View file

@ -62,7 +62,7 @@ class TestCLI < Minitest::Test
t.join
end
unless defined?(JRUBY_VERSION) || RbConfig::CONFIG["host_os"] =~ /mingw|mswin/
unless Puma.jruby? || Puma.windows?
def test_control_clustered
url = "unix://#{@tmp_path}"

View file

@ -4,7 +4,7 @@ require "puma/minissl"
class TestMiniSSL < Minitest::Test
if defined?(JRUBY_VERSION)
if Puma.jruby?
def test_raises_with_invalid_keystore_file
ctx = Puma::MiniSSL::Context.new

View file

@ -31,7 +31,7 @@ class TestPumaServerSSL < Minitest::Test
@ctx = Puma::MiniSSL::Context.new
if defined?(JRUBY_VERSION)
if Puma.jruby?
@ctx.keystore = File.expand_path "../../examples/puma/keystore.jks", __FILE__
@ctx.keystore_pass = 'blahblah'
else
@ -116,7 +116,7 @@ class TestPumaServerSSL < Minitest::Test
Net::HTTP::Get.new '/'
end
end
unless defined?(JRUBY_VERSION)
unless Puma.jruby?
assert_match("wrong version number", @events.error.message) if @events.error
end
end
@ -133,7 +133,7 @@ class TestPumaServerSSLClient < Minitest::Test
@app = lambda { |env| [200, {}, [env['rack.url_scheme']]] }
@ctx = Puma::MiniSSL::Context.new
if defined?(JRUBY_VERSION)
if Puma.jruby?
@ctx.keystore = File.expand_path "../../examples/puma/client-certs/keystore.jks", __FILE__
@ctx.keystore_pass = 'blahblah'
else
@ -168,7 +168,7 @@ class TestPumaServerSSLClient < Minitest::Test
assert_equal !!error, client_error
# The JRuby MiniSSL implementation lacks error capturing currently, so we can't inspect the
# messages here
unless defined?(JRUBY_VERSION)
unless Puma.jruby?
assert_match error, events.error.message if error
assert_equal @host, events.addr if error
assert_equal subject, events.cert.subject.to_s if subject

View file

@ -2,7 +2,7 @@ require "test_helper"
# UNIX sockets are not recommended on JRuby
# (or Windows)
unless defined?(JRUBY_VERSION) || RbConfig::CONFIG["host_os"] =~ /mingw|mswin/
unless Puma.jruby? || Puma.windows?
class TestPumaUnixSocket < Minitest::Test
App = lambda { |env| [200, {}, ["Works"]] }