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 IS_JRUBY
end end
IS_WINDOWS = RUBY_PLATFORM =~ /mswin|ming|cygwin/
def self.windows? def self.windows?
RUBY_PLATFORM =~ /mswin|ming|cygwin/ IS_WINDOWS
end end
end end

View file

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

View file

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

View file

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