$rollout = Rollout.new(REDIS)
$rollout.define_group(:admin) do |user|
user.admin?
end
class Rollout
def self.defaults!
# Put current state of rollouts here
# Example: $rollout.activate_group(:fb_connect, :admin)
end
end
<% if $rollout.active?(:fb_connect, current_user) %>
<%= render "facebook_connect_bar" %>
<% end %>
It should function correctly whether the feature is active or not (tested!)
Test with the feature activated and deactivated
module RolloutHelperMethods
def feature_on(feature)
$rollout.activate_group(feature, :all)
end
def feature_off(feature)
$rollout.deactivate_all(feature)
end
end
RSpec.configuration.include RolloutHelperMethods
require File.dirname(__FILE__) + '/acceptance_helper'
feature "Log in: " do
background do
@bob = Factory(:user, :email => "[email protected]", :screen_name => "Bob")
feature_off(:fb_connect)
end
scenario "user logs in with its challengepost account" do
...
end
scenario "user fails to log in" do
...
end
scenario "user choose not to login after all" do
...
end
scenario "fb connect should not be active" do
# replace with an actual test
$rollout.active?(:fb_connect, AnonymousUser.new).should be_false
end
context "fb connect is enabled" do
background do
feature_on(:fb_connect)
end
scenario "fb connect should be active" do
# replace with an actual test
$rollout.active?(:fb_connect, AnonymousUser.new).should be_true
end
end
end
Thank you, enjoy your day.