- Unit tests are very narrowly focused on testing a single model
- Functional tests are very narrowly focused on testing a single controller and the interactions between the models it employs
- Integration tests are broad story-level tests that verify the interactions between the various actions supported by the application, across all controllers
This file contains 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/acts_as_indexed.rb | |
ActsAsIndexed.configure do |config| | |
# Disable acts_as_indexed auto indexing in test by default | |
config.disable_auto_indexing = Rails.env.test? | |
end |
This file contains 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/active_record.rb | |
module ActiveRecord | |
class Base | |
# Find by array of IDs, preserving order of IDs | |
# See http://stackoverflow.com/a/25248122/83743 | |
def self.find_with_relevance(array_of_ids) | |
array_of_ids = Array(array_of_ids) unless array_of_ids.is_a?(Array) | |
self.find(array_of_ids).index_by(&:id).slice(*array_of_ids).values | |
end |
This file contains 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
# db/migrations/20140101000000_add_hstore_field_to_trip_tickets.rb | |
class AddHstoreFieldToTripTickets < ActiveRecord::Migration | |
def change | |
add_column :trip_tickets, :customer_identifiers, :hstore | |
end | |
end |
This file contains 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
source 'https://rubygems.org' | |
ruby '2.1.4' | |
gem 'rails', '~> 3.2.0' | |
gem 'mysql2' | |
group :development, :test do | |
gem 'byebug' |
This file contains 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
There is something to be learned from a rainstorm. | |
When meeting with a sudden shower, you try | |
not to get wet and run quickly along the road. | |
By doing such things as passing under the eaves | |
of houses, you still get wet. When you are | |
resolved from the beginning, you will not be | |
perplexed, though you will still get the same | |
soaking. This understanding extends to all things. | |
Ghost Dog, Chapter 22, T01:32:25 (quoted from: Hagakure: The Book of the Samauri) |
This file contains 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
task :write => :environment do | |
dir = RAILS_ROOT + '/db/backup' | |
FileUtils.mkdir_p(dir) | |
FileUtils.chdir(dir) | |
interesting_tables.each do |tbl| | |
sql ||= ActiveRecord::Base.connection() | |
if (records = sql.execute("SELECT * FROM " + tbl) rescue false) | |
puts "Writing #{tbl}..." |
This file contains 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
.ilb { | |
display: -moz-inline-box; | |
display: inline-block; | |
} |
This file contains 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
javascript:void(prompt('Result',function(){var a=window.getSelection().toString();if(a.indexOf("\n")>=0){a=a.split("\n");var b=0;for(var i=0;i<a.length;i++){b+=parseFloat(a[i])}}else b=parseFloat(a);return(isNaN(b))?0:b}())); |
This file contains 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
macosx:~ chrisb$ irb -rosx/cocoa | |
/opt/local/lib/ruby/1.8/osx/foundation.rb:8:in `require': no such file to load -- rubycocoa (LoadError) | |
from /opt/local/lib/ruby/1.8/osx/foundation.rb:8 | |
from /opt/local/lib/ruby/1.8/osx/cocoa.rb:8:in `require' | |
from /opt/local/lib/ruby/1.8/osx/cocoa.rb:8 | |
from /opt/local/lib/ruby/1.8/irb/init.rb:254:in `require' | |
from /opt/local/lib/ruby/1.8/irb/init.rb:254:in `load_modules' | |
from /opt/local/lib/ruby/1.8/irb/init.rb:252:in `each' | |
from /opt/local/lib/ruby/1.8/irb/init.rb:252:in `load_modules' | |
from /opt/local/lib/ruby/1.8/irb/init.rb:21:in `setup' |
OlderNewer