Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Puma env detection helpers in tests. #1156

Merged
merged 2 commits into from Nov 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/puma/detect.rb
Expand Up @@ -5,7 +5,9 @@ def self.jruby?
IS_JRUBY
end

IS_WINDOWS = RUBY_PLATFORM =~ /mswin|ming|cygwin/

def self.windows?
RUBY_PLATFORM =~ /mswin|ming|cygwin/
IS_WINDOWS
end
end
2 changes: 1 addition & 1 deletion test/test_cli.rb
Expand Up @@ -62,7 +62,7 @@ def test_control_for_tcp
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}"

Expand Down
2 changes: 1 addition & 1 deletion test/test_minissl.rb
Expand Up @@ -4,7 +4,7 @@

class TestMiniSSL < Minitest::Test

if defined?(JRUBY_VERSION)
if Puma.jruby?
def test_raises_with_invalid_keystore_file
ctx = Puma::MiniSSL::Context.new

Expand Down
8 changes: 4 additions & 4 deletions test/test_puma_server_ssl.rb
Expand Up @@ -31,7 +31,7 @@ def setup

@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
Expand Down Expand Up @@ -116,7 +116,7 @@ def test_ssl_v3_rejection
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
Expand All @@ -133,7 +133,7 @@ def assert_ssl_client_error_match(error, subject=nil, &blk)
@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
Expand Down Expand Up @@ -168,7 +168,7 @@ def assert_ssl_client_error_match(error, subject=nil, &blk)
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
Expand Down
2 changes: 1 addition & 1 deletion test/test_unix_socket.rb
Expand Up @@ -2,7 +2,7 @@

# 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"]] }
Expand Down