Fetching contributors…
Cannot retrieve contributors at this time
84 lines (51 sloc) 1.86 KB

Vanity is an Experiment Driven Development framework for Rails.

A/B Testing With Rails (In 5 Easy Steps)

Step 1: Start using Vanity in your Rails application:

gem.config "vanity"


class ApplicationController < ActionController::Base
  use_vanity :current_user

Step 2: Define your first A/B test. This experiment goes in the file experiments/price_options.rb:

ab_test "Price options" do
  description "Mirror, mirror on the wall, who's the better price of all?"
  alternatives 19, 25, 29
  metrics :signups

Step 3: Present the different options to your users:

<h2>Get started for only $<%= ab_test :price_options %> a month!</h2>

Step 4: Measure conversion:

class SignupController < ApplicationController
  def signup
    @account =[:account])
      track! :signups
      redirect_to @acccount
      render action: :offer

Step 5: Check the report:

vanity --output vanity.html

Building From Source

To run the test suite for the first time:

$ gem install rails mocha timecop
$ rake

You can also +rake test+ if you insist on being explicit.

To build the documentation:

$ gem install yardoc jekyll
$ rake docs
$ open html/index.html

To clean up after yourself:

$ rake clobber

To package Vanity as a gem and install on your machine:

$ rake install


Original code, copyright of Assaf Arkin, released under the MIT license.

Documentation available under the Creative Commons Attribution license.

For full list of credits and licenses: