This is a fairly common question, and there isn't a One True Answer.
These are the most common techniques:
# Gemfile | |
… | |
gem 'uuidtools' | |
… |
RSpec.configure do |config| | |
config.before(:suite) do | |
ActiveRecord::Base.establish_connection database['one'] | |
DatabaseCleaner.strategy = :deletion | |
ActiveRecord::Base.establish_connection config.database['two'] | |
DatabaseCleaner.strategy = :deletion | |
end | |
config.before(:each) do |
# WAIT! Do consider that `wait` may not be needed. This article describes | |
# that reasoning. Please read it and make informed decisions. | |
# https://www.varvet.com/blog/why-wait_until-was-removed-from-capybara/ | |
# Have you ever had to sleep() in Capybara-WebKit to wait for AJAX and/or CSS animations? | |
describe 'Modal' do | |
should 'display login errors' do | |
visit root_path |
#1 Install it (example of linking to RackSpace Cloud), ubuntu example | |
apt-get install duplicity | |
apt-get install python-setuptools | |
git clone git://github.com/rackspace/python-cloudfiles.git | |
python setup.py install | |
#2 Create a simple shell script (put this in a shell script) | |
export CLOUDFILES_USERNAME=YOURNAME | |
export CLOUDFILES_APIKEY=YOURKEY |
# | |
# WillPaginate renderer for will_paginate 2.3.16 to generate HTML code for Twitter Bootstrap | |
# Put this content in in your config/initializers/will_paginate.rb | |
module WillPaginate | |
module ViewHelpers | |
class BootstrapLinkRenderer < LinkRenderer | |
def to_html |
# Put this in Rakefile (doesn't matter where) | |
require 'benchmark' | |
class Rake::Task | |
def execute_with_benchmark(*args) | |
bm = Benchmark.measure { execute_without_benchmark(*args) } | |
puts " #{name} --> #{bm}" | |
end | |
alias_method :execute_without_benchmark, :execute |
/** | |
* Copyright 2012 Akseli Palén. | |
* Created 2012-07-15. | |
* Licensed under the MIT license. | |
* | |
* <license> | |
* Permission is hereby granted, free of charge, to any person obtaining | |
* a copy of this software and associated documentation files | |
* (the "Software"), to deal in the Software without restriction, | |
* including without limitation the rights to use, copy, modify, merge, |
module AllCacheKey | |
extend ActiveSupport::Concern | |
module ClassMethods | |
def cache_key | |
pluck("COUNT(*)", "MAX(updated_at)").flatten.map(&:to_i).join("-") | |
end | |
end | |
end |
# This is a skeleton for testing models including examples of validations, callbacks, | |
# scopes, instance & class methods, associations, and more. | |
# Pick and choose what you want, as all models don't NEED to be tested at this depth. | |
# | |
# I'm always eager to hear new tips & suggestions as I'm still new to testing, | |
# so if you have any, please share! | |
# | |
# @kyletcarlson | |
# | |
# This skeleton also assumes you're using the following gems: |