Sha256: c399d5900d16c2a035f53695923275076eca2da8946a0c4c03e9f4f55217fd8a

Contents?: true

Size: 1.62 KB

Versions: 8

Compression:

Stored size: 1.62 KB

Contents

require "spec_helper"

module LaunchDarkly
  module Impl
    module EvaluatorSpecBase
      def factory
        EventFactory.new(false)
      end

      def user
        {
          key: "userkey",
          email: "test@example.com",
          name: "Bob"
        }
      end

      def logger
        ::Logger.new($stdout, level: ::Logger::FATAL)
      end

      def get_nothing
        lambda { |key| raise "should not have requested #{key}" }
      end

      def get_things(map)
        lambda { |key|
          raise "should not have requested #{key}" if !map.has_key?(key)
          map[key]
        }
      end

      def basic_evaluator
        subject.new(get_nothing, get_nothing, logger)
      end

      def boolean_flag_with_rules(rules)
        { key: 'feature', on: true, rules: rules, fallthrough: { variation: 0 }, variations: [ false, true ] }
      end

      def boolean_flag_with_clauses(clauses)
        boolean_flag_with_rules([{ id: 'ruleid', clauses: clauses, variation: 1 }])
      end

      def make_user_matching_clause(user, attr)
        {
          attribute: attr.to_s,
          op: :in,
          values: [ user[attr.to_sym] ],
          negate: false
        }
      end

      def make_segment(key)
        {
          key: key,
          included: [],
          excluded: [],
          salt: 'abcdef',
          version: 1
        }
      end

      def make_segment_match_clause(segment)
        {
          op: :segmentMatch,
          values: [ segment[:key] ],
          negate: false
        }
      end
    end

    RSpec.configure { |c| c.include EvaluatorSpecBase, :evaluator_spec_base => true }
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
launchdarkly-server-sdk-6.2.4 spec/impl/evaluator_spec_base.rb
launchdarkly-server-sdk-6.2.3 spec/impl/evaluator_spec_base.rb
launchdarkly-server-sdk-6.2.2 spec/impl/evaluator_spec_base.rb
launchdarkly-server-sdk-6.2.1 spec/impl/evaluator_spec_base.rb
launchdarkly-server-sdk-6.2.0 spec/impl/evaluator_spec_base.rb
launchdarkly-server-sdk-6.1.1 spec/impl/evaluator_spec_base.rb
launchdarkly-server-sdk-6.1.0 spec/impl/evaluator_spec_base.rb
launchdarkly-server-sdk-6.0.0 spec/impl/evaluator_spec_base.rb