Sha256: 724448a120f63f006265887046d03a49de96658d55ad6319d4657b7738dcf646

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 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::Experiment.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::Experiment.find_or_create('color', 'red', 'blue')
      experiment2 = Split::Experiment.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::Experiment.find_or_create('purchase', 'red', 'blue')
      experiment2 = Split::Experiment.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

3 entries across 3 versions & 1 rubygems

Version Path
split-1.0.0 spec/metric_spec.rb
split-0.8.0 spec/metric_spec.rb
split-0.7.3 spec/metric_spec.rb