Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
114 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ | |
*.gem | ||
gemfiles/*.lock | ||
Gemfile.local | ||
.rspec_status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,32 @@ | ||
# frozen_string_literal: true | ||
|
||
module Isolator | ||
# Isolator configuration: | ||
# | ||
# - `raise_exceptions` - whether to raise an exception in case of offense; | ||
# defaults to true in test env and false otherwise. | ||
# NOTE: env is infered from RACK_ENV and RAILS_ENV. | ||
# | ||
# - `logger` - logger instance (nil by default) | ||
# | ||
# - `send_notifications` - whether to send notifications (through uniform_notifier); | ||
# defauls to false | ||
class Configuration | ||
attr_accessor :raise_errors, :logger | ||
attr_accessor :raise_exceptions, :logger, :send_notifications | ||
|
||
def initialize | ||
@logger = nil | ||
@raise_exceptions = test_env? | ||
@send_notifications = false | ||
end | ||
|
||
alias raise_exceptions? raise_exceptions | ||
alias send_notifications? send_notifications | ||
|
||
private | ||
|
||
def test_env? | ||
ENV["RACK_ENV"] == "test" || ENV["RAILS_ENV"] == "test" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,7 @@ | ||
require 'spec_helper' | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Isolator do | ||
subject { described_class } | ||
|
||
describe '.configure' do | ||
before do | ||
described_class.configure do |configuration| | ||
configuration.raise_errors = true | ||
configuration.logger = true | ||
end | ||
end | ||
require "spec_helper" | ||
|
||
it 'sets raise_errors option properly' do | ||
expect(described_class.configuration.raise_errors).to eq true | ||
end | ||
|
||
it 'sets logger option properly' do | ||
expect(described_class.configuration.logger).to eq true | ||
end | ||
end | ||
end | ||
describe Isolator do | ||
subject { described_class } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters