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 :sqlite do | |
desc "Backup sqlite3 database." | |
task :dump do | |
run "cp #{shared_path}/data/#{rails_env}.sqlite3 #{shared_path}/data/#{rails_env}_#{Time.now.strftime("%Y%m%d%H%M%S")}.sqlite3" | |
end | |
desc "Copy remote db file to local" | |
task :fetch, :roles => :db do | |
get "#{shared_path}/data/#{rails_env}.sqlite3", "./db/#{rails_env}_#{Time.now.strftime("%Y%m%d%H%M%S")}.sqlite3" | |
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
namespace :git do | |
desc "Create local git branch of current revision" | |
task :current do | |
system "git branch -lf #{stage} #{current_revision}" | |
system "git log --graph --decorate --pretty=oneline --abbrev-commit -30 #{stage}" | |
end | |
desc "[internal] Create release tag with current timestamp and push" | |
task :release_tag do | |
tag_name = "#{stage}_#{Time.now.strftime("%Y%m%d")}" |
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
str.gsub(/(\r\n|\n|\r)/,'<br />') |
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
# http://www.ruby-doc.org/core-1.9.3/Hash.html#method-i-values | |
# http://rxr.whitequark.org/rubinius/source/kernel/common/hash18.rb | |
class Hash | |
def deep_values | |
ary = [] | |
each_value do |value| | |
if value.is_a? Hash | |
ary += value.deep_values | |
elsif value.is_a? Array |
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
# Could be placed in spec_helper.rb | |
# Requiring foo.rake in this example. | |
def run_foo_bar(arg) | |
require 'rake' | |
@rake = Rake::Application.new | |
Rake.application = @rake | |
Rake.application.rake_require "lib/tasks/foo" | |
Rake::Task.define_task(:environment) | |
silence do |
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
# spec/support/detect_translation_missing.rb | |
module TranslationMissingDetector | |
module Capybara::Node::Finders | |
alias_method :find_original, :find | |
def find(*args) | |
begin | |
m = session.body.match(/translation[_ ]missing[^<]+/) | |
puts ["="*80, m[0], '', caller].join("\n")+"\n\n" if m |
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
# spec/support/selenium_chromedriver.rb | |
Capybara.register_driver :selenium do |app| | |
# http://code.google.com/p/chromedriver/downloads/list | |
# sudo mv ~/Downloads/chromedriver /usr/bin/ | |
Capybara::Selenium::Driver.new(app, :browser => :chrome) | |
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
# spec/support/bindaddress.rb | |
# Equivalent to $ rails server -b 127.0.0.1 | |
require 'webrick' | |
module Rack | |
module Handler | |
class WEBrick | |
def self.run(app, options={}) | |
options[:BindAddress] = '127.0.0.1' |
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
# selenium-webdriver (2.12.2) (with rails3) | |
def assert_confirmation(message, choice = 'ok') | |
if selenium? | |
assert_equal message, page.driver.browser.switch_to.alert.text | |
if choice == 'ok' | |
page.driver.browser.switch_to.alert.accept | |
elsif choice == 'cancel' | |
page.driver.browser.switch_to.alert.dismiss | |
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
diff --git a/config/boot.rb b/config/boot.rb | |
index dd5e3b6..9ee835a 100644 | |
--- a/config/boot.rb | |
+++ b/config/boot.rb | |
@@ -106,5 +106,19 @@ module Rails | |
end | |
end | |
+class Rails::Boot | |
+ def run |