Sha256: 4aec34b9b57b9d17a20713474de27dd535c1f1d2a6bf7a715507647ba041c112

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

require 'spec_helper'

module GxApi

  describe ExperimentIdentifier do

    subject {
      ExperimentIdentifier.new("Test Test")
    }

    context "Generic Methods" do

      context "#to_key" do

        it "turns its value into a string for a cache key" do
          expect(subject.to_key).to eql("test_test")
        end

      end

    end


    context "IdIdentifier" do

      subject {
        ExperimentIdentifier.new(id: id)
      }

      let(:id) {
        "123"
      }

      context '#matches_experiment?' do

        it 'matches by id' do
          experiment = stub(id: id)
          expect(subject.matches_experiment?(experiment)).to be_truthy
        end

      end

      context '#value' do

        it 'returns the id as its value' do
          expect(subject.value).to eq(id)
        end

      end



    end


    context "NameIdentifier" do

      subject {
        ExperimentIdentifier.new(name)
      }

      let(:name) {
        "123"
      }

      context '#matches_experiment?' do

        it 'matches by name' do
          experiment = stub(name: name)
          expect(subject.matches_experiment?(experiment)).to be_truthy
        end

      end

      context '#value' do

        it 'returns the id as its value' do
          expect(subject.value).to eq(name)
        end

      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gxapi_rails-0.1.0 spec/lib/gxapi/experiment_identifier_spec.rb