Skip to content

Instantly share code, notes, and snippets.

View erik-megarad's full-sized avatar

Erik Peterson erik-megarad

View GitHub Profile
@erik-megarad
erik-megarad / gist:1563290
Created January 5, 2012 01:58 — forked from brow/gist:1562617
Benchmark concatenating strings with reduce(:+) vs. with join('').
require 'benchmark'
STRING = 'abc'
ITERATIONS = 500000
Benchmark.bm(10) do |bench|
for n in [2,3,4, 5]
n_strings = Array.new(n, STRING)
bench.report("add #{n}") do
require 'spec_helper'
describe GamesController do
describe 'POST "create"' do
subject(:response) { post :create, params }
context 'valid parameters provided' do
let(:params) { { game: FactoryGirl.attributes_for(:game) } }
specify { expect { subject }.to change(Game, :count).by 1 }