Skip to content

Instantly share code, notes, and snippets.

View brunapereira's full-sized avatar

Bruna Pereira brunapereira

View GitHub Profile
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);
})
});
it('should render Card Component', () => {
const cardGroup = shallow(<CardGroup title="Test Group" cards={cards} />);
expect(cardGroup).to.have.exactly(2).descendants(Card)
})
@brunapereira
brunapereira / Gemfile
Last active December 14, 2019 22:21
Gems para utilização do flipper
# Your Gem definitions
# Flipper
gem 'flipper'
# UI
gem 'flipper-ui'
#Adapter
gem 'flipper-active_record'
# config/routes.rb
YourRailsApp::Application.routes.draw do
# Your previous routes...
#flipper route
mount Flipper::UI.app(Flipper) => '/flipper'
end
# 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
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
class Application < Rails::Application
# Configurações já existentes
config.middleware.use Rack::Session::Cookie, secret: ENV.fetch('SESSION_COOKIE_SECRET')
end
module Toggle
class TestToggleService
def show
if Flipper.enabled?(:test_feature)
'Enabled!'
else
'Disabled!'
end
end
end
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|
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