Skip to content

Instantly share code, notes, and snippets.

begin
require 'rake'
rescue LoadError
require 'rubygems'
require 'rake'
end
#----------------------------------------------------------------------------
# Git Setup
#----------------------------------------------------------------------------
file '.gitignore', <<-FILE
.DS_Store
log/*.log
tmp/**/*
config/database.yml
db/*.sqlite3
public/uploads/*
module Mod
def self.included(base)
base.class_eval do
puts "Included in #{base}"
end
end
end
# Adapted for Rspec2. This won't work in RSpec 1.
# Put this code in acceptance_helper.rb or better in a new file spec/acceptance/support/javascript.rb
Rspec.configure do |config|
config.before(:each) do
Capybara.current_driver = :selenium if example.metadata[:js]
end
config.after(:each) do
# config.ru
class RackApp
def call(env)
[200, {'Content-Type' => 'text/plain'}, ["Hello world!"]]
end
end
class AdminRackApp
def call(env)
#!/usr/bin/env ruby
# encoding: UTF-8
#
# LearnRubyByExample:
#
# Ruby is a highly expressive programming language.
# Testing software is an expressive way to communicate how it works.
#
# In the middle of a night awake for allergy and insomnia, and some days after the 1st _why day,
# I've tried to combine Ruby and testing to help teaching ruby with some goals in mind:

How do I do what I do? (and why)

A talk proposal for Conferencia Rails 2010, by Raul Murciano

Abstract

I always love to see how other people work: we all have small tips and habits that help us to work less, better, and to be happier in our daily work.

Thinking that other people may find it interesting too, with this talk I'd like to share what my daily workflow is and why I'm doing things this way, including aspects like:

def fucking_ie6?
request.env['HTTP_USER_AGENT'] and request.env['HTTP_USER_AGENT'].include? "MSIE 6.0"
end
@raul
raul / set_request_headers.rb
Created November 27, 2010 11:33
Set request headers in Capybara+RackTest
# Patch to support customized request headers in your Capybara tests
# when you're using the RackTest driver, based on an Aslak Hellesøy's gist:
# https://gist.github.com/358664
#
# Please note that some drivers don't allow access to headers, see:
# https://github.com/jnicklas/capybara/issuesearch?state=closed&q=header#issue/17
class Capybara::Driver::RackTest < Capybara::Driver::Base
def env
var detectBackOrForward = function(onBack, onForward) {
hashHistory = [window.location.hash];
historyLength = window.history.length;
return function() {
var hash = window.location.hash, length = window.history.length;
if (hashHistory.length && historyLength == length) {
if (hashHistory[hashHistory.length - 2] == hash) {
hashHistory = hashHistory.slice(0, -1);
onBack();