This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'spork' | |
#uncomment the following line to use spork with the debugger | |
#require 'spork/ext/ruby-debug' | |
Spork.prefork do | |
# Loading more in this block will cause your tests to run faster. However, | |
# if you change any configuration or code from libraries loaded here, you'll | |
# need to restart spork for it take effect. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Default | |
Hoge.any_instance.stub(:save).and_return(false) | |
Hoge.any_instance.should_receive(:update_attributes).with({'these' => 'params'}) | |
# mocha | |
Hoge.any_instance.stubs(:save).returns(false) | |
Hoge.any_instance.expects(:update_attributes).with({'these' => 'params'}) | |
# spec_helper for mocha | |
RSpec.configure do |config| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
recipes: | |
- action_mailer | |
- active_admin | |
- activerecord | |
- add_user | |
- capybara | |
- cleanup | |
- devise | |
- extras | |
- git |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/setup_email.rb | |
if Rails.env.development? | |
ActionMailer::Base.default_url_options[:host] = "localhost:3000" | |
ActionMailer::Base.smtp_settings = { | |
:address => "localhost", | |
:port => 1025, | |
:domain => "localhost" | |
} | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module CapybaraExtension | |
def drag_by(right_by, down_by) | |
base.drag_by(right_by, down_by) | |
end | |
end | |
module CapybaraSeleniumExtension | |
def drag_by(right_by, down_by) | |
resynchronize { driver.browser.action.drag_and_drop_by(native, right_by, down_by).perform } | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### config/environments/test.rb | |
... | |
# Add assets settings to be identical to production env | |
# Using | |
if ENV['ASSETS'] | |
puts "ENV['ASSETS'] is given. Set asset pipeling configurations." | |
# Compress JavaScripts and CSS | |
config.assets.compress = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :log do | |
desc "tail production log files" | |
task :tail, :roles => :app do | |
run "tail -fn 100 #{shared_path}/log/#{rails_env}.log" do |channel, stream, data| | |
trap("INT") { puts 'Interupted'; exit 0; } | |
puts # for an extra line break before the host name | |
puts "#{channel[:host]}: #{data}" | |
break if stream == :err | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ruby 1.8.7 | |
def show_capistrano_variables(exec_proc = false) | |
report = [] | |
require 'active_support/ordered_hash' | |
require 'active_support/core_ext/hash/keys' | |
report << "="*20 + " @variables " + "="*20 | |
ActiveSupport::OrderedHash.new.merge(instance_variable_get("@variables")).stringify_keys.sort.each do |k,v| | |
next if %w{password}.include?(k) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# [NOTE!] namespace :rake cannot be used because 'rake' is already used as capistrano variable. | |
# #{rake} will be #<Capistrano::Configuration::Namespaces::Namespace:0x103abdf48> and command will abort if namespace :rake is used. | |
namespace :raketask do | |
desc "Show available rake tasks($ cap staging raketask:show_tasks)." | |
task :show_tasks do | |
run "cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} -T" | |
end | |
desc "Run a task on a remote server($ cap staging raketask:invoke task=a_certain_task)." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Deploy tasks for Passenger | |
namespace :deploy do | |
desc "Restarting mod_rails with restart.txt" | |
task :restart, :roles => :app, :except => { :no_release => true } do | |
run "touch #{current_path}/tmp/restart.txt" | |
end | |
[:start, :stop].each do |t| | |
desc "#{t} task is a no-op with mod_rails" | |
task t, :roles => :app do ; end |