linqueta / rails-healthcheck

A simple way to configure a healthcheck route for a Rails application
MIT License
136 stars 10 forks source link

Only depend on actionpack and railties for gem usage #48

Closed nickcampbell18 closed 3 years ago

nickcampbell18 commented 3 years ago

This reduces the dependency surface area when included in Rails applications which aren't using all of the other dependencies (e.g. actioncable, activestorage, etc.)

Closes #47.

❯ bundle exec rspec

Healthcheck::HealthchecksController
  #check
    when check with success
      returns success code
    when check without success
      without verbose setting
        is expected to receive head(503) 1 time
      with verbose setting
        is expected to receive render(*(any args)) 1 time
    with custom
      is expected to receive call(*(any args)) 1 time

Healthcheck::Check
  is expected to be a kind of Healthcheck::Check
  is expected to eq :zero_division
  is expected to eq #<Proc:0x00007fc3a546a850 /Users/nickcampbell/code/github.com/linqueta/rails-healthcheck/spec/healthcheck/check_spec.rb:7 (lambda)>

Healthcheck::Checker
  #initialize
    is expected to be a kind of Healthcheck::Checker
    is expected to be empty
  #check
    with errors
      has two errors
    without errors
      hasnt errors
  #errored?
    without errors
      is expected to be falsey
    with errors
      is expected to be truthy

Healthcheck::Configuration
  #initialize
    is expected to be a kind of Healthcheck::Configuration
    is expected to be nil
    is expected to be nil
    is expected to be nil
    is expected to be nil
    is expected to be nil
    is expected to be nil
    is expected to be empty
  #add_check
    is expected not to be empty
    is expected to eq 1
    is expected to be a kind of Healthcheck::Check

Healthcheck::Error
  #initialize
    is expected to be a kind of Healthcheck::Error
    is expected to eq :migrations
    is expected to eq "StandardError"
    is expected to eq "Migrations are pending. To resolve this issue, run: bin/rails db:migrate RAILS_ENV=production"

Healthcheck::Router
  #mount
    is expected to receive send(:get, {"/healthcheck"=>"healthcheck/healthchecks#check"}) 1 time

Healthcheck
  is expected not to equal nil
  .configure
    is expected to eq 200
    is expected to eq 503
    is expected to eq false
    is expected to eq "/healthcheck"
    is expected to eq :get
    is expected to be a kind of Healthcheck::Check
  .configuration
    is expected to be a kind of Healthcheck::Configuration
  .routes
    is expected to receive mount(*(any args)) 1 time

Healthcheck
  /healthcheck
    all ok
      example at ./spec/requests/healthcheck_spec.rb:17
      is expected to eq ""
    with error in one check
      verbose true
        example at ./spec/requests/healthcheck_spec.rb:28
        is expected not to eq ""
        is expected to eq {"code"=>503, "errors"=>[{"exception"=>"StandardError", "message"=>"year", "name"=>"year_check"}]}
      verbose false
        example at ./spec/requests/healthcheck_spec.rb:50
        is expected to eq ""

Finished in 0.10962 seconds (files took 1.84 seconds to load)
45 examples, 0 failures

COVERAGE: 100.00% -- 76/76 lines in 7 files
linqueta commented 3 years ago

Thank you man, I'll release it immediately!

linqueta commented 3 years ago

I've released your commit as 1.3.0.