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
describe('Card Group Component', () => { | |
it('should render Card Component', () => { | |
const cardGroup = shallow(<CardGroup title="Test Group" cards={cards} />); | |
expect(cardGroup.find(Card).length).toBe(2); | |
}) | |
}); |
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
it('should render Card Component', () => { | |
const cardGroup = shallow(<CardGroup title="Test Group" cards={cards} />); | |
expect(cardGroup).to.have.exactly(2).descendants(Card) | |
}) |
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
# Your Gem definitions | |
# Flipper | |
gem 'flipper' | |
# UI | |
gem 'flipper-ui' | |
#Adapter | |
gem 'flipper-active_record' |
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
# config/routes.rb | |
YourRailsApp::Application.routes.draw do | |
# Your previous routes... | |
#flipper route | |
mount Flipper::UI.app(Flipper) => '/flipper' | |
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
# config/initializers/flipper.rb | |
require 'flipper/ui' | |
require 'flipper/adapters/active_record' | |
Flipper.configure do |config| | |
config.default do | |
adapter = Flipper::Adapters::ActiveRecord.new | |
Flipper.new(adapter) | |
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
YourRailsApp::Application.routes.draw do | |
flipper_auth_app = Flipper::UI.app(Flipper.instance) do |builder| | |
builder.use Rack::Auth::Basic do |username, password| | |
if username == ENV['FLIPPER_USERNAME'] && password == ENV['FLIPPER_SECRET'] | |
true | |
else | |
false | |
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
class Application < Rails::Application | |
# Configurações já existentes | |
config.middleware.use Rack::Session::Cookie, secret: ENV.fetch('SESSION_COOKIE_SECRET') | |
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
module Toggle | |
class TestToggleService | |
def show | |
if Flipper.enabled?(:test_feature) | |
'Enabled!' | |
else | |
'Disabled!' | |
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
module Helpers | |
def enable_toggle(toggle_name) | |
allow_any_instance_of(Flipper).to receive(:enabled?).with(toggle_name).and_return(true) | |
end | |
def disable_toggle(toggle_name) | |
allow_any_instance_of(Flipper).to receive(:enabled?).with(toggle_name).and_return(false) | |
end | |
end | |
RSpec.configure do |config| |
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
require 'rails_helper' | |
require 'webmock/rspec' | |
describe ::Toggle::TestToggle do | |
context 'When test_toggle feature toggle is active' do | |
it 'returns enabled' do | |
enable_toggle(:test_feature) | |
expect(described_class.new.show).to eql('Enabled!') | |
end |
OlderNewer