Skip to content

Instantly share code, notes, and snippets.

#in my step definitions
Then /^I should see in this order the following elements:$/ do |table|
matched_vals = response.body =~ Regexp.new(table.raw.join(".*"), Regexp::MULTILINE)
assert !matched_vals.nil?
end
#in my feature:
Then I should see in this order the following elements:
| primo |
puts 'toto'
def titi
end
[
"Alsace",
"Aquitaine",
"Auvergne",
"Basse-Normandie",
"Bourgogne",
"Bretagne",
"Centre",
"Champagne-Ardenne",
"Corse",
gem install ruby-debug19 -- --with-ruby-include=/Users/thibaut/.rvm/src/ruby-1.9.1-p378
@tibastral
tibastral / store_redirect_to.rb
Created May 8, 2011 22:21
omniauth redirect back to
class StoreRedirectTo
def initialize(app)
@app = app
end
def call(env)
request = Rack::Request.new(env)
path = request.path
signin = path.match(%r(^/auth/[^/]+$)) && path != '/auth/failure'
signout = path == '/users/signout'
if signin || signout
@tibastral
tibastral / sessions_controller.rb
Created May 8, 2011 22:25
omniauth session controller
class SessionsController < ApplicationController
def create
auth = request.env["omniauth.auth"]
user = User.find_by_provider_and_uid(auth["provider"], auth["uid"])
user ||= User.create_with_omniauth(auth)
session[:user_id] = user.id
redirect_to [:dashboard, user]
end
def destroy
@tibastral
tibastral / hotspots.rb
Created February 27, 2012 16:36
I love capybara_webkit
When /^I create a new "([^"]*)" hotspot$/ do |hotspot_type|
click_link "Hotspots"
page.find(:css, "a[data-hotspot-type=\"#{hotspot_type.camelize}Hotspot\"]").click
end
Before('@omniauth_test') do
OmniAuth.config.test_mode = true
end
After('@omniauth_test') do
OmniAuth.config.test_mode = false
end
@tibastral
tibastral / ab.rb
Created September 19, 2012 12:47
Fixes for Apache AB for Mountain Lion
require 'formula'
class Ab < Formula
homepage 'http://httpd.apache.org/docs/trunk/programs/ab.html'
url 'http://www.apache.org/dist/httpd/httpd-2.4.3.tar.bz2'
sha1 '0ef1281bb758add937efe61c345287be2f27f662'
depends_on 'pcre'
depends_on 'libtool'