Skip to content

Commit

Permalink
Merge pull request #25 from on-strum/develop
Browse files Browse the repository at this point in the history
OnStrum::Healthcheck v0.2.0
  • Loading branch information
bestwebua authored Mar 28, 2024
2 parents c5a9ffe + 3aa5d8a commit 7591ec5
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 4 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.2.0] - 2024-03-28

### Added

- Added ability to use configuration with default settings without block passing

```ruby
OnStrum::Healthcheck.configure # It will create configuration instance with default settings
```

### Updated

- Updated `OnStrum::Healthcheck.configure`, tests
- Updated gem documentation

## [0.1.0] - 2024-03-26

### Added
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,10 @@ Please note, to start using this middleware you should configure `OnStrum::Healt
```ruby
require 'on_strum/healthcheck'

# Configuring OnStrum::Healthcheck with default settings
OnStrum::Healthcheck.configure

RackCascade = Rack::Builder.app do
Rack::Builder.app do
use OnStrum::Healthcheck::RackMiddleware
run YourApplication
end
Expand All @@ -167,6 +168,7 @@ end
```ruby
require 'on_strum/healthcheck'

# Configuring OnStrum::Healthcheck with default settings
OnStrum::Healthcheck.configure

class YourApplication < Roda
Expand All @@ -181,8 +183,11 @@ end

require 'on_strum/healthcheck'

# Configuring OnStrum::Healthcheck with default settings
OnStrum::Healthcheck.configure
```

```ruby
# config/environment.rb

Hanami.configure do
Expand All @@ -197,8 +202,11 @@ end

require 'on_strum/healthcheck'

# Configuring OnStrum::Healthcheck with default settings
OnStrum::Healthcheck.configure
```

```ruby
# config/application.rb

class Application < Rails::Application
Expand Down
2 changes: 2 additions & 0 deletions lib/on_strum/healthcheck.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ def configuration(&block)
end

def configure(&block)
return configuration {} unless block # rubocop:disable Lint/EmptyBlock

configuration(&block)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/on_strum/healthcheck/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module OnStrum
module Healthcheck
VERSION = '0.1.0'
VERSION = '0.2.0'
end
end
23 changes: 21 additions & 2 deletions spec/on_strum/healthcheck_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,27 @@
let(:config_block) { nil }

context 'without block' do
it { expect(configuration).to be_nil }
it { expect { configuration }.not_to change(described_class, :configuration) }
it 'sets default attributes into configuration instance' do
expect { configuration }
.to change(described_class, :configuration)
.from(nil)
.to(be_instance_of(OnStrum::Healthcheck::Configuration))
expect(configuration).to be_an_instance_of(OnStrum::Healthcheck::Configuration)
expect(configuration.services).to eq({})
expect(configuration.services_startup).to eq([])
expect(configuration.services_liveness).to eq([])
expect(configuration.services_readiness).to eq([])
expect(configuration.endpoints_namespace).to eq(OnStrum::Healthcheck::Configuration::ENDPOINTS_NAMESPACE)
expect(configuration.endpoint_startup).to eq(OnStrum::Healthcheck::Configuration::ENDPOINT_STARTUP)
expect(configuration.endpoint_liveness).to eq(OnStrum::Healthcheck::Configuration::ENDPOINT_LIVENESS)
expect(configuration.endpoint_readiness).to eq(OnStrum::Healthcheck::Configuration::ENDPOINT_READINESS)
expect(configuration.endpoint_startup_status_success).to eq(OnStrum::Healthcheck::Configuration::DEFAULT_HTTP_STATUS_SUCCESS)
expect(configuration.endpoint_liveness_status_success).to eq(OnStrum::Healthcheck::Configuration::DEFAULT_HTTP_STATUS_SUCCESS)
expect(configuration.endpoint_readiness_status_success).to eq(OnStrum::Healthcheck::Configuration::DEFAULT_HTTP_STATUS_SUCCESS)
expect(configuration.endpoint_startup_status_failure).to eq(OnStrum::Healthcheck::Configuration::DEFAULT_HTTP_STATUS_FAILURE)
expect(configuration.endpoint_liveness_status_failure).to eq(OnStrum::Healthcheck::Configuration::DEFAULT_HTTP_STATUS_FAILURE)
expect(configuration.endpoint_readiness_status_failure).to eq(OnStrum::Healthcheck::Configuration::DEFAULT_HTTP_STATUS_FAILURE)
end
end

context 'with block' do
Expand Down

0 comments on commit 7591ec5

Please sign in to comment.