A clean workaround for running capybara tests on Rails with assets pipeline enabled.
Original: teamcapybara/capybara#500 (comment)
RSpec.configure do |config| | |
config.around do |example| | |
# For examples using capybara-webkit for example. | |
# Remove this if you don't use it or anything similar | |
if example.metadata[:js] | |
example.run | |
ActiveRecord::Base.connection.tables.each do |table| | |
ActiveRecord::Base.connection.execute("TRUNCATE TABLE #{table};") | |
end |
# https://gist.github.com/1623632 | |
# bundler bootstrap | |
require 'bundler/capistrano' | |
# main details | |
set :application, "123" | |
role :web, "#{application}.cloud.voupe.net" # #{application}.cloud.voupe.net | |
role :app, "#{application}.cloud.voupe.net" | |
role :db, "#{application}.cloud.voupe.net", :primary => true |
# Add these two gems | |
gem 'ice_cube', '0.9.3' | |
gem 'squeel', '1.0.16' |
# app/models/user.rb | |
class User < ActiveRecord::Base | |
validates :zipcode, presence: true, zipcode: true | |
end |
on appIsRunning(appName) | |
tell application "System Events" to (name of processes) contains appName | |
end appIsRunning | |
on execInItermTab(_terminal, _session, _command) | |
tell application "iTerm" | |
activate | |
set current terminal to _terminal | |
tell _session | |
select _session |
require 'delegate' | |
class Base | |
def foo | |
"foo" | |
end | |
def bar | |
"bar" | |
end | |
end |
// Slick little method to create a bitmask from an array of boolean values. (for Javascript) | |
function bitMask(a, b) { | |
var m = 0, i; | |
if (b !== undefined) { a = Array.prototype.slice.apply(arguments); } | |
for (i = 0; i < a.length; i += 1) { | |
if (a[i] !== false) { m += Math.pow(2, i) }; | |
} | |
return m; |
A clean workaround for running capybara tests on Rails with assets pipeline enabled.
Original: teamcapybara/capybara#500 (comment)
module Abilities | |
def self.ability_for(user) | |
if user.admin? | |
AdminAbility.new(user) | |
else user | |
MemberAbility.new(user) | |
else | |
GuestAbility.new | |
end | |
end |
# Parses YouTube URLs directly or from iframe code. Handles: | |
# * Address bar on YouTube url (ex: http://www.youtube.com/watch?v=ZFqlHhCNBOI) | |
# * Direct http://youtu.be/ url (ex: http://youtu.be/ZFqlHhCNBOI) | |
# * Full iframe embed code (ex: <iframe src="http://www.youtube.com/embed/ZFqlHhCNBOI">) | |
# * Old <object> tag embed code (ex: <object><param name="movie" value="http://www.youtube.com/v/ZFqlHhCNBOI">...) | |
/(youtu\.be\/|youtube\.com\/(watch\?(.*&)?v=|(embed|v)\/))([^\?&"'>]+)/ | |
$5 #=> the video ID | |
# test it on Rubular: http://rubular.com/r/eaJeSMkJvo |