Sha256: 720142e3bf76353b8215406fda6dfb4263a6a90150cd16201ea0ff5161106193

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'
require 'rack/test'
require 'split/dashboard'

describe Split::Dashboard do
  include Rack::Test::Methods

  def app
    @app ||= Split::Dashboard
  end

  it "should respond to /" do
    get '/'
    last_response.should be_ok
  end

  it "should reset an experiment" do
    experiment = Split::Experiment.find_or_create('link_color', 'blue', 'red')
    red = Split::Alternative.find('red', 'link_color').participant_count

    red = Split::Alternative.find('red', 'link_color')
    blue = Split::Alternative.find('blue', 'link_color')
    red.participant_count = 5
    red.save
    blue.participant_count = 6
    blue.save

    post '/reset/link_color'

    last_response.should be_redirect

    new_red_count = Split::Alternative.find('red', 'link_color').participant_count
    new_blue_count = Split::Alternative.find('blue', 'link_color').participant_count

    new_blue_count.should eql(0)
    new_red_count.should eql(0)
  end

  it "should delete an experiment" do
    experiment = Split::Experiment.find_or_create('link_color', 'blue', 'red')
    delete '/link_color'
    last_response.should be_redirect
    lambda { Split::Experiment.find('link_color') }.should raise_error
  end

  it "should mark an alternative as the winner" do
    experiment = Split::Experiment.find_or_create('link_color', 'blue', 'red')
    experiment.winner.should be_nil

    post '/link_color', :alternative => 'red'

    last_response.should be_redirect
    experiment.winner.name.should eql('red')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
split-0.2.3 spec/dashboard_spec.rb