Skip to content

Instantly share code, notes, and snippets.

View pierrevalade's full-sized avatar

Pierre pierrevalade

View GitHub Profile
@johnboxall
johnboxall / gunzip.js
Created November 8, 2011 01:30
nodejs: gunzip httpclientresponse w/ zlib
var http = require('http');
var zlib = require('zlib');
var request = http.get({
host: 'www.bonobos.com',
port: 80,
path: '/',
headers: {'accept-encoding': 'gzip'}
});
@igrigorik
igrigorik / em-http-vcr.rb
Created January 30, 2011 04:56
Mocking with WebMock and VCR
require 'rubygems'
require 'test/unit'
require 'em-http'
require 'vcr'
VCR.config do |c|
c.cassette_library_dir = 'fixtures/vcr_cassettes'
c.http_stubbing_library = :webmock
end
@anolson
anolson / application_controller.rb
Created November 16, 2010 16:11
Rails set mobile format.
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :redirect_mobile_device
before_filter :set_mobile_format
private
def redirect_mobile_device
if is_mobile_device?
@juliocesar
juliocesar / testing_front_end_rspec_capybara.md
Created October 21, 2010 23:51
Testing front-end for a Sinatra app with RSpec and Capybara

Testing front-end for a Sinatra app with RSpec and Capybara

I've used Cucumber quite a bit on my last job. It's an excellent tool, and I believe readable tests are the way to the future. But I could never get around to write effective scenarios, or maintain the boatload of text that the suite becomes once you get to a point where you have decent coverage. On top of that, it didn't seem to take much for the suite to become really slow as tests were added.

A while ago I've seen a gist by Lachie Cox where he shows how to use RSpec and Capybara to do front-end tests. That sounded perfect for me. I love RSpec, I can write my own matchers when I need them with little code, and it reads damn nicely.

So for my Rails Rumble 2010 project, as usual, I rolled a Sinatra app and figured I should give the idea a shot. Below are my findings.

Gemfile