-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from ResultadosDigitais/add-configuration-class
Uncople Configuration to own class
- Loading branch information
Showing
8 changed files
with
76 additions
and
85 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
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module FeatureFlagger | ||
class Configuration | ||
attr_accessor :storage, :yaml_filepath | ||
|
||
def initialize | ||
@storage ||= Storage::Redis.default_client | ||
@yaml_filepath ||= default_yaml_filepath | ||
end | ||
|
||
def info | ||
@info ||= YAML.load_file(yaml_filepath) if yaml_filepath | ||
end | ||
|
||
private | ||
|
||
def default_yaml_filepath | ||
"#{Rails.root}/config/rollout.yml" if defined?(Rails) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'spec_helper' | ||
|
||
module FeatureFlagger | ||
RSpec.describe Configuration do | ||
describe '.storage' do | ||
let(:configuration) { described_class.new } | ||
|
||
context 'no storage set' do | ||
it 'returns a Redis storage by default' do | ||
expect(configuration.storage).to be_a(FeatureFlagger::Storage::Redis) | ||
end | ||
end | ||
|
||
context 'storage set' do | ||
let(:storage) { double('storage') } | ||
|
||
before { configuration.storage = storage } | ||
|
||
it 'returns storage' do | ||
expect(configuration.storage).to eq storage | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe FeatureFlagger do | ||
describe '.configure' do | ||
let(:redis) { double('redis') } | ||
let(:storage) { double('storage') } | ||
|
||
before do | ||
FeatureFlagger.configure do |config| | ||
config.storage = storage | ||
end | ||
end | ||
|
||
it { expect(FeatureFlagger.config.storage).to eq storage } | ||
end | ||
|
||
describe '.control' do | ||
let(:control) { FeatureFlagger.control } | ||
it 'initializes a Control with redis storage' do | ||
expect(control).to be_a(FeatureFlagger::Control) | ||
expect(control.storage).to be_a(FeatureFlagger::Storage::Redis) | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.