Sha256: da5a7fdb6fa29b6aad5b1c0cb6b08a5fe78b7a882d4cea27c99923a6e956bcde

Contents?: true

Size: 1.24 KB

Versions: 6

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'
require 'split/metric'

describe Split::Metric do
  describe 'possible experiments' do
    it "should load the experiment if there is one, but no metric" do
      experiment = Split::ExperimentCatalog.find_or_create('color', 'red', 'blue')
      expect(Split::Metric.possible_experiments('color')).to eq([experiment])
    end

    it "should load the experiments in a metric" do
      experiment1 = Split::ExperimentCatalog.find_or_create('color', 'red', 'blue')
      experiment2 = Split::ExperimentCatalog.find_or_create('size', 'big', 'small')

      metric = Split::Metric.new(:name => 'purchase', :experiments => [experiment1, experiment2])
      metric.save
      expect(Split::Metric.possible_experiments('purchase')).to include(experiment1, experiment2)
    end

    it "should load both the metric experiments and an experiment with the same name" do
      experiment1 = Split::ExperimentCatalog.find_or_create('purchase', 'red', 'blue')
      experiment2 = Split::ExperimentCatalog.find_or_create('size', 'big', 'small')

      metric = Split::Metric.new(:name => 'purchase', :experiments => [experiment2])
      metric.save
      expect(Split::Metric.possible_experiments('purchase')).to include(experiment1, experiment2)
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
split-1.3.2 spec/metric_spec.rb
split-1.3.1 spec/metric_spec.rb
split-1.3.0 spec/metric_spec.rb
split-1.2.1 spec/metric_spec.rb
split-1.2.0 spec/metric_spec.rb
split-1.1.0 spec/metric_spec.rb