This gist illustrates how you would add Google Analytics tracking into your Rails mailers. Add the tracking_interceptor.rb
into your path and enable it for your mailers with:
register_interceptor TrackingInterceptor
require "spec_helper" | |
describe ExampleMailer do | |
describe :new_user do | |
let(:user) { FactoryGirl.create :user } | |
it "sends to the correct addresses" do | |
# :mail is similar to the controller specs 'get', 'post' etc methods | |
mail :new_user, user |
# Gemfile | |
gem 'kramdown' |
def solution(instructions) | |
position = [0,0] | |
directions = [ | |
[0,1], # north | |
[1,0], # east | |
[0,-1], # south | |
[-1,0] # west | |
] | |
current_dir = 0; | |
history = [] |
This gist illustrates how you would add Google Analytics tracking into your Rails mailers. Add the tracking_interceptor.rb
into your path and enable it for your mailers with:
register_interceptor TrackingInterceptor
class ActiveRecord::Base | |
def self.import!(record_list) | |
raise ArgumentError "record_list not an Array of Hashes" unless record_list.is_a?(Array) && record_list.all? {|rec| rec.is_a? Hash } | |
return record_list if record_list.empty? | |
(1..record_list.count).step(1000).each do |start| | |
key_list, value_list = convert_record_list(record_list[start-1..start+999]) | |
sql = "INSERT INTO #{self.table_name} (#{key_list.join(", ")}) VALUES #{value_list.map {|rec| "(#{rec.join(", ")})" }.join(" ,")}" | |
self.connection.insert_sql(sql) |
source "https://rubygems.org" | |
gem "sinatra" | |
gem "haml" | |
gem "rsvg2" |
This list is based on aliases_spec.rb.
You can see also Module: RSpec::Matchers API.
matcher | aliased to | description |
---|---|---|
a_truthy_value | be_truthy | a truthy value |
a_falsey_value | be_falsey | a falsey value |
be_falsy | be_falsey | be falsy |
a_falsy_value | be_falsey | a falsy value |
namespace :db do | |
desc "Backs up heroku database and restores it locally." | |
task import_from_heroku: [ :environment, :create ] do | |
HEROKU_APP_NAME = nil # Change this if app name is not picked up by `heroku` git remote. | |
c = Rails.configuration.database_configuration[Rails.env] | |
heroku_app_flag = HEROKU_APP_NAME ? " --app #{HEROKU_APP_NAME}" : nil | |
Bundler.with_clean_env do | |
puts "[1/4] Capturing backup on Heroku" | |
`heroku pg:backups capture DATABASE_URL#{heroku_app_flag}` |
class ActiveRecord::Base | |
def self.import!(record_list) | |
raise ArgumentError 'record_list not an Array of Hashes' unless record_list.is_a?(Array) && record_list.all? {|rec| rec.is_a? Hash } | |
return if record_list.empty? | |
record_list.in_groups_of(1000, false).each do |record_group| | |
key_list, value_list = convert_record_list(record_group) | |
sql = "INSERT INTO #{self.table_name} (#{key_list.join(', ')}) VALUES #{value_list.map {|rec| "(#{rec.join(', ')})" }.join(' ,')}" | |
self.connection.insert_sql(sql) |
$enable_tracing = false | |
#$trace_out = File.open(Rails.root + 'trace.txt', 'w') | |
set_trace_func proc { |event, file, line, id, binding, classname| | |
if $enable_tracing && event == 'call' | |
#$trace_out.puts "#{file}:#{line} #{classname}##{id}" | |
raise "crash me" if caller_locations.length > 500 | |
end | |
} |