Sha256: ee2b4f43e979a0d9b6bf578357c219d89591fc02c161d60f25a6f4fc1db2fbfd

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

require 'spec_helper'

describe RolloutUi::Feature do
  before do
    # Request a feature to prime RolloutUi::Wrapper rollout instance
    $rollout.active?(:featureA, mock(:user, :id => 5))

    @feature = RolloutUi::Feature.new(:featureA)
  end

  describe "#percentage" do
    it "returns the activated percentage for the feature" do
      $rollout.activate_percentage(:featureA, 75)
      @feature.percentage.should == "75"
    end
  end

  describe "#percentage=" do
    it "sets the activated percentage for the feature" do
      @feature.percentage = 90
      RolloutUi::Feature.new(:featureA).percentage.should == "90"
    end
  end

  describe "#groups" do
    it "returns the activated groups for the feature" do
      $rollout.activate_group(:featureA, :beta_testers)
      @feature.groups.should == ["beta_testers"]
    end
  end

  describe "#groups=" do
    it "sets the activated groups for the feature" do
      @feature.groups = ["all", "admins"]
      RolloutUi::Feature.new(:featureA).groups.should == ["admins", "all"]
    end
  end

  describe "#users" do
    it "returns the activated users for the feature" do
      $rollout.activate_user(:featureA, mock(:user, :id => 5))
      @feature.user_ids.should == ["5"]
    end
  end

  describe "#users=" do
    it "sets the activated users for the feature" do
      @feature.user_ids = [5, "7", ""]
      RolloutUi::Feature.new(:featureA).user_ids.length.should == 2
      RolloutUi::Feature.new(:featureA).user_ids.should include("5") 
      RolloutUi::Feature.new(:featureA).user_ids.should include("7") 
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rollout_ui-0.2.1 spec/lib/rollout_ui/feature_spec.rb