New Upstream Release - ruby-health-check

Ready changes

Summary

Merged new upstream version: 3.1.0 (was: 3.0.0).

Resulting package

Built on 2022-03-14T13:48 (took 2m41s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-releases ruby-health-check

Lintian Result

Diff

diff --git a/.gitignore b/.gitignore
index e90f6ea..e2b4423 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,6 +24,8 @@ test/bin/
 railsapps/
 test/*.gemfile.lock
 ,*
+.vagrant
+ubuntu*console.log
 
 # See: https://gist.github.com/ianheggie/9327010
 # for Global git ignore for OS/IDE/temp/backup files
diff --git a/.travis.yml b/.travis.yml
index 8535ef9..7c02aef 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,4 +1,7 @@
-sudo: false
+dest: xenial
+os: linux
+# Released April 2018, Support ended: April 2023
+# ruby 2.4.9, 2.5.3, 2.5.7, 2.6.5 (default) and 2.7.0 pre-installed on travis
 addons:
   apt:
     packages:
@@ -23,9 +26,39 @@ bundler_args: "--binstubs"
 
 script: ./test/test_with_railsapp
 
-matrix:
+jobs:
   fast_finish: true
 
+  allow_failures:
+
+    - rvm: 3.0.1
+      gemfile: test/rails_6.1.gemfile
+      env:
+      - RAILS_VERSION=6.1
+      - MIDDLEWARE=YES
+
+    - rvm: 3.0.1
+      gemfile: test/rails_edge.gemfile
+      env: 
+      - RAILS_VERSION=edge 
+      - MIDDLEWARE=YES
+      - SMTP_STARTTLS=DISABLED
+
+    - rvm: ruby-head
+      gemfile: test/rails_6.1.gemfile
+      env: 
+      - RAILS_VERSION=6.1 
+      - MIDDLEWARE=YES
+      - SMTP_STARTTLS=DISABLED
+
+    - rvm: ruby-head
+      gemfile: test/rails_edge.gemfile
+      env: 
+      - RAILS_VERSION=edge 
+      - MIDDLEWARE=YES
+      - SMTP_STARTTLS=DISABLED
+
+
   include:
     # -------------------------------------
     # Standard
@@ -34,25 +67,40 @@ matrix:
     
     - rvm: 2.2.2
       gemfile: test/rails_5.0.gemfile
-      env: RAILS_VERSION=5.0 MIDDLEWARE=no
+      env: 
+      - RAILS_VERSION=5.0 
+      - MIDDLEWARE=no
+      - RUBYGEMS_VERSION=2.7.11
+      - BUNDLER_VERSION=1.17.3
 
     - rvm: 2.3.6
       gemfile: test/rails_5.0.gemfile
-      env: RAILS_VERSION=5.0 MIDDLEWARE=no
+      env:
+      - RAILS_VERSION=5.0
+      - MIDDLEWARE=no
 
     # rails 5.1 sometime before May 2017
     
     - rvm: 2.2.2
       gemfile: test/rails_5.1.gemfile
-      env: RAILS_VERSION=5.1 MIDDLEWARE=no
+      env:
+      - RAILS_VERSION=5.1
+      - MIDDLEWARE=no
+      - RUBYGEMS_VERSION=2.7.11
+      - BUNDLER_VERSION=1.17.3
 
     - rvm: 2.3.6
       gemfile: test/rails_5.1.gemfile
-      env: RAILS_VERSION=5.1 MIDDLEWARE=no
+      env:
+      - RAILS_VERSION=5.1
+      - MIDDLEWARE=no
+      - BUNDLER_VERSION=1.17.3
 
     - rvm: 2.4.3
       gemfile: test/rails_5.1.gemfile
-      env: RAILS_VERSION=5.1 MIDDLEWARE=no
+      env:
+      - RAILS_VERSION=5.1
+      - MIDDLEWARE=no
 
     # -------------------------------------
     # Middleware
@@ -61,19 +109,110 @@ matrix:
     
     - rvm: 2.2.2
       gemfile: test/rails_5.0.gemfile
-      env: RAILS_VERSION=5.0 MIDDLEWARE=yes
+      env:
+      - RAILS_VERSION=5.0
+      - MIDDLEWARE=yes
+      - RUBYGEMS_VERSION=2.7.11
+      - BUNDLER_VERSION=1.17.3
 
     - rvm: 2.3.6
       gemfile: test/rails_5.0.gemfile
-      env: RAILS_VERSION=5.0 MIDDLEWARE=yes
+      env:
+      - RAILS_VERSION=5.0
+      - MIDDLEWARE=yes
 
     # rails 5.1 sometime before May 2017
     
     - rvm: 2.2.2
       gemfile: test/rails_5.1.gemfile
-      env: RAILS_VERSION=5.1 MIDDLEWARE=yes
+      env:
+      - RAILS_VERSION=5.1
+      - MIDDLEWARE=yes
+      - RUBYGEMS_VERSION=2.7.11
+      - BUNDLER_VERSION=1.17.3
 
     - rvm: 2.4.3
       gemfile: test/rails_5.1.gemfile
-      env: RAILS_VERSION=5.1 MIDDLEWARE=yes
+      env:
+      - RAILS_VERSION=5.1
+      - MIDDLEWARE=yes
+
+
+    # rails 5.2 April 2018
+    # -------------------------------------
+    # INSTALLED AS MIDDLEWARE
+    
+
+    # rails 6.0
+
+    - rvm: 2.5.0
+      gemfile: test/rails_6.0.gemfile
+      env:
+      - RAILS_VERSION=6.0
+      - MIDDLEWARE=YES
+
+    - rvm: 2.6.7
+      gemfile: test/rails_6.0.gemfile
+      env:
+      - RAILS_VERSION=6.0
+      - MIDDLEWARE=YES
+    
+    # Not testing past recommended ruby version as listed on https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html
+
+    # --------------------------------------
+    - rvm: 2.5.0
+      gemfile: test/rails_6.1.gemfile
+      env:
+      - RAILS_VERSION=6.1
+      - MIDDLEWARE=YES
+
+    - rvm: 2.6.6
+      gemfile: test/rails_6.1.gemfile
+      env:
+      - RAILS_VERSION=6.1
+      - MIDDLEWARE=YES
+
+    - rvm: 2.7.3
+      gemfile: test/rails_6.1.gemfile
+      env:
+      - RAILS_VERSION=6.1
+      - MIDDLEWARE=YES
+
+    - rvm: 3.0.1
+      gemfile: test/rails_6.1.gemfile
+      env:
+      - RAILS_VERSION=6.1
+      - MIDDLEWARE=YES
+      - SMTP_STARTTLS=DISABLED
+    
+   # ------------------
+   # FIXME
+   # ------------------
+
+    - rvm: 3.0.1
+      gemfile: test/rails_6.1.gemfile
+      env:
+      - RAILS_VERSION=6.1
+      - MIDDLEWARE=YES
+
+    - rvm: 3.0.1
+      gemfile: test/rails_edge.gemfile
+      env: 
+      - RAILS_VERSION=edge 
+      - MIDDLEWARE=YES
+      - SMTP_STARTTLS=DISABLED
+
+    - rvm: ruby-head
+      gemfile: test/rails_6.1.gemfile
+      env: 
+      - RAILS_VERSION=6.1 
+      - MIDDLEWARE=YES
+      - SMTP_STARTTLS=DISABLED
+
+    - rvm: ruby-head
+      gemfile: test/rails_edge.gemfile
+      env: 
+      - RAILS_VERSION=edge 
+      - MIDDLEWARE=YES
+      - SMTP_STARTTLS=DISABLED
 
diff --git a/CHANGELOG b/CHANGELOG
index b95355a..e17c17b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,26 @@
 = Change Log =
 
+* 3.1.0 - 26 May 2021
+  * Updated README to clarify railsN branch status (they are intended to be stable, development to be a feature branch off them or master)
+  * Updated README with all the settings
+  * Updated all the branches to work with the latest travis and gem changes, as some gems needed to be locked down.
+  * Updated to test rails 6.0 and 6.1
+  * Got all travis tests passing
+  * Removed old, unused branches
+  * Merged PR Fix broken Cache-Control headers #93 from felixbuenemann 
+  * Merged PR S3 should not depend on Rails secrets file #77 by natefaerber
+  * Merged PR RabbitMQ Health check #98 from rhuanbarreto
+  * Merged PR Use remote_ip to accept proxy-forwarded requests #102 by alessio-signorini but made it optional
+  * Fixed up failure setting to match previous output on error, and use it as a prefix when the error message is also output (not by default)
+  * Always log the error to rails log even if not including in html response
+  * Merged PR ensure REDIS connections are closed #88 from yld
+  * Merged PR more robust cache check #90 from masciugo
+  * Merged PR Add log_level config setting which defaults to 'info'. #97 from FloHeinle 
+  * Merged PR get rid of old school hash rockets syntax #92 from DmytroStepaniuk
+  * Merged PR Converted whitelist testing to use IPAddr objects. #64 jordanyaker
+  * Added on_success and on_failure callbacks
+  * Makes sure errors are seperated by a period and a space and a period always ends the list of errors
+
 * 3.0.0
  * First release on rails5 branch
  * Depends on railties rather than rails so it can be used with trimmed down stacks
diff --git a/README.rdoc b/README.rdoc
index a37458a..1d82787 100644
--- a/README.rdoc
+++ b/README.rdoc
@@ -1,11 +1,19 @@
 = health_check gem
 
-Simple health check of Rails 5.x apps for use with Pingdom, NewRelic, EngineYard or uptime.openacs.org etc.
+Simple health check of Rails 5.x and 6.x apps for use with Pingdom, NewRelic, EngineYard etc.
 
 The basic goal is to quickly check that rails is up and running and that it has access to correctly configured resources (database, email gateway)
 
 Check the latest README {master}[https://github.com/ianheggie/health_check/tree/master] for other versions
 
+Use gem versions for stable releases:
+* ~> 3.x for Rails 5.x and 6.x (etc until there is a proven need to split off another branch),
+* ~> 2.x for Rails 4.x,
+* ~> 1.7 for Rails 3.x,
+* ~> 1.6.3 for Rails 2.3
+
+Note: it is best to pin to a specific commit if using a development branch as sometimes tests break.
+
 health_check provides various monitoring URIs, for example:
 
     curl localhost:3000/health_check
@@ -24,6 +32,7 @@ health_check provides various monitoring URIs, for example:
 You may also issue POST calls instead of GET to these urls.
 
 On failure (detected by health_check) a 500 http status is returned with a simple explanation of the failure
+(if include_error_in_response_body is true)
 
     curl localhost:3000/health_check/fail
     health_check failed: invalid argument to health_test.
@@ -39,10 +48,12 @@ The health_check controller disables sessions for versions that eagerly load ses
 * database - checks that the current migration level can be read from the database
 * email - basic check of email - :test returns true, :sendmail checks file is present and executable, :smtp sends HELO command to server and checks response
 * migration - checks that the database migration level matches that in db/migrations
+* rabbitmq - RabbitMQ Health Check
 * redis / redis-if-present - checks Redis connectivity
 * resque-redis / resque-redis-if-present - checks Resque connectivity to Redis
 * s3 / s3-if-present - checks proper permissions to s3 buckets
 * sidekiq-redis / sidekiq-redis-if-present - checks Sidekiq connectivity to Redis
+* elasticsearch / elasticsearch-if-present - checks Elasticsearch connectivity
 * site - checks rails is running sufficiently to render text
 
 Some checks have a *-if-present form, which only runs the check if the corresponding library has been required.
@@ -55,9 +66,9 @@ Note: rails also checks migrations by default in development mode and throws an
 
 == Installation
 
-Add the following line to Gemfile
+Add the following line to Gemfile (after the rails gems are listed)
 
-    gem "health_check"
+    gem 'health_check'
 
 And then execute
 
@@ -79,6 +90,16 @@ To change the configuration of health_check, create a file `config/initializers/
       # Text output upon success
       config.success = 'success'
 
+      # Text output upon failure
+      config.failure = 'health_check failed'
+
+      # Disable the error message to prevent /health_check from leaking
+      # sensitive information
+      config.include_error_in_response_body = false
+
+      # Log level (success or failure message with error details is sent to rails log unless this is set to nil)
+      config.log_level = 'info'
+
       # Timeout in seconds used when checking smtp server
       config.smtp_timeout = 30.0
 
@@ -89,7 +110,7 @@ To change the configuration of health_check, create a file `config/initializers/
       config.http_status_for_error_text = 500
 
       # http status code used when an error object is output (json or xml)
-      # Set to 200 if you want your want to distinguish between partial (healthy property == false) and
+      # Set to 200 if you want to distinguish between partial (healthy property == false) and
       # total failure of rails application (http status of 500 etc)
 
       config.http_status_for_error_object = 500
@@ -129,15 +150,37 @@ To change the configuration of health_check, create a file `config/initializers/
       config.basic_auth_username = 'my_username'
       config.basic_auth_password = 'my_password'
 
-      # Whitelist requesting IPs
-      # Defaults to blank and allows any IP
-      config.origin_ip_whitelist = %w(123.123.123.123)
+      # Whitelist requesting IPs by a list of IP and/or CIDR ranges, either IPv4 or IPv6 (uses IPAddr.include? method to check)
+      # Defaults to blank which allows any IP
+      config.origin_ip_whitelist = %w(123.123.123.123 10.11.12.0/24 2400:cb00::/32)
+
+      # Use ActionDispatch::Request's remote_ip method when behind a proxy to pick up the real remote IP for origin_ip_whitelist check
+      # Otherwise uses Rack::Request's ip method (the default, and always used by Middleware), which is more susceptable to spoofing
+      # See https://stackoverflow.com/questions/10997005/whats-the-difference-between-request-remote-ip-and-request-ip-in-rails
+      config.accept_proxied_requests = false
 
       # http status code used when the ip is not allowed for the request
       config.http_status_for_ip_whitelist_error = 403
 
-      # When redis url is non-standard
-      config.redis_url = 'redis_url'
+      # rabbitmq
+      config.rabbitmq_config = {}
+
+      # When redis url/password is non-standard
+      config.redis_url = 'redis_url' # default ENV['REDIS_URL']
+      # Only included if set, as url can optionally include passwords as well
+      config.redis_password = 'redis_password' # default ENV['REDIS_PASSWORD']
+
+      # Failure Hooks to do something more ...
+      # checks lists the checks requested
+      config.on_failure do |checks, msg|
+        # log msg somewhere
+      end
+    
+      config.on_success do |checks|
+        # flag that everything is well
+      end
+  
+
     end
 
 You may call add_custom_check multiple times with different tests. These tests will be included in the default list ("standard").
@@ -151,7 +194,7 @@ Install health_check as middleware if you want to sometimes ignore exceptions fr
 eg DB connection errors from QueryCache. The "middleware" check will fail if you have not installed health_check as middleware.
 
 To install health_check as middleware add the following line to the config/application.rb:
-    config.middleware.insert_after "Rails::Rack::Logger", HealthCheck::MiddlewareHealthcheck
+    config.middleware.insert_after Rails::Rack::Logger, HealthCheck::MiddlewareHealthcheck
 
 Note: health_check is installed as a full rails engine even if it has been installed as middleware. This is so the
 remaining checks continue to run through the complete rails stack.
@@ -174,7 +217,6 @@ See
 
 * Pingdom Website Monitoring - https://www.pingdom.com
 * NewRelic Availability Monitoring - http://newrelic.com/docs/features/availability-monitoring-faq
-* Uptime by OpenACS - http://uptime.openacs.org/uptime/
 * Engine Yard's guide - https://support.cloud.engineyard.com/entries/20996821-monitor-application-uptime (although the guide is based on fitter_happier plugin it will also work with this gem)
 * Nagios check_http (with -s success) - https://www.nagios-plugins.org/doc/man/check_http.html
 * Any other montoring service that can be set to check for the word success in the text returned from a url
@@ -236,24 +278,31 @@ Last-modified is set to the current time (rounded down to a multiple of max_age
 
 == Known Issues
 
+* See https://github.com/ianheggie/health_check/issues
 * No inline documentation for methods
 * <b>rvm gemsets breaks the test</b> - specifically <tt>rvm use 1.9.3</tt> works but <tt>rvm gemset use ruby-1.9.3-p385@health_check --create</tt> triggers a "Could not find gem 'coffee-rails (~> 3.2.1) ruby' in the gems available on this machine." error in the last call to bundle (installing health_check as a gem via a path into the temp railsapp)
 
 == Similar projects
 
 * fitter_happier plugin by atmos - plugin with similar goals, but not compatible with uptime, and does not check email gateway
+* HealthBit - inspired by this gem but with a fresh start as a simpler rack only application, no travis CI tests (yet?) but looks interesting.
 
 == Testing
 
 === Automated testing and other checks
 
-* {<img src="https://travis-ci.org/ianheggie/health_check.svg?branch=rails5">}[https://travis-ci.org/ianheggie/health_check.svg?branch=rails5]  - Travis CI 
+* {<img src="https://badge.fury.io/rb/health_check.svg" alt="Gem Version" />}[http://badge.fury.io/rb/health_check] - Latest Gem
+* {<img src="https://travis-ci.org/ianheggie/health_check.svg">}[https://travis-ci.org/ianheggie/health_check]  - Travis CI
+* {<img src="https://codeclimate.com/github/ianheggie/health_check.svg" />}[https://codeclimate.com/github/ianheggie/health_check] - Code quality
+* {<img src="https://gemnasium.com/ianheggie/health_check.svg">}[https://gemnasium.com/ianheggie/health_check] - Gem dependencies
 
 === Manual testing
 
-The instructions have been changed to using a vagrant virtual box for consistant results.
+The instructions have been changed to using a vagrant virtual box for consistent results.
+
+Install vagrant 1.9.7 or later and virtual_box or other local virtual machine provider.  Add the vagrant plugin called vbguest.
 
-Install vagrant 1.9.7 or later and virtual_box or other local virtual machine providor.
+    vagrant plugin install vagrant-vbguest
 
 Create a temp directory for throw away testing, and clone the health_check gem into it
 
@@ -281,11 +330,11 @@ Cd to the checked out health_check directory and then run the test as follows:
 
     cd /vagrant  # the current directory on your host is mounted here on the virtual machine
 
-    chruby 2.2.2 # or some other ruby version 
+    chruby 2.2.2 # or some other ruby version (run chruby with no arguments to see the current list)
 
     test/test_with_railsapp
 
-    exit        # from viretual machine when finished
+    exit        # from virtual machine when finished
 
 The script will first call `test/setup_railsapp` to setup a rails app with health_check installed and then
 run up the rails server and perform veraious tests.
@@ -297,7 +346,7 @@ The command `rake test` will also launch these tests, except it cannot install t
 
 == Copyright
 
-Copyright (c) 2010-2017 Ian Heggie, released under the MIT license.
+Copyright (c) 2010-2021 Ian Heggie, released under the MIT license.
 See MIT-LICENSE for details.
 
 == Contributors
@@ -306,10 +355,18 @@ Thanks go to the various people who have given feedback and suggestions via the
 
 === Contributing
 
+Use gem versions for stable releases, or github branch / commits for development versions:
+* for Rails 5.x and 6.x use feature branched off master {master}[https://github.com/ianheggie/health_check/tree/master] for development;
+* for Rails 4.x use feature branches off the {rails4}[https://github.com/ianheggie/health_check/tree/rails4] stable branch for development;
+* for Rails 3.x use feature branches off the {rails3}[https://github.com/ianheggie/health_check/tree/rails3] stable branch for development;
+* for Rails 2.3 use feature branches off the {rails2.3}[https://github.com/ianheggie/health_check/tree/rails2.3] stable branch for development;
+
 1. Fork it
 2. Create your feature branch (`git checkout -b my-new-feature`)
-3. Commit your changes (`git commit -am 'Add some feature'`)
-4. Push to the branch (`git push origin my-new-feature`)
-5. Create new Pull Request (Code with BDD tests are favoured)
+3. Create a test that confirms your changes work
+4. Update README.rdoc to explain enhancements, or add succinct comment in code when fixing bugs
+5. Commit your changes (`git commit -am 'Add some feature'`)
+6. Push to the branch (`git push origin my-new-feature`)
+7. Create new Pull Request (Code with BDD tests and documentation are highly favoured)
 
-<em>Feedback welcome! Especially with suggested replacement code and corresponding tests</em>
+<em>Feedback welcome! Especially with suggested replacement code, tests and documentation</em>
diff --git a/Rakefile b/Rakefile
index f5d6178..ee0f3c1 100644
--- a/Rakefile
+++ b/Rakefile
@@ -8,7 +8,7 @@ task :test do
   exec '/bin/bash', './test/test_with_railsapp'
 end
 
-task :default => :test
+task default: :test
 
 begin
   gem 'rdoc'
diff --git a/Vagrantfile b/Vagrantfile
index 9ed5b72..85cd839 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -5,7 +5,7 @@ Vagrant.configure("2") do |config|
   # For a complete reference, please see the online documentation at
   # https://docs.vagrantup.com.
 
-  config.vm.box = "ubuntu/xenial64"
+  config.vm.box = "ubuntu/focal64"
 
   # set auto_update to false, if you do NOT want to check the correct 
   # additions version when booting this machine
@@ -17,4 +17,16 @@ Vagrant.configure("2") do |config|
   # provision with a shell script.
   config.vm.provision "shell", path: "./test/provision_vagrant"
 
+  config.vm.provider "virtualbox" do |v|
+    # travis allocates 7.5 GB, but this is sufficient
+    v.memory = 2048
+    v.cpus = 2
+  end
+
+#  if File.file?('.git') && IO.read('.git') =~ %r{\Agitdir: (.+)/.git/worktrees.*}
+#    # Handle git worktrees ...
+#    path = $1
+#    config.vm.synced_folder path, path
+#  end
+
 end
diff --git a/config/routes.rb b/config/routes.rb
index 22fbafe..c56a98f 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,5 +1,5 @@
 unless HealthCheck::Engine.routes_explicitly_defined
-  Rails.application.routes.draw do
+  ::Rails.application.routes.draw do
     add_health_check_routes()
   end
 end
diff --git a/debian/changelog b/debian/changelog
index cc6665c..e0b0d4b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+ruby-health-check (3.1.0-1) UNRELEASED; urgency=low
+
+  * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Mon, 14 Mar 2022 13:45:46 -0000
+
 ruby-health-check (3.0.0-1) unstable; urgency=medium
 
   * Team Upload
diff --git a/health_check.gemspec b/health_check.gemspec
index 9ce8d28..b2d9766 100644
--- a/health_check.gemspec
+++ b/health_check.gemspec
@@ -9,14 +9,14 @@ Gem::Specification.new do |gem|
   gem.required_rubygems_version = Gem::Requirement.new(">= 0") if gem.respond_to? :required_rubygems_version=
   gem.authors       = ["Ian Heggie"]
   gem.email         = ["ian@heggie.biz"]
-  gem.summary = %q{Simple health check of Rails app for uptime monitoring with Pingdom, NewRelic, EngineYard or uptime.openacs.org etc.}
+  gem.summary = %q{Simple health check of Rails app for uptime monitoring with Pingdom, NewRelic, EngineYard etc.}
   gem.description = <<-EOF
-  	Simple health check of Rails app for uptime monitoring with Pingdom, NewRelic, EngineYard or uptime.openacs.org etc.
+  	Simple health check of Rails app for uptime monitoring with Pingdom, NewRelic, EngineYard etc.
   EOF
   gem.homepage      = "https://github.com/ianheggie/health_check"
+  gem.license       = "MIT"
 
   gem.files         = `git ls-files`.split($/)
-  gem.executables   = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
   gem.test_files    = gem.files.grep(%r{^(test|spec|features)/})
   gem.extra_rdoc_files = [ "README.rdoc" ]
   gem.require_paths = ["lib"]
@@ -25,5 +25,5 @@ Gem::Specification.new do |gem|
   gem.add_development_dependency(%q<smarter_bundler>, [">= 0.1.0"])
   gem.add_development_dependency(%q<rake>, [">= 0.8.3"])
   gem.add_development_dependency(%q<shoulda>, ["~> 2.11.0"])
-  gem.add_development_dependency(%q<bundler>, ["~> 1.2"])
+  gem.add_development_dependency(%q<bundler>, [">= 1.2"])
 end
diff --git a/lib/health_check.rb b/lib/health_check.rb
index 07fa1e3..669a74e 100644
--- a/lib/health_check.rb
+++ b/lib/health_check.rb
@@ -3,14 +3,22 @@
 
 module HealthCheck
 
-  class Engine < Rails::Engine
-    cattr_accessor :routes_explicitly_defined 
+  class Engine < ::Rails::Engine
+    cattr_accessor :routes_explicitly_defined
   end
 
+  # Log level
+  mattr_accessor :log_level
+  self.log_level = 'info'
+
   # Text output upon success
   mattr_accessor :success
   self.success = "success"
 
+  # Text output upon failure
+  mattr_accessor :failure
+  self.failure = "health_check failed"
+
   # Timeout in seconds used when checking smtp server
   mattr_accessor :smtp_timeout
   self.smtp_timeout = 30.0
@@ -27,6 +35,10 @@ module HealthCheck
   mattr_accessor :http_status_for_ip_whitelist_error
   self.http_status_for_ip_whitelist_error = 403
 
+  # check remote_ip rather than ip for ip whitelist
+  mattr_accessor :accept_proxied_requests
+  self.accept_proxied_requests = false
+
   # ips allowed to perform requests
   mattr_accessor :origin_ip_whitelist
   self.origin_ip_whitelist = []
@@ -40,6 +52,10 @@ module HealthCheck
   mattr_accessor :buckets
   self.buckets = {}
 
+  # rabbitmq
+  mattr_accessor :rabbitmq_config
+  self.rabbitmq_config = {}
+
   # health check uri path
   mattr_accessor :uri
   self.uri = 'health_check'
@@ -54,7 +70,7 @@ module HealthCheck
   mattr_accessor :full_checks
   mattr_accessor :standard_checks
   self.custom_checks = { }
-  self.full_checks = ['database', 'migrations', 'custom', 'email', 'cache', 'redis-if-present', 'sidekiq-redis-if-present', 'resque-redis-if-present', 's3-if-present']
+  self.full_checks = ['database', 'migrations', 'custom', 'email', 'cache', 'redis-if-present', 'sidekiq-redis-if-present', 'resque-redis-if-present', 's3-if-present', 'elasticsearch-if-present']
   self.standard_checks = [ 'database', 'migrations', 'custom', 'emailconf' ]
 
   # Middleware based checks
@@ -63,15 +79,37 @@ module HealthCheck
 
   mattr_accessor :installed_as_middleware
 
-  # Allow non-standard redis url
+  # Allow non-standard redis url and password
   mattr_accessor :redis_url
-  self.redis_url = nil
+  self.redis_url = ENV['REDIS_URL']
+
+  mattr_accessor :redis_password
+  self.redis_password = 'some-password'
+
+  # Include the error in the response body. 
+  # You should only do this where your /health_check endpoint is NOT open to the public internet
+  mattr_accessor :include_error_in_response_body
+  self.include_error_in_response_body = false
+
+  # used for on_failure and on_success
+  mattr_accessor :success_callbacks
+  mattr_accessor :failure_callbacks
 
   def self.add_custom_check(name = 'custom', &block)
     custom_checks[name] ||= [ ]
     custom_checks[name] << block
   end
 
+  def self.on_success(&block)
+    success_callbacks ||= [ ]
+    success_callbacks << block
+  end
+
+  def self.on_failure(&block)
+    failure_callbacks ||= [ ]
+    failure_callbacks << block
+  end
+
   def self.setup
     yield self
   end
@@ -83,10 +121,12 @@ require 'health_check/base_health_check'
 require 'health_check/resque_health_check'
 require 'health_check/s3_health_check'
 require 'health_check/redis_health_check'
+require 'health_check/elasticsearch_health_check'
 require 'health_check/sidekiq_health_check'
 require 'health_check/utils'
 require 'health_check/health_check_controller'
 require 'health_check/health_check_routes'
 require 'health_check/middleware_health_check'
+require 'health_check/rabbitmq_health_check'
 
 # vi: sw=2 sm ai:
diff --git a/lib/health_check/elasticsearch_health_check.rb b/lib/health_check/elasticsearch_health_check.rb
new file mode 100644
index 0000000..3519f99
--- /dev/null
+++ b/lib/health_check/elasticsearch_health_check.rb
@@ -0,0 +1,15 @@
+module HealthCheck
+  class ElasticsearchHealthCheck
+    extend BaseHealthCheck
+
+    def self.check
+      unless defined?(::Elasticsearch)
+        raise "Wrong configuration. Missing 'elasticsearch' gem"
+      end
+      res = ::Elasticsearch::Client.new.ping
+      res == true ? '' : "Elasticsearch returned #{res.inspect} instead of true"
+    rescue Exception => e
+      create_error 'elasticsearch', e.message
+    end
+  end
+end
diff --git a/lib/health_check/health_check_controller.rb b/lib/health_check/health_check_controller.rb
index 632da77..e4bf6a5 100644
--- a/lib/health_check/health_check_controller.rb
+++ b/lib/health_check/health_check_controller.rb
@@ -1,5 +1,6 @@
-# Copyright (c) 2010-2013 Ian Heggie, released under the MIT license.
+# Copyright (c) 2010-2021 Ian Heggie, released under the MIT license.
 # See MIT-LICENSE for details.
+require "ipaddr"
 
 module HealthCheck
   class HealthCheckController < ActionController::Base
@@ -14,8 +15,8 @@ module HealthCheck
       if max_age > 1
         last_modified = Time.at((last_modified.to_f / max_age).floor * max_age).utc
       end
-      public = (max_age > 1) && ! HealthCheck.basic_auth_username
-      if stale?(:last_modified => last_modified, :public => public)
+      is_public = (max_age > 1) && ! HealthCheck.basic_auth_username
+      if stale?(last_modified: last_modified, public: is_public)
         checks = params[:checks] ? params[:checks].split('_') : ['standard']
         checks -= HealthCheck.middleware_checks if HealthCheck.installed_as_middleware
         begin
@@ -23,15 +24,25 @@ module HealthCheck
         rescue Exception => e
           errors = e.message.blank? ? e.class.to_s : e.message.to_s
         end
-        response.headers['Cache-control'] = (public ? 'public' : 'private') + ', no-cache, must-revalidate' + (max_age > 0 ? ", max-age=#{max_age}" : '')
+        response.headers['Cache-Control'] = "must-revalidate, max-age=#{max_age}"
         if errors.blank?
-          send_response nil, :ok, :ok
+          send_response true, nil, :ok, :ok
+          if HealthCheck.success_callbacks
+            HealthCheck.success_callbacks.each do |callback|
+              callback.call(checks)
+            end 
+          end
         else
-          msg = "health_check failed: #{errors}"
-          send_response msg, HealthCheck.http_status_for_error_text, HealthCheck.http_status_for_error_object
+          msg = HealthCheck.include_error_in_response_body ? "#{HealthCheck.failure}: #{errors}" : nil
+          send_response false, msg, HealthCheck.http_status_for_error_text, HealthCheck.http_status_for_error_object
+          
           # Log a single line as some uptime checkers only record that it failed, not the text returned
-          if logger
-            logger.info msg
+          msg = "#{HealthCheck.failure}: #{errors}"
+          logger.send(HealthCheck.log_level, msg) if logger && HealthCheck.log_level
+          if HealthCheck.failure_callbacks
+            HealthCheck.failure_callbacks.each do |callback|
+              callback.call(checks, msg)
+            end
           end
         end
       end
@@ -39,15 +50,14 @@ module HealthCheck
 
     protected
 
-    def send_response(msg, text_status, obj_status)
-      healthy = !msg
-      msg ||= HealthCheck.success
-      obj = { :healthy => healthy, :message => msg}
+    def send_response(healthy, msg, text_status, obj_status)
+      msg ||= healthy ? HealthCheck.success : HealthCheck.failure
+      obj = { healthy: healthy, message: msg}
       respond_to do |format|
-        format.html { render :plain => msg, :status => text_status, :content_type => 'text/plain' }
-        format.json { render :json => obj, :status => obj_status }
-        format.xml { render :xml => obj, :status => obj_status }
-        format.any { render :plain => msg, :status => text_status, :content_type => 'text/plain' }
+        format.html { render plain: msg, status: text_status, content_type: 'text/plain' }
+        format.json { render json: obj, status: obj_status }
+        format.xml { render xml: obj, status: obj_status }
+        format.any { render plain: msg, status: text_status, content_type: 'text/plain' }
       end
     end
 
@@ -59,11 +69,12 @@ module HealthCheck
     end
 
     def check_origin_ip
+      request_ipaddr = IPAddr.new(HealthCheck.accept_proxied_requests ? request.remote_ip : request.ip)
       unless HealthCheck.origin_ip_whitelist.blank? ||
-          HealthCheck.origin_ip_whitelist.include?(request.ip)
-        render :plain => 'Health check is not allowed for the requesting IP',
-               :status => HealthCheck.http_status_for_ip_whitelist_error,
-               :content_type => 'text/plain'
+          HealthCheck.origin_ip_whitelist.any? { |addr| IPAddr.new(addr).include? request_ipaddr }
+        render plain: 'Health check is not allowed for the requesting IP',
+               status: HealthCheck.http_status_for_ip_whitelist_error,
+               content_type: 'text/plain'
       end
     end
 
diff --git a/lib/health_check/health_check_routes.rb b/lib/health_check/health_check_routes.rb
index 3585308..ad977d4 100644
--- a/lib/health_check/health_check_routes.rb
+++ b/lib/health_check/health_check_routes.rb
@@ -8,7 +8,7 @@ module ActionDispatch::Routing
 
     def add_health_check_routes(prefix = nil)
       HealthCheck.uri = prefix if prefix
-      match "#{HealthCheck.uri}(/:checks)(.:format)", :to => 'health_check/health_check#index', via: [:get, :post], :defaults => { :format => 'txt' }
+      match "#{HealthCheck.uri}(/:checks)(.:format)", controller: 'health_check/health_check', action: :index, via: [:get, :post], defaults: { format: 'txt' }
     end
 
   end
diff --git a/lib/health_check/middleware_health_check.rb b/lib/health_check/middleware_health_check.rb
index 7ef00df..68cad6c 100644
--- a/lib/health_check/middleware_health_check.rb
+++ b/lib/health_check/middleware_health_check.rb
@@ -1,3 +1,7 @@
+# Copyright (c) 2010-2021 Ian Heggie, released under the MIT license.
+# See MIT-LICENSE for details.
+require 'ipaddr'
+
 module HealthCheck
   class MiddlewareHealthcheck
 
@@ -59,7 +63,8 @@ module HealthCheck
     def ip_blocked(env)
       return false if HealthCheck.origin_ip_whitelist.blank?
       req = Rack::Request.new(env)
-      unless HealthCheck.origin_ip_whitelist.include?(req.ip)
+      request_ipaddr = IPAddr.new(req.ip)
+      unless HealthCheck.origin_ip_whitelist.any? { |addr| IPAddr.new(addr).include? request_ipaddr }
         [ HealthCheck.http_status_for_ip_whitelist_error,
           { 'Content-Type' => 'text/plain' },
           [ 'Health check is not allowed for the requesting IP' ]
diff --git a/lib/health_check/rabbitmq_health_check.rb b/lib/health_check/rabbitmq_health_check.rb
new file mode 100644
index 0000000..6d08f89
--- /dev/null
+++ b/lib/health_check/rabbitmq_health_check.rb
@@ -0,0 +1,16 @@
+module HealthCheck
+  class RabbitMQHealthCheck
+    extend BaseHealthCheck
+    def self.check
+      unless defined?(::Bunny)
+        raise "Wrong configuration. Missing 'bunny' gem"
+      end
+      connection = Bunny.new(HealthCheck.rabbitmq_config)
+      connection.start
+      connection.close
+      ''
+    rescue Exception => e
+      create_error 'rabbitmq', e.message
+    end
+  end
+end
diff --git a/lib/health_check/redis_health_check.rb b/lib/health_check/redis_health_check.rb
index 39373e7..7d85c05 100644
--- a/lib/health_check/redis_health_check.rb
+++ b/lib/health_check/redis_health_check.rb
@@ -1,15 +1,28 @@
+# frozen_string_literal: true
+
 module HealthCheck
   class RedisHealthCheck
     extend BaseHealthCheck
 
-    def self.check
-      unless defined?(::Redis)
-        raise "Wrong configuration. Missing 'redis' gem"
+    class << self
+      def check
+        raise "Wrong configuration. Missing 'redis' gem" unless defined?(::Redis)
+
+        client.ping == 'PONG' ? '' : "Redis.ping returned #{res.inspect} instead of PONG"
+      rescue Exception => err
+        create_error 'redis', err.message
+      ensure
+        client.close if client.connected?
+      end
+
+      def client
+        @client ||= Redis.new(
+          {
+            url: HealthCheck.redis_url,
+            password: HealthCheck.redis_password
+          }.reject { |k, v| v.nil? }
+        )
       end
-      res = ::Redis.new(url: HealthCheck.redis_url).ping
-      res == 'PONG' ? '' : "Redis.ping returned #{res.inspect} instead of PONG"
-    rescue Exception => e
-      create_error 'redis', e.message
     end
   end
 end
diff --git a/lib/health_check/s3_health_check.rb b/lib/health_check/s3_health_check.rb
index 5290d0f..2da5fac 100644
--- a/lib/health_check/s3_health_check.rb
+++ b/lib/health_check/s3_health_check.rb
@@ -5,7 +5,7 @@ module HealthCheck
     class << self
       def check
         unless defined?(::Aws)
-          raise "Wrong configuration. Missing 'aws-sdk' gem"
+          raise "Wrong configuration. Missing 'aws-sdk' or 'aws-sdk-s3' gem"
         end
         return create_error 's3', 'Could not connect to aws' if aws_s3_client.nil?
         HealthCheck.buckets.each do |bucket_name, permissions|
@@ -27,19 +27,14 @@ module HealthCheck
 
       private
 
+      # We already assume you are using Rails.  Let's also assume you have an initializer
+      # created for your Aws config.  We will set the region here so you can use an
+      # instance profile and simply set the region in your environment.
       def configure_client
-        return unless defined?(Rails)
+        ::Aws.config[:s3] = { force_path_style: true }
+        ::Aws.config[:region] ||= ENV['AWS_REGION'] || ENV['DEFAULT_AWS_REGION']
 
-        aws_configuration = {
-          region: Rails.application.secrets.aws_default_region,
-          credentials: ::Aws::Credentials.new(
-            Rails.application.secrets.aws_access_key_id,
-            Rails.application.secrets.aws_secret_access_key
-          ),
-          force_path_style: true
-        }
-
-        ::Aws::S3::Client.new aws_configuration
+        ::Aws::S3::Client.new
       end
 
       def aws_s3_client
@@ -52,13 +47,13 @@ module HealthCheck
 
       def W(bucket)
         aws_s3_client.put_object(bucket: bucket,
-                                 key: "healthcheck_#{Rails.application.class.parent_name}",
+                                 key: "healthcheck_#{::Rails.application.class.parent_name}",
                                  body: Time.new.to_s)
       end
 
       def D(bucket)
         aws_s3_client.delete_object(bucket: bucket,
-                                    key: "healthcheck_#{Rails.application.class.parent_name}")
+                                    key: "healthcheck_#{::Rails.application.class.parent_name}")
       end
     end
   end
diff --git a/lib/health_check/utils.rb b/lib/health_check/utils.rb
index e5feb52..64a8d89 100644
--- a/lib/health_check/utils.rb
+++ b/lib/health_check/utils.rb
@@ -6,13 +6,13 @@ module HealthCheck
 
     @@default_smtp_settings =
         {
-            :address              => "localhost",
-            :port                 => 25,
-            :domain               => 'localhost.localdomain',
-            :user_name            => nil,
-            :password             => nil,
-            :authentication       => nil,
-            :enable_starttls_auto => true,
+            address:               "localhost",
+            port:                  25,
+            domain:                'localhost.localdomain',
+            user_name:             nil,
+            password:              nil,
+            authentication:        nil,
+            enable_starttls_auto:  true
         }
 
     cattr_accessor :default_smtp_settings
@@ -55,6 +55,8 @@ module HealthCheck
             errors << HealthCheck::RedisHealthCheck.check if defined?(::Redis)
           when 's3-if-present'
             errors << HealthCheck::S3HealthCheck.check if defined?(::Aws)
+          when 'elasticsearch-if-present'
+            errors << HealthCheck::ElasticsearchHealthCheck.check if defined?(::Elasticsearch)
           when 'resque-redis'
             errors << HealthCheck::ResqueHealthCheck.check
           when 'sidekiq-redis'
@@ -63,6 +65,10 @@ module HealthCheck
             errors << HealthCheck::RedisHealthCheck.check
           when 's3'
             errors << HealthCheck::S3HealthCheck.check
+          when 'elasticsearch'
+            errors << HealthCheck::ElasticsearchHealthCheck.check
+          when 'rabbitmq'
+            errors << HealthCheck::RabbitMQHealthCheck.check
           when "standard"
             errors << HealthCheck::Utils.process_checks(HealthCheck.standard_checks, called_from_middleware)
           when "middleware"
@@ -84,15 +90,16 @@ module HealthCheck
               return "invalid argument to health_test."
             end
         end
+        errors << '. ' unless errors == '' || errors.end_with?('. ')
       end
-      return errors
+      return errors.strip
     rescue => e
       return e.message
     end
 
     def self.db_migrate_path
       # Lazy initialisation so Rails.root will be defined
-      @@db_migrate_path ||= File.join(Rails.root, 'db', 'migrate')
+      @@db_migrate_path ||= File.join(::Rails.root, 'db', 'migrate')
     end
 
     def self.db_migrate_path=(value)
@@ -135,36 +142,43 @@ module HealthCheck
       status = ''
       begin
         if @skip_external_checks
-          status = '221'
+          status = '250'
         else
-          Timeout::timeout(timeout) do |timeout_length|
-            t = TCPSocket.new(settings[:address], settings[:port])
-            begin
-              status = t.gets
-              while status != nil && status !~ /^2/
-                status = t.gets
-              end
-              t.puts "HELO #{settings[:domain]}\r"
-              while status != nil && status !~ /^250/
-                status = t.gets
-              end
-              t.puts "QUIT\r"
-              status = t.gets
-            ensure
-              t.close
-            end
+          smtp = Net::SMTP.new(settings[:address], settings[:port])
+          smtp.enable_starttls if settings[:enable_starttls_auto]
+          smtp.open_timeout = timeout
+          smtp.read_timeout = timeout
+          smtp.start(settings[:domain], settings[:user_name], settings[:password], settings[:authentication]) do
+            status = smtp.helo(settings[:domain]).status
           end
         end
-      rescue Errno::EBADF => ex
-        status = "Unable to connect to service"
       rescue Exception => ex
         status = ex.to_s
       end
-      (status =~ /^221/) ? '' : "SMTP: #{status || 'unexpected EOF on socket'}. "
+      (status =~ /^250/) ? '' : "SMTP: #{status || 'unexpected error'}. "
     end
 
     def self.check_cache
-      Rails.cache.write('__health_check_cache_test__', 'ok', :expires_in => 1.second) ? '' : 'Unable to write to cache. '
+      t = Time.now.to_i
+      value = "ok #{t}"
+      ret = ::Rails.cache.read('__health_check_cache_test__')
+      if ret.to_s =~ /^ok (\d+)$/ 
+        diff = ($1.to_i - t).abs
+        return('Cache expiry is broken. ') if diff > 30
+      elsif ret
+        return 'Cache is returning garbage. '
+      end
+      if ::Rails.cache.write('__health_check_cache_test__', value, expires_in: 2.seconds)
+        ret = ::Rails.cache.read('__health_check_cache_test__')
+        if ret =~ /^ok (\d+)$/ 
+          diff = ($1.to_i - t).abs
+          (diff < 2 ? '' : 'Out of date cache or time is skewed. ')
+        else
+          'Unable to read from cache. '
+        end
+      else
+        'Unable to write to cache. '
+      end
     end
 
   end
diff --git a/lib/health_check/version.rb b/lib/health_check/version.rb
index 4eaf33a..fc16bd6 100644
--- a/lib/health_check/version.rb
+++ b/lib/health_check/version.rb
@@ -1,3 +1,3 @@
 module HealthCheck
-  VERSION = "3.0.0"
+  VERSION = "3.1.0"
 end
diff --git a/test/fake_smtp_server b/test/fake_smtp_server
index 7f1e645..0eb9014 100755
--- a/test/fake_smtp_server
+++ b/test/fake_smtp_server
@@ -1,38 +1,157 @@
 #!/usr/bin/env ruby
 
 require 'socket'
+require 'openssl'
 
-port = 3555
+class FakeSmtpServer
+  def initialize(port)
+    @port = port
+    @socket = TCPServer.new(@port)
+    @client = @orig_client = nil
+  end
 
+  def start
+    return unless @client.nil?
 
-server = TCPServer.new port
-puts "fake_smtp_server: Waiting for one connection to port #{port} ..."
+    puts "fake_smtp_server: Waiting for one connection to port #{@port} ..."
+    @client = @socket.accept
 
-def send(client, line)
-  client.puts line
-  puts "> #{line}"
-end
+    send '220 dummy-smtp.example.com SMTP'
+    cmd = receive
 
-def receive(client)
-  line = client.gets
-  puts "< #{line}"
-  line
-end
+    while cmd !~ /^QUIT\r/
+      if cmd =~ /^HELO(.*)\r/
+        if ENV['FAIL_SMTP'] == 'HELO'
+          send '550 Access Denied – Invalid HELO name'
+        else
+          send '250-Welcome to a dummy smtp server'
+          unless ENV['SMTP_STARTTLS'] == 'DISABLED'
+            send '250-STARTTLS'
+          end
+          send '250-AUTH PLAIN LOGIN'
+          send '250 Ok'
+        end
+      elsif cmd =~ /^AUTH(.*)\r/
+        if ENV['FAIL_SMTP'] == 'AUTH'
+          send '535 5.7.8 Authentication credentials invalid'
+        else
+          send '235 2.7.0 Authentication successful'
+        end
+      elsif cmd =~ /^STARTTLS\r/
+        if ENV['SMTP_STARTTLS'] == 'DISABLED'
+          send '502 STARTTLS is disabled!'
+        end
+        send '220 Ready to start TLS'
+        if ENV['FAIL_SMTP'] == 'STARTTLS'
+          cmd = receive
+          return close
+        end
+        @orig_client = @client
+        @client = tlsconnect(@client)
+      else
+        send '502 I am so dumb I only understand HELO, AUTH, STARTTLS and QUIT which always return a success status'
+      end
+
+      cmd = receive
+    end
+    send '221 Bye Bye'
+
+    close
+  end
+
+  private
+
+  def close
+    @client.close unless @client.nil?
+    @orig_client.close unless @orig_client.nil?
+  end
+
+  def send(line)
+    @client.puts line
+    puts "-> #{line}"
+  end
+
+  def receive
+    line = @client.gets
+    puts "<- #{line}"
+    line
+  end
+
+  def ssl_socket(client, context)
+    OpenSSL::SSL::SSLSocket.new(client, context)
+  end
+
+  def ssl_context
+    @_ssl_context ||= begin
+      key, cert = generate_certificate
+
+      context = OpenSSL::SSL::SSLContext.new
+      context.key = key
+      context.cert = cert
+      context.verify_mode = OpenSSL::SSL::VERIFY_NONE
+      context.min_version = nil
+      context
+    end
+  end
+
+  # Pass socket from TCPServer.new accept
+  def tlsconnect(client)
+    ssl_client = ssl_socket(client, ssl_context)
+    puts '=> TLS connection started'
+    ssl_client.accept
+    puts '=> TLS connection established'
+
+    ssl_client
+  end
 
-client = server.accept    # Wait for a client to connect
-send(client, "220 dummy-smtp.example.com SMTP")
-cmd = receive(client)
+  def generate_certificate
+    key = OpenSSL::PKey::RSA.new(2048)
+    name = OpenSSL::X509::Name.parse('CN=localhost')
 
-while cmd !~ /^QUIT\r/
-  if cmd =~ /^HELO(.*)\r/
-    send(client, "250 Welcome to a dummy smtp server")
-  else
-    send(client, "502 I am so dumb I only understand HELO and QUIT")
+    cert = OpenSSL::X509::Certificate.new
+    cert.version = 2
+    cert.serial = 0
+    cert.not_before = Time.now
+    cert.not_after = Time.now + 3600
+
+    cert.public_key = key.public_key
+    cert.subject = name
+
+    extension_factory = OpenSSL::X509::ExtensionFactory.new nil, cert
+
+    cert.add_extension extension_factory.create_extension('basicConstraints', 'CA:FALSE', true)
+    cert.add_extension extension_factory.create_extension('keyUsage', 'keyEncipherment,dataEncipherment,digitalSignature')
+    cert.add_extension extension_factory.create_extension('subjectKeyIdentifier', 'hash')
+
+    cert.issuer = name
+    cert.sign key, OpenSSL::Digest::SHA256.new
+
+    [key, cert]
   end
-  cmd = receive(client)
 end
-send(client, "221 Bye Bye")
 
-client.close
-puts "fake_smtp_server: Exiting now the conversation has finished."
+FakeSmtpServer.new(3555).start
+
+puts 'fake_smtp_server: Exiting now the conversation has finished.'
 exit 0
+
+# Tested with irb script:
+# require 'net/smtp'
+# 
+# status = ''
+# begin
+#   if @skip_external_checks
+#     status = '250'
+#   else
+#     smtp = Net::SMTP.new('localhost', 3555)
+#     smtp.enable_starttls 
+#     smtp.open_timeout = 10
+#     smtp.read_timeout = 10
+#     smtp.start('domain', 'user_name', 'password', :plain) do
+#       status = smtp.helo('domain').status
+#     end
+#   end
+# rescue Exception => ex
+#   status = ex.to_s
+# end
+# (status =~ /^250/) ? 'PASS' : "FAILED SMTP: #{status || 'unexpected error'}. "
diff --git a/test/init_variables b/test/init_variables
index b1ee35b..514f865 100644
--- a/test/init_variables
+++ b/test/init_variables
@@ -1,7 +1,25 @@
 #!/bin/bash
 
 # Any failure causes exit
-set -e
+set -eE -o functrace
+
+report_failure() {
+  local lineno=$2
+  local fn=$3
+  local exitstatus=$4
+  local msg=$5
+  local lineno_fns=${1% 0}
+  if [[ $lineno_fns != "0" ]] ; then
+    lineno="${lineno} ${lineno_fns}"
+  fi
+  if [[ $exitstatus == 0 ]] ; then
+    echo "${BASH_SOURCE[1]}: Finished!"
+  else
+    echo "${BASH_SOURCE[1]}:${fn}[${lineno}] Failed with status ${exitstatus}: $msg"
+  fi
+}
+
+trap 'report_failure "${BASH_LINENO[*]}" "$LINENO" "${FUNCNAME[*]:-script}" "$?" "$BASH_COMMAND"' ERR
 
 echo Setting RAILS_ENV=test RACK_ENV=test
 export RAILS_ENV=test RACK_ENV=test
diff --git a/test/migrate/twelve/012_create_users.rb b/test/migrate/twelve/012_create_users.rb
index dee82e4..c97e0d8 100644
--- a/test/migrate/twelve/012_create_users.rb
+++ b/test/migrate/twelve/012_create_users.rb
@@ -1,6 +1,6 @@
 class CreateUsers < ActiveRecord::Migration[5.0]
   def self.up
-    create_table "users", :force => true do |t|
+    create_table "users", force: true do |t|
       t.column :name, :string
     end
   end
diff --git a/test/provision_vagrant b/test/provision_vagrant
index cb18cde..5c9b484 100644
--- a/test/provision_vagrant
+++ b/test/provision_vagrant
@@ -7,22 +7,55 @@ case `id` in
         exec echo Must be run as root
         ;;
 esac
-set -xe
+
+chruby_version=0.3.9
+chruby=chruby-${chruby_version}
+set -x
+set -eE -o functrace
+
+report_failure() {
+  local lineno=$2
+  local fn=$3
+  local exitstatus=$4
+  local msg=$5
+  local lineno_fns=${1% 0}
+  if [[ $lineno_fns != "0" ]] ; then
+    lineno="${lineno} ${lineno_fns}"
+  fi
+  if [[ $exitstatus == 0 ]] ; then
+    echo "${BASH_SOURCE[1]}: Finished!"
+  else
+    echo "${BASH_SOURCE[1]}:${fn}[${lineno}] Failed with status ${exitstatus}: $msg"
+  fi
+}
+
+trap 'report_failure "${BASH_LINENO[*]}" "$LINENO" "${FUNCNAME[*]:-script}" "$?" "$BASH_COMMAND"' ERR
+
+
 id
 pwd
 export DEBIAN_FRONTEND=noninteractive
 find /tmp/got-apt-update -mtime -1 || ( apt-get update && touch /tmp/got-apt-update )
-apt install --yes --force-yes -q build-essential ruby ruby-dev sqlite3 libsqlite3-dev nodejs
-
+apt install --yes -q build-essential ruby ruby-dev sqlite3 libsqlite3-dev nodejs git git-core
+apt install --yes -q gcc autoconf bison libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm-dev
+apt install --yes -q libgdbm3
+# useful when debugging
+apt install --yes -q silversearcher-ag vim exuberant-ctags
+apt install --yes -q unattended-upgrades
+unattended-upgrade
+# The following is not required for testing, install if you are doing manual tests with extra gems
+# apt install --yes -q mysql-client mysql-server libmysqlclient-dev
+# apt install --yes -q libcurl4-openssl-dev libncurses5-dev libxml2-dev libxslt1-dev
 (
   echo Install chruby
-  [ -s chruby-0.3.9.tar.gz ] || wget -q -O chruby-0.3.9.tar.gz https://github.com/postmodern/chruby/archive/v0.3.9.tar.gz
-  [ chruby-0.3.9 ] || tar -xzf chruby-0.3.9.tar.gz
-  cd chruby-0.3.9/
+  [ -s ${chruby}.tar.gz ] || wget -q -O ${chruby}.tar.gz https://github.com/postmodern/chruby/archive/v${chruby_version}.tar.gz
+  [ -d ${chruby} ] || tar -xzf ${chruby}.tar.gz
+  cd ${chruby}/
   ./scripts/setup.sh
   cat > /etc/profile.d/chruby.sh <<'EOF'
 if [ -n "$BASH_VERSION" ] || [ -n "$ZSH_VERSION" ]; then
   source /usr/local/share/chruby/chruby.sh
+  #source /usr/local/share/chruby/auto
 fi
 EOF
   chmod a+r /etc/profile.d/chruby.sh
@@ -33,29 +66,38 @@ EOF
   which ruby-build || PREFIX=/usr/local ./ruby-build/install.sh
 
   mkdir -p /opt/rubies
-  [ -x /opt/rubies/1.9.3-p551/bin/bundle ] || ( ruby-build 1.9.3-p551 /opt/rubies/1.9.3-p551 && /opt/rubies/1.9.3-p551/bin/gem install bundler )
-
-  for v in 2.2.0
+  for v in 2.2.2
   do
-    [ -x /opt/rubies/$v/bin/bundle ] || ( ruby-build $v /opt/rubies/$v && /opt/rubies/$v/bin/gem install bundler )
+    [ -x /opt/rubies/$v/bin/ruby ] || ( ruby-build $v /opt/rubies/$v )
+    [ -x /opt/rubies/${v}/bin/bundle ] || ( /opt/rubies/${v}/bin/gem install bundler -v '<2.0' )
+  done
+  
+  for v in 2.3.8 2.4.10 2.5.9 2.5.0 2.6.6 2.6.7 2.7.1 2.7.3 3.0.1
+  do
+    [ -x /opt/rubies/$v/bin/ruby ] || ( ruby-build $v /opt/rubies/$v )
+    [ -x /opt/rubies/$v/bin/bundle ] || ( /opt/rubies/$v/bin/gem install bundler )
   done
 )
 
 echo Setup system ruby
-which bundle || gem install bundler 
+which bundle || gem install bundler || gem install bundler -v '<2.0'
+which bundle || gem install bundler -v '< 2.0'
 bundle --version
 set +x
 cat <<EOF
 
 Now test by running the following commands:
 
+  vagrant ssh
+  cd /vagrant
+
   chruby RUBY_VERSION
   or
   chruby system # for system version 2.3.1
 
-  vagrant ssh
-  cd /vagrant
   ./test/test_with_railsapp
 
+  exit
+
 EOF
 exit
diff --git a/test/rails_5.0.gemfile b/test/rails_5.0.gemfile
index 1bbb4c3..b1675db 100644
--- a/test/rails_5.0.gemfile
+++ b/test/rails_5.0.gemfile
@@ -17,12 +17,13 @@ group :development, :test do
     gem 'sqlite3', "~> 1.3.7"
   end
   gem 'shoulda'
-  
-  # redis based checks
-  gem 'sidekiq', :require => !ENV['SIDEKIQ'].nil?
-  gem 'redis', :require => !ENV['REDIS_URL'].nil?
-  gem 'resque', :require => !ENV['RESQUE'].nil?
-  # s3 check
-  gem 'aws-sdk', :require => !ENV['AWS_ACCESS_KEY_ID'].nil?
 end
+  
+# redis based checks
+gem 'sidekiq', '~> 5.2.9', require: !ENV['SIDEKIQ'].nil? # REQUIRED
+gem 'redis', '~> 4.0.3', require: !ENV['REDIS_URL'].nil? # REQUIRED
+gem 'resque', '~> 1.27.4', require: !ENV['RESQUE'].nil? # REQUIRED
+gem 'elasticsearch', '~> 6.3.1', require: !ENV['ELASTICSEARCH_URL'].nil? # REQUIRED
+# s3 check
+gem 'aws-sdk-s3', require: !ENV['AWS_ACCESS_KEY_ID'].nil? # REQUIRED
 
diff --git a/test/rails_5.1.gemfile b/test/rails_5.1.gemfile
index c176ed9..8409b3c 100644
--- a/test/rails_5.1.gemfile
+++ b/test/rails_5.1.gemfile
@@ -23,13 +23,12 @@ group :development, :test do
     gem 'sqlite3', "~> 1.3.7"
   end
   gem 'shoulda'
-  
-  # redis based checks
-  gem 'sidekiq', :require => !ENV['SIDEKIQ'].nil?
-  gem 'redis', :require => !ENV['REDIS_URL'].nil?
-  gem 'resque', :require => !ENV['RESQUE'].nil?
-  # s3 check
-  gem 'aws-sdk', :require => !ENV['AWS_ACCESS_KEY_ID'].nil?
-
 end
 
+# redis based checks
+gem 'sidekiq', '~> 5.2.9', require: !ENV['SIDEKIQ'].nil? # REQUIRED
+gem 'redis', '~> 4.0.3', require: !ENV['REDIS_URL'].nil? # REQUIRED
+gem 'resque', '~> 1.27.4', require: !ENV['RESQUE'].nil? # REQUIRED
+gem 'elasticsearch', '~> 6.3.1', require: !ENV['ELASTICSEARCH_URL'].nil? # REQUIRED
+# s3 check
+gem 'aws-sdk', require: !ENV['AWS_ACCESS_KEY_ID'].nil? # REQUIRED
diff --git a/test/rails_5.2.gemfile b/test/rails_5.2.gemfile
new file mode 100644
index 0000000..4c0b1e1
--- /dev/null
+++ b/test/rails_5.2.gemfile
@@ -0,0 +1,34 @@
+# Gemfile for health_test testing
+
+source 'https://rubygems.org'
+
+ruby RUBY_VERSION < '2.2.2' ? '2.2.2' : RUBY_VERSION
+
+gem 'rails', '~> 5.2.0'
+gem 'rake', '>= 0.8.7'
+
+#  spring-watcher-listen was resolved to 2.0.1, which depends on
+#    listen was resolved to 3.1.5, which depends on
+#      ruby_dep
+#      and ruby_dep 1.5 requires 2.2.3 or later
+gem 'ruby_dep', '~> 1.3.0'  # REQUIRED
+
+gem 'listen', '<3.1.2' # REQUIRED
+
+group :development, :test do
+  if defined?(JRUBY_VERSION)
+    gem 'jruby-openssl'
+    gem 'activerecord-jdbcsqlite3-adapter'
+  else
+    gem 'sqlite3', "~> 1.3.7"
+  end
+  gem 'shoulda'
+end
+
+# redis based checks
+gem 'sidekiq', '~> 5.2.9', require: !ENV['SIDEKIQ'].nil? # REQUIRED
+gem 'redis', '~> 4.0.3', require: !ENV['REDIS_URL'].nil? # REQUIRED
+gem 'resque', '~> 1.27.4', require: !ENV['RESQUE'].nil? # REQUIRED
+gem 'elasticsearch', '~> 6.3.1', require: !ENV['ELASTICSEARCH_URL'].nil? # REQUIRED
+# s3 check
+gem 'aws-sdk', require: !ENV['AWS_ACCESS_KEY_ID'].nil? # REQUIRED
diff --git a/test/rails_6.0.gemfile b/test/rails_6.0.gemfile
new file mode 100644
index 0000000..a1fdaba
--- /dev/null
+++ b/test/rails_6.0.gemfile
@@ -0,0 +1,30 @@
+# Gemfile for health_test testing
+
+source 'https://rubygems.org'
+
+ruby RUBY_VERSION < '2.5' ? '2.5.0' : RUBY_VERSION
+
+gem 'rails', '~> 6.0.0'
+gem 'rake', '>= 0.8.7'
+
+gem 'listen', '<3.1.2' # REQUIRED
+
+group :development, :test do
+  if defined?(JRUBY_VERSION)
+    gem 'jruby-openssl'
+    gem 'activerecord-jdbcsqlite3-adapter'
+  else
+    gem 'sqlite3', "~> 1.3.7"
+  end
+  gem 'shoulda'
+end
+
+# redis based checks
+gem 'sidekiq', '~> 5.2.9', require: !ENV['SIDEKIQ'].nil? # REQUIRED
+gem 'redis', '~> 4.0.3', require: !ENV['REDIS_URL'].nil? # REQUIRED
+gem 'resque', '~> 1.27.4', require: !ENV['RESQUE'].nil? # REQUIRED
+gem 'elasticsearch', '~> 6.3.1', require: !ENV['ELASTICSEARCH_URL'].nil? # REQUIRED
+# s3 check
+gem 'aws-sdk-s3', require: !ENV['AWS_ACCESS_KEY_ID'].nil? # REQUIRED
+
+gem 'webpacker', '~> 4.0.7' # REQUIRED
diff --git a/test/rails_6.1.gemfile b/test/rails_6.1.gemfile
new file mode 100644
index 0000000..2cfe991
--- /dev/null
+++ b/test/rails_6.1.gemfile
@@ -0,0 +1,29 @@
+# Gemfile for health_test testing
+
+source 'https://rubygems.org'
+
+ruby RUBY_VERSION < '2.5' ? '2.5.0' : RUBY_VERSION
+
+gem 'rails', '~> 6.1.0'
+gem 'rake', '>= 0.8.7'
+
+group :development, :test do
+  if defined?(JRUBY_VERSION)
+    gem 'jruby-openssl'
+    gem 'activerecord-jdbcsqlite3-adapter'
+  else
+    gem 'sqlite3', "~> 1.3.7"
+  end
+  gem 'shoulda'
+end
+
+# redis based checks
+gem 'sidekiq', require: !ENV['SIDEKIQ'].nil? # REQUIRED
+gem 'redis', require: !ENV['REDIS_URL'].nil? # REQUIRED
+gem 'resque', require: !ENV['RESQUE'].nil? # REQUIRED
+# s3 check
+gem 'aws-sdk-s3', require: !ENV['AWS_ACCESS_KEY_ID'].nil? # REQUIRED
+
+gem 'webpacker', '~> 4.0.7' # REQUIRED
+gem 'rexml', '~> 3.2.4' # REQUIRED for ruby 3.0
+gem 'webrick' # REQUIRED for ruby 3.0
diff --git a/test/rails_6.2.gemfile b/test/rails_6.2.gemfile
new file mode 100644
index 0000000..b402a53
--- /dev/null
+++ b/test/rails_6.2.gemfile
@@ -0,0 +1,30 @@
+# Gemfile for health_test testing
+
+source 'https://rubygems.org'
+
+ruby RUBY_VERSION < '2.5' ? '2.5.0' : RUBY_VERSION
+
+gem 'rails', '~> 6.2.0'
+gem 'rake', '>= 0.8.7'
+
+group :development, :test do
+  if defined?(JRUBY_VERSION)
+    gem 'jruby-openssl'
+    gem 'activerecord-jdbcsqlite3-adapter'
+  else
+    gem 'sqlite3', "~> 1.3.7"
+  end
+  gem 'shoulda'
+end
+
+# redis based checks
+gem 'sidekiq', '~> 5.2.9', require: !ENV['SIDEKIQ'].nil? # REQUIRED
+gem 'redis', '~> 4.0.3', require: !ENV['REDIS_URL'].nil? # REQUIRED
+gem 'resque', '~> 1.27.4', require: !ENV['RESQUE'].nil? # REQUIRED
+gem 'elasticsearch', '~> 6.3.1', require: !ENV['ELASTICSEARCH_URL'].nil? # REQUIRED
+# s3 check
+gem 'aws-sdk-s3', require: !ENV['AWS_ACCESS_KEY_ID'].nil? # REQUIRED
+
+gem 'webpacker', '~> 4.0.7' # REQUIRED
+gem 'rexml', '~> 3.2.4' # REQUIRED for ruby 3.0
+gem 'webrick' # REQUIRED for ruby 3.0
diff --git a/test/rails_edge.gemfile b/test/rails_edge.gemfile
new file mode 100644
index 0000000..3377171
--- /dev/null
+++ b/test/rails_edge.gemfile
@@ -0,0 +1,37 @@
+# Gemfile for health_test testing
+
+source 'https://rubygems.org'
+
+# Bundle edge Rails instead:
+
+ruby RUBY_VERSION < '2.2.2' ? '2.2.2' : RUBY_VERSION
+
+gem 'rails'
+gem 'rake'
+gem 'rack'
+
+group :development, :test do
+  if defined?(JRUBY_VERSION)
+    gem 'jruby-openssl'
+    gem 'activerecord-jdbcsqlite3-adapter'
+  else
+    gem 'sqlite3'
+  end
+  gem 'shoulda'
+end
+
+# redis based checks
+gem 'sidekiq', '~> 5.2.9', require: !ENV['SIDEKIQ'].nil? # REQUIRED
+gem 'redis', '~> 4.0.3', require: !ENV['REDIS_URL'].nil? # REQUIRED
+gem 'resque', '~> 1.27.4', require: !ENV['RESQUE'].nil? # REQUIRED
+gem 'elasticsearch', '~> 6.3.1', require: !ENV['ELASTICSEARCH_URL'].nil? # REQUIRED
+# s3 check
+gem 'aws-sdk-s3', require: !ENV['AWS_ACCESS_KEY_ID'].nil? # REQUIRED
+
+# Initial Gemfile has therubyracer commented out
+gem 'therubyrhino', platform: :jruby # REQUIRED
+gem 'therubyracer', platform: :ruby # REQUIRED
+
+gem 'webpacker', '~> 4.0.7' # REQUIRED
+gem 'rexml', '~> 3.2.4' # REQUIRED for ruby 3.0
+gem 'webrick' # REQUIRED for ruby 3.0
diff --git a/test/setup_railsapp b/test/setup_railsapp
index c16056a..63bbb1c 100755
--- a/test/setup_railsapp
+++ b/test/setup_railsapp
@@ -2,15 +2,27 @@
 
 route_prefix=medical_check
 
-err_report() {
-    echo "$0: Error on line $1 - aborted"
-    exit 1
+# Any failure causes exit
+set -eE -o functrace
+
+report_failure() {
+  local lineno=$2
+  local fn=$3
+  local exitstatus=$4
+  local msg=$5
+  local lineno_fns=${1% 0}
+  if [[ $lineno_fns != "0" ]] ; then
+    lineno="${lineno} ${lineno_fns}"
+  fi
+  if [[ $exitstatus == 0 ]] ; then
+    echo "${BASH_SOURCE[1]}: Finished!"
+  else
+    echo "${BASH_SOURCE[1]}:${fn}[${lineno}] Failed with status ${exitstatus}: $msg"
+  fi
 }
 
-trap 'err_report $LINENO' ERR
+trap 'report_failure "${BASH_LINENO[*]}" "$LINENO" "${FUNCNAME[*]:-script}" "$?" "$BASH_COMMAND"' ERR
 
-# Any failure causes exit
-set -e
 
 case "$1" in
 [0-9]*)
@@ -54,7 +66,7 @@ mkdir -p tmp/gems
 if $rbenv_which bundle ; then
   echo Bundler is installed
 else
-  gem install bundler
+  gem install bundler ${BUNDLER_VERSION:+-v ${BUNDLER_VERSION}}
   $rehash
 fi
 
@@ -62,6 +74,13 @@ echo "Running bundle with BUNDLE_GEMFILE=$BUNDLE_GEMFILE ..."
 if ! smarter_bundle ; then
     echo "Test aborted (missing required gems)"
     exit 2
+elif [ ! -s $BUNDLE_GEMFILE.lock ] ; then
+    echo "Error: smarter_bundler return OK status BUT lock file ($BUNDLE_GEMFILE.lock) is missing!"
+    exit 3
+else
+    echo bundle passed - lock file contains:
+    cat $BUNDLE_GEMFILE.lock
+    echo
 fi
 $rehash
 
@@ -69,9 +88,9 @@ rails="$base_dir/test/bin/rails"
 rake="$base_dir/test/bin/rake"
 
 echo Checking $rails is present ...
-[ -f $rails -a -f $rake ] || bundle exec rake rails:update:bin || echo '(ignored rake rails:update:bin exit status)'
-[ -f $rails ] || bundle binstubs railties || echo '(ignored bundle exit status)'
-[ -f $rails ] || bundle binstubs rails || echo '(ignored bundle exit status)'
+[ -f $rails -a -f $rake ] || bundle ${BUNDLER_VERSION:+_${BUNDLER_VERSION}_} exec rake rails:update:bin || echo '(ignored rake rails:update:bin exit status)'
+[ -f $rails ] || bundle ${BUNDLER_VERSION:+_${BUNDLER_VERSION}_} binstubs railties || echo '(ignored bundle exit status)'
+[ -f $rails ] || bundle ${BUNDLER_VERSION:+_${BUNDLER_VERSION}_} binstubs rails || echo '(ignored bundle exit status)'
 if [ ! -f $rails ]; then
     echo "Test aborted (unable to create $rails)"
     exit 2
@@ -79,7 +98,7 @@ fi
 
 if [ ! -f $rake ]; then
     echo "Running bundle binstubs rake ..."
-    if ! bundle binstubs rake || [ ! -f $rake ]; then
+    if ! bundle ${BUNDLER_VERSION:+_${BUNDLER_VERSION}_} binstubs rake || [ ! -f $rake ]; then
         echo "Test aborted (unable to create $rake)"
         exit 2
     fi
@@ -124,16 +143,25 @@ esac
 
 echo "Creating $actual_rails_version app in $tmp_dir/railsapp using adapter $db"
 case "$actual_rails_version" in
-    *' '[12].*)
-        $rails railsapp -d $db
-        ;;
     *' '[345].*)
+        args="--skip-bundle -d $db"
         case "$BUNDLE_GEMFILE" in
         *rails_edge.gemfile)
-            $rails new railsapp --skip-bundle -d $db --edge
+            $rails new railsapp $args --edge
             ;;
         *)
-            $rails new railsapp --skip-bundle -d $db
+            $rails new railsapp $args
+            ;;
+        esac
+        ;;
+    *' '[6].*)
+        args="--skip-bundle -d $db --skip-git --skip-bootsnap"
+        case "$BUNDLE_GEMFILE" in
+        *rails_edge.gemfile)
+            $rails new railsapp $args --edge
+            ;;
+        *)
+            $rails new railsapp $args
             ;;
         esac
         ;;
@@ -155,31 +183,48 @@ echo "Configuring mailer to point to fake_smtp_server port 3555"
 cat >> config/environment.rb <<'!EOF!'
 
 ActionMailer::Base.delivery_method = :smtp
-ActionMailer::Base.smtp_settings = { :address => "localhost", :port => 3555 }
+ActionMailer::Base.smtp_settings = { address: "localhost", port: 3555 }
 
 !EOF!
 
 echo Adding an initializer for health_check gem ...
 mkdir -p config/initializers
 tee config/initializers/health_check.rb <<!
-HealthCheck.setup do |config|
-  config.success = "$success"
-  config.smtp_timeout = 60.0
-  config.http_status_for_error_text = 550
-  config.http_status_for_error_object = 555
-  config.uri = '$route_prefix'
-  config.origin_ip_whitelist = ENV['IP_WHITELIST'].split(',') unless ENV['IP_WHITELIST'].blank?
-  config.basic_auth_username = ENV['AUTH_USER'] unless ENV['AUTH_USER'].blank?
-  config.basic_auth_password = ENV['AUTH_PASSWORD'] unless ENV['AUTH_PASSWORD'].blank?
-
-  config.add_custom_check do
-    File.exists?("$custom_file") ? '' : '$custom_file is missing!'
-  end
-
-  config.add_custom_check('pass') do
-    ''
+require 'fileutils'
+
+if defined? HealthCheck
+  HealthCheck.setup do |config|
+    config.success = "$success"
+    config.smtp_timeout = 60.0
+    config.http_status_for_error_text = 550
+    config.http_status_for_error_object = 555
+    config.uri = '$route_prefix'
+    config.origin_ip_whitelist = ENV['IP_WHITELIST'].split(',') unless ENV['IP_WHITELIST'].blank?
+    config.basic_auth_username = ENV['AUTH_USER'] unless ENV['AUTH_USER'].blank?
+    config.basic_auth_password = ENV['AUTH_PASSWORD'] unless ENV['AUTH_PASSWORD'].blank?
+  
+    config.add_custom_check do
+      File.exists?("$custom_file") ? '' : '$custom_file is missing!'
+    end
+  
+    config.add_custom_check('pass') do
+      ''
+    end
+  
+    config.on_failure do |checks, msg|
+      File.open('tmp/health_check_failure.txt', 'w') do |f|
+        f.puts "FAILED: #{checks}, MESSAGE: #{msg}"
+      end
+    end
+  
+    config.on_success do |checks|
+      File.open('tmp/health_check_success.txt', 'w') do |f|
+        f.puts "PASSED: #{checks}"
+      end
+    end
+  
+    config.include_error_in_response_body = ENV['HIDE_ERROR_RESPONSE'].to_s !~ /^[1tTyY]/
   end
-
 end
 !
 
@@ -194,7 +239,7 @@ then
     exit 2
 fi
 echo Adding health_check as gem to Gemfile...
-echo "gem 'health_check', :path => '$base_dir'" >> Gemfile
+echo "gem 'health_check', path: '$base_dir'" >> Gemfile
 
 case "$RAILS_SERVER" in
 webrick|'')
@@ -205,33 +250,59 @@ webrick|'')
         echo "gem '$RAILS_SERVER'" >> Gemfile
         ;;
 esac
-
-sed -i.bak -e '/listen/s/^/#Earlier version required # /' Gemfile
-
-egrep REQUIRED < ${INITIAL_BUNDLE_GEMFILE} >> Gemfile || echo No required gems found...
+TAB=$'\t'
+QUOTES='"'"'"
+case "$actual_rails_version" in
+*' '5.0*)
+  if egrep -i 'gem.*sqlite3' Gemfile ; then
+     # Can't do this as a require as we may go back to testing JRuby
+     echo Force sqlite to 1.3.13+ version for Rails 5.0 ...
+     gem=sqlite3
+     sed -i.bak -e "s/^\([ ${TAB}]*gem[ ${TAB}]*[${QUOTES}]${gem}[${QUOTES}]\)\(.*\)$/\1, '~> 1.3.13' # overriden: \2/" Gemfile
+  fi
+  ;;
+esac
+if egrep -q REQUIRED ${INITIAL_BUNDLE_GEMFILE} ; then
+  sed -n "s/^[ ${TAB}]*gem[ ${TAB}]*[${QUOTES}]\([^${QUOTES}]*\)[${QUOTES}].*REQUIRED.*/\1/p" ${INITIAL_BUNDLE_GEMFILE} | while read gem
+  do
+    echo "Commenting out gem '$gem' line in Gemfile"
+    sed -i.bak -e "s/^\([ ${TAB}]*gem[ ${TAB}]*[${QUOTES}]${gem}[${QUOTES}].*\)$/# overriden by REQUIRED below: \1/" Gemfile
+  done
+  echo Adding Required gems
+  egrep REQUIRED ${INITIAL_BUNDLE_GEMFILE} | tee -a Gemfile
+else
+  echo No required gems to be added to Gemfile 
+fi
 
 echo
-echo ================= Gemfile ===================
+echo ================= $PWD/Gemfile ===================
 cat Gemfile
 echo
-echo running bundle install
-smarter_bundle ${BUNDLER_VERSION:+_${BUNDLER_VERSION}_} install
+echo ==================================================
+echo running smarter_bundle install
+smarter_bundle install
 $rehash
+
+if egrep webpacker Gemfile && [ ! -f config/webpacker.yml ] ; then
+  echo completing setup by running rails webpacker:install ...
+  $rails webpacker:install
+fi
+
 echo "Using binstubs in $railsapp/bin for rails and rake commands"
 rails="$railsapp/bin/rails"
 rake="$railsapp/bin/rake"
 
 echo Checking $rails is present ...
-[ -f $rails -a -f $rake ] || bundle exec rake rails:update:bin || echo '(ignored rake rails:update:bin exit status)'
-[ -f $rails ] || bundle binstubs railties || echo '(ignored bundle exit status)'
-[ -f $rails ] || bundle binstubs rails || echo '(ignored bundle exit status)'
+[ -f $rails -a -f $rake ] || bundle ${BUNDLER_VERSION:+_${BUNDLER_VERSION}_} exec rake rails:update:bin || echo '(ignored rake rails:update:bin exit status)'
+[ -f $rails ] || bundle ${BUNDLER_VERSION:+_${BUNDLER_VERSION}_} binstubs railties || echo '(ignored bundle exit status)'
+[ -f $rails ] || bundle ${BUNDLER_VERSION:+_${BUNDLER_VERSION}_} binstubs rails || echo '(ignored bundle exit status)'
 if [ ! -f $rails ]; then
     echo "Test aborted (unable to create $rails)"
     exit 2
 fi
 
 echo Checking $rake is present ...
-[ -f $rake ] || bundle binstubs rake || echo '(ignored bundle exit status)'
+[ -f $rake ] || bundle ${BUNDLER_VERSION:+_${BUNDLER_VERSION}_} binstubs rake || echo '(ignored bundle exit status)'
 if [ ! -f $rake ]; then
     echo "Test aborted (unable to create $rake)"
     exit 2
@@ -240,8 +311,9 @@ fi
 $rehash
 # Fix for rvm, otherwise bundle run from rails create fails
 export PATH="`pwd`/bin:$PATH"
-echo ================= Gemfile.lock ===================
+echo ================= $PWD/Gemfile.lock ===================
 cat Gemfile.lock
+echo ==================================================
 echo
 
 for e in test ${RAILS_ENV2:-production}
@@ -255,11 +327,22 @@ do
       echo
     fi
 done
-echo "============== config/environment.rb ============="
+
+if egrep -q 'bootsnap.setup' config/boot.rb  ; then
+  echo Commenting out bootsnap from config/boot.rb
+  sed -i.bak -e 's/^\(.*bootsnap.setup\)/# \1/' config/boot.rb 
+  echo "============== $PWD/config/boot.rb ============="
+  cat config/boot.rb
+  echo ==================================================
+fi
+rm -rf tmp/cache/bootsnap*
+echo 
+
+echo "============== $PWD/config/environment.rb ============="
 cat config/environment.rb
 echo 
 
-echo ========================
+echo =========================================================
 case $db in
     jdbcsqlite3)
       for e in test ${RAILS_ENV2:-production}
@@ -350,11 +433,11 @@ cat > app/controllers/example_controller.rb <<'EOF'
 class ExampleController < ApplicationController
 
   def index
-    render :plain => 'example page'
+    render plain: 'example page'
   end
   
   def catchall
-    render :plain => 'catch all route'
+    render plain: 'catch all route'
   end
   
 end
@@ -388,7 +471,7 @@ case "$MIDDLEWARE" in
 
     #echo =============== config/application.rb-old ========================
     #cat config/application.rb-old
-    echo =============== config/application.rb ========================
+    echo =============== $PWD/config/application.rb ========================
     cat config/application.rb
   else
     echo FAILED: NO config/application.rb file!!
@@ -412,11 +495,12 @@ if [ -s config/routes.rb ]; then
     # rails 3.0+
     echo "  # -----------------------------------------"
     echo "  # START OF SECTION FOR TESTING HEALTH_CHECK"
-    echo "  get 'example(/:action(/:id))(.:format)' => 'example'"
+    echo "  get 'example/catchall(.:format)', controller: :example, action: :catchall"
+    echo "  get 'example(.:format)', controller: :example, action: :index"
     echo "  if File.exists?('$catchall_file')"
     echo "    health_check_routes"
     echo "    # CATCH ALL ROUTE"
-    echo "    get '*path', :to => 'example#catchall'"
+    echo "    get '*path', controller: :example, action: :catchall"
     echo "  end"
     echo "  # END OF SECTION FOR TESTING HEALTH_CHECK"
     echo "  # ---------------------------------------"
diff --git a/test/test_with_railsapp b/test/test_with_railsapp
index e715983..c514df4 100755
--- a/test/test_with_railsapp
+++ b/test/test_with_railsapp
@@ -2,15 +2,49 @@
 
 route_prefix=medical_check
 
-err_report() {
-    echo "$0: Error on line $1 - aborted"
-    exit 1
+# Any failure causes exit
+set -eE -o functrace
+
+report_failure() {
+  local lineno=$2
+  local fn=$3
+  local exitstatus=$4
+  local msg=$5
+  local lineno_fns=${1% 0}
+  if [[ $lineno_fns != "0" ]] ; then
+    lineno="${lineno} ${lineno_fns}"
+  fi
+  if [[ $exitstatus == 0 ]] ; then
+    echo "${BASH_SOURCE[1]}: Finished!"
+  else
+    echo "${BASH_SOURCE[1]}:${fn}[${lineno}] Failed with status ${exitstatus}: $msg"
+  fi
 }
 
-trap 'err_report $LINENO' ERR
+trap 'report_failure "${BASH_LINENO[*]}" "$LINENO" "${FUNCNAME[*]:-script}" "$?" "$BASH_COMMAND"' ERR
+
 
 # Any failure causes exit
-set -e
+set -eE -o functrace
+
+report_failure() {
+  local lineno=$2
+  local fn=$3
+  local exitstatus=$4
+  local msg=$5
+  local lineno_fns=${1% 0}
+  if [[ $lineno_fns != "0" ]] ; then
+    lineno="${lineno} ${lineno_fns}"
+  fi
+  if [[ $exitstatus == 0 ]] ; then
+    echo "${BASH_SOURCE[1]}: Finished!"
+  else
+    echo "${BASH_SOURCE[1]}:${fn}[${lineno}] Failed with status ${exitstatus}: $msg"
+  fi
+}
+
+trap 'report_failure "${BASH_LINENO[*]}" "$LINENO" "${FUNCNAME[*]:-script}" "$?" "$BASH_COMMAND"' ERR
+
 export DISABLE_SPRING=1
 
 cleanup_db()
@@ -91,18 +125,25 @@ start_server()
         bundle_prefix='bundle exec'
     fi
     server_arg=${RAILS_SERVER:-webrick}
+    case "$actual_rails_version" in
+    *' '[12345].*)
+        ;;
+    *) 
+        server_arg="-u $server_arg"
+        ;;
+    esac
     echo "start_server called using: `env | egrep '^RAILS|^RACK|^PATH='` $bundle_prefix $server_arg"
     case "$server_arg" in
-    puma) 
+    *puma) 
         $bundle_prefix puma -b tcp://127.0.0.1:$port &
         ;;
-    passenger) 
+    *passenger) 
         $bundle_prefix passenger start -p $port &
         ;;
-    thin) 
+    *thin) 
         $bundle_prefix thin start -p $port &
         ;;
-    unicorn) 
+    *unicorn) 
         $bundle_prefix unicorn_rails -l 127.0.0.1:$port &
         ;;
     *)
@@ -212,7 +253,7 @@ common_tests()
     test_no=$1
 
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: CHECKING routes exist..."
+        echo "${test_no}[line $LINENO]: CHECKING routes exist..."
         $rake routes | tee /tmp/t$$
         echo
         case `egrep ${route_prefix} /tmp/t$$ || true` in
@@ -225,7 +266,7 @@ common_tests()
 
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING can get a static file ..."
+        echo "${test_no}[line $LINENO]: TESTING can get a static file ..."
         case "$RAILS_ENV=`egrep '^\s*config.serve_static_[asetfil]* *= *false' config/environments/${RAILS_ENV}.rb`" in
         production*static*false*)
             echo "  SKIPPED (disabled in production)"
@@ -238,40 +279,77 @@ common_tests()
         echo
     fi
 
+    rm -f tmp/health_check_success.txt tmp/health_check_failure.txt
+
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING can get an example controller ..."
+        echo "${test_no}[line $LINENO]: TESTING can get an example controller ..."
         $testurl ${host}/example 200 text/plain 'example page'
         echo
     fi
 
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING direct call to catchall method on example controller ..."
+        echo "${test_no}[line $LINENO]: TESTING direct call to catchall method on example controller ..."
         $testurl ${host}/example/catchall 200 text/plain 'catch all route'
         echo
     fi
 
+    if [ -f tmp/health_check_success.txt ] ; then
+        echo "FAIL tmp/health_check_success.txt exists on line $LINENO" 
+    else
+        echo "PASS tmp/health_check_success.txt is missing as expected on line $LINENO" 
+    fi
+    if [ -f tmp/health_check_failure.txt ] ; then
+        echo "FAIL tmp/health_check_failure.txt exists on line $LINENO" 
+    else
+        echo "PASS tmp/health_check_failure.txt is missing as expected on line $LINENO" 
+    fi
+
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix}/migration should pass with no database migrations ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/migration should pass with no database migrations ..."
         ls db/migrate
+        rm -f tmp/health_check_success.txt tmp/health_check_failure.txt
         $testurl ${host}/${route_prefix}/migration 200 text/plain $success
+        if [ -f tmp/health_check_success.txt ] ; then
+            echo "PASS tmp/health_check_success.txt exists as expected on line $LINENO" 
+            cat tmp/health_check_success.txt
+        else
+            echo "FAIL tmp/health_check_success.txt is missing on line $LINENO" 
+        fi
+        if [ -f tmp/health_check_failure.txt ] ; then
+            echo "FAIL tmp/health_check_failure.txt exists on line $LINENO" 
+        else
+            echo "PASS tmp/health_check_failure.txt is missing as expected on line $LINENO" 
+        fi
         echo
     fi
 
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix}/migration should fail without initial database migration ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/migration should fail without initial database migration ..."
         cp $base_dir/test/migrate/nine/* db/migrate
         ls db/migrate
+        rm -f tmp/health_check_success.txt tmp/health_check_failure.txt
         $testurl ${host}/${route_prefix}/migration 550 text/plain failed
+        if [ -f tmp/health_check_success.txt ] ; then
+            echo "FAIL tmp/health_check_success.txt exists on line $LINENO" 
+        else
+            echo "PASS tmp/health_check_success.txt is missing as expected on line $LINENO" 
+        fi
+        if [ -f tmp/health_check_failure.txt ] ; then
+            echo "PASS tmp/health_check_failure.txt exists as expected on line $LINENO" 
+            cat tmp/health_check_failure.txt
+        else
+            echo "FAIL tmp/health_check_failure.txt is missing on line $LINENO" 
+        fi
         echo
     fi
 
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix}/database should pass without initial database migration (since it ignores the difference) ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/database should pass without initial database migration (since it ignores the difference) ..."
         $testurl ${host}/${route_prefix}/database 200 text/plain $success
         echo
     fi
@@ -280,14 +358,14 @@ common_tests()
 
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix}/site should pass ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/site should pass ..."
         $testurl ${host}/${route_prefix}/site 200 text/plain $success
         echo
     fi
 
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix}/migration should pass after initial database migration ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/migration should pass after initial database migration ..."
         $rake db:migrate
         $testurl ${host}/${route_prefix}/migration 200 text/plain $success
         echo
@@ -303,18 +381,33 @@ common_tests()
 
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix}/database should fail if the database has been corrupted ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/database should fail if the database has been corrupted ..."
+
+        $testurl ${host}/${route_prefix}/database 550 text/plain failed:
+        echo
+    fi
 
-        $testurl ${host}/${route_prefix}/database 550 text/plain failed
+    export HIDE_ERROR_RESPONSE=true
+    stop_server
+    start_server
+
+    test_no=`expr 1 + $test_no`
+    if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/database should have response body 'health_check failed' but no error details if include_error_in_response_body is false"
+        $testurl ${host}/${route_prefix}/database 550 text/plain 'health_check failed' failed:
         echo
     fi
 
+    unset HIDE_ERROR_RESPONSE
+    stop_server
+    start_server
+
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix}/site should pass ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/site should pass ..."
         $testurl ${host}/${route_prefix}/site 200 text/plain $success
         if $has_middleware; then
-            echo "${test_no}: TESTING ${route_prefix}/middleware_site should pass ..."
+            echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/middleware_site should pass ..."
             $testurl ${host}/${route_prefix}/middleware_site 200 text/plain $success
         fi
         echo
@@ -325,7 +418,7 @@ common_tests()
 
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix}/migration should fail without all migrations ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/migration should fail without all migrations ..."
         cp $base_dir/test/migrate/twelve/* db/migrate
 
         ls db/migrate
@@ -335,7 +428,7 @@ common_tests()
 
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix}/migration should pass after both database migrations ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/migration should pass after both database migrations ..."
         $rake db:migrate
         $testurl ${host}/${route_prefix}/migration 200 text/plain $success
         echo
@@ -343,7 +436,7 @@ common_tests()
 
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix}/migration should pass after both database migrations ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/migration should pass after both database migrations ..."
         $rake db:migrate
         $testurl ${host}/${route_prefix}/migration 200 text/plain $success
         echo
@@ -351,14 +444,14 @@ common_tests()
 
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix}/email should fail without smtp available ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/email should fail without smtp available ..."
         $testurl ${host}/${route_prefix}/email 550 text/plain failed
         echo
     fi
 
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix}/email should pass with smtp available ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/email should pass with smtp available ..."
         $fake_smtp_server &
         fake_smtp_pid=$!
         sleep 5
@@ -368,14 +461,14 @@ common_tests()
 
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix} (all) should fail without smtp available ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix} (all) should fail without smtp available ..."
         $testurl ${host}/${route_prefix} 550 text/plain failed
         echo
     fi
 
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix}/all should fail without smtp available ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/all should fail without smtp available ..."
         $testurl ${host}/${route_prefix} 550 text/plain failed
         echo
     fi
@@ -383,7 +476,7 @@ common_tests()
     kill -9 $fake_smtp_pid || echo fake_smtp_server had finished as expected
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix} (all) should pass with smtp available ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix} (all) should pass with smtp available ..."
         $fake_smtp_server &
         fake_smtp_pid=$!
         sleep 5
@@ -394,7 +487,7 @@ common_tests()
     kill -9 $fake_smtp_pid || echo fake_smtp_server had finished as expected
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix}/all should pass with smtp available ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/all should pass with smtp available ..."
         $fake_smtp_server &
         fake_smtp_pid=$!
         sleep 5
@@ -404,28 +497,28 @@ common_tests()
 
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix}/pass should pass ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/pass should pass ..."
         $testurl ${host}/${route_prefix}/pass 200 text/plain $success
         echo
     fi
 
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix}/custom should pass ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/custom should pass ..."
         $testurl ${host}/${route_prefix}/custom 200 text/plain $success
         echo
     fi
 
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix}/custom.html should pass (returning plain text) ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/custom.html should pass (returning plain text) ..."
         $testurl ${host}/${route_prefix}/custom.html 200 text/plain $success
         echo
     fi
 
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix}/custom.json should pass ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/custom.json should pass ..."
         $testurl ${host}/${route_prefix}/custom.json 200 application/json '"healthy":true'
         $testurl ${host}/${route_prefix}/custom.json 200 application/json "\"message\":\"$success\""
         echo
@@ -433,7 +526,7 @@ common_tests()
 
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix}/custom.xml should pass ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/custom.xml should pass ..."
         $testurl ${host}/${route_prefix}/custom.xml 200 application/xml '<healthy type="boolean">true</healthy>'
         $testurl ${host}/${route_prefix}/custom.xml 200 application/xml "<message>$success</message>"
         echo
@@ -442,27 +535,27 @@ common_tests()
     test_no=`expr 1 + $test_no`
     rm -f $custom_file
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix}/custom should fail when custom returns string ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/custom should fail when custom returns string ..."
         $testurl ${host}/${route_prefix}/custom 550 text/plain failed
         echo
     fi
 
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix}/pass should pass even if other custom test returns string ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/pass should pass even if other custom test returns string ..."
         $testurl ${host}/${route_prefix}/pass 200 text/plain $success
         echo
     fi
 
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix} (all) should fail when custom check fails ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix} (all) should fail when custom check fails ..."
         $testurl ${host}/${route_prefix} 550 text/plain "$custom_file is missing!"
         echo
     fi
 
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix}.json (all) should fail when custom check fails ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix}.json (all) should fail when custom check fails ..."
         $testurl ${host}/${route_prefix}.json 555 application/json '"healthy":false'
         $testurl ${host}/${route_prefix}.json 555 application/json "$custom_file is missing!"
         echo
@@ -470,7 +563,7 @@ common_tests()
 
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING ${route_prefix}.xml (all) should fail when custom check fails ..."
+        echo "${test_no}[line $LINENO]: TESTING ${route_prefix}.xml (all) should fail when custom check fails ..."
         $testurl ${host}/${route_prefix}.xml 555 application/xml '<healthy type="boolean">false</healthy>'
         echo
     fi
@@ -478,10 +571,10 @@ common_tests()
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
         if $has_middleware; then
-            echo "${test_no}: TESTING ${route_prefix}/middleware_site should pass ..."
+            echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/middleware_site should pass ..."
             $testurl ${host}/${route_prefix}/middleware_site 200 text/plain $success
         else
-            echo "${test_no}: TESTING ${route_prefix}/middleware_site should fail ..."
+            echo "${test_no}[line $LINENO]: TESTING ${route_prefix}/middleware_site should fail ..."
             $testurl ${host}/${route_prefix}/middleware_site 550 text/plain failed
         fi
         echo
@@ -489,7 +582,7 @@ common_tests()
 
     test_no=`expr 1 + $test_no`
     if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
-        echo "${test_no}: TESTING log files to check for deprecation warnings ..."
+        echo "${test_no}[line $LINENO]: TESTING log files to check for deprecation warnings ..."
         if egrep ' is deprecated|DEPRECATION WARNING' $railsapp/log/[tp][er][so][td]*.log 
         then
             echo Found deprecation warnings - failed test
diff --git a/test/testurl b/test/testurl
index 0f3a670..df22086 100755
--- a/test/testurl
+++ b/test/testurl
@@ -62,4 +62,13 @@ if ARGV[3] and ARGV[3] != ''
   end
 end
 
+if ARGV[4] and ARGV[4] != ''
+  if !page_content.to_s.include? ARGV[4]
+    puts "PASS (did not find #{ARGV[4]})"
+  else
+    puts "FAIL (found #{ARGV[4]}) - page contents:" , page_content.to_s, 'END-OF-CONTENTS'
+    exit 3
+  end
+end
+
 exit 0

Debdiff

[The following lists of changes regard files as different if they have different names, permissions or owners.]

Files in second set of .debs but not in first

-rw-r--r--  root/root   /usr/lib/ruby/vendor_ruby/health_check/elasticsearch_health_check.rb
-rw-r--r--  root/root   /usr/lib/ruby/vendor_ruby/health_check/rabbitmq_health_check.rb
-rw-r--r--  root/root   /usr/share/rubygems-integration/all/specifications/health_check-3.1.0.gemspec

Files in first set of .debs but not in second

-rw-r--r--  root/root   /usr/share/rubygems-integration/all/specifications/health_check-3.0.0.gemspec

Control files: lines which differ (wdiff format)

  • Ruby-Versions: all

More details

Full run details