Sha256: 1526ac1464be9cb2b666dd08da8238acd2e41e28f481917a603be45d4fdc8063

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

require 'test_helper'
require 'experiment_repo'
require 'feature'
require 'resolvers/group'

module CanaryLabs
  class ExperimentRepoTest < ActiveSupport::TestCase
    def test_add_beta
      repo = new_repo
      repo.add :added_beta, '', CanaryLabs::Resolvers::Group.new([])

      assert_includes(
        repo.all,
        Feature.new(:added_beta, '', CanaryLabs::Resolvers::Group.new([])),
      )
    end

    def test_find_beta_by_name
      repo = new_repo
      repo.add :beta_to_find, '', CanaryLabs::Resolvers::Group.new([])

      assert_equal(
        Feature.new(:beta_to_find, '', CanaryLabs::Resolvers::Group.new([])),
        repo.find(:beta_to_find)
       )
    end

    def test_participating_by_name
      repo = new_repo
      repo.add :participatable_beta, '', CanaryLabs::Resolvers::Group.new(['my_id'])

      assert repo.participating? :participatable_beta, 'my_id'
    end

    def test_participating_with_bad_name
      repo = new_repo

      assert repo.participating? :bad_name, 'my_id'
    end

    def test_list_all_betas
      repo = new_repo
      repo.add :beta_a, '', CanaryLabs::Resolvers::Group.new([])
      repo.add :beta_b, '', CanaryLabs::Resolvers::Group.new([])
      repo.add :beta_c, '', CanaryLabs::Resolvers::Group.new([])

      all_betas = repo.all

      assert_equal 3, all_betas.length
      assert_includes all_betas, Feature.new(:beta_a, '', CanaryLabs::Resolvers::Group.new([]))
    end

    private

    def new_repo
      CanaryLabs::ExperimentRepo.new
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
canary_labs-0.2.0 test/experiment_repo_test.rb