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
#rvm use 1.9.2 | |
#brew install mongo | |
#gem install mongo_mapper | |
#gem install bson_ext | |
require 'rubygems' | |
require 'mongo_mapper' | |
MongoMapper.database = 'mm_demo' |
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
# RSpec's subject method, both implicitly and explicitly set, is useful for | |
# declaratively setting up the context of the object under test. If you provide a | |
# class for your describe block, subject will implicitly be set to a new instance | |
# of this class (with no arguments passed to the constructor). If you want | |
# something more complex done, such as setting arguments, you can use the | |
# explicit subject setter, which takes a block. | |
describe Person do | |
context "born 19 years ago" do | |
subject { Person.new(:birthdate => 19.years.ago } | |
it { should be_eligible_to_vote } |
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
<!-- keep IE in quirks mode --> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<!-- This following meta tag does no good since there is no way to trigger quirks | |
mode only in IE7. The problems with an xml prolog that triggered quirks mode were | |
fixed in IE7, but this meta tag was not yet introduced, so the only thing you can do | |
is trigger IE-wide quirks via the comment before the DOCTYPE //--> | |
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" /> | |
<style type="text/css"> |
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
def self.logger | |
@logger ||= begin | |
(defined?(Rails) && Rails.logger) || | |
(defined?(RAILS_DEFAULT_LOGGER) && RAILS_DEFAULT_LOGGER) || | |
default_logger | |
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
#In case it wasn't obvious, this was a joke about Rails anti-patterns | |
def address(separator, seperator2=' ') | |
fields_array = %w(address1 address2 city state zip phone).map {|t| [:billing,t].join('_').to_sym} | |
(0..10).inject("") { |string, i| | |
if i.odd? | |
field = :separator | |
field = (field.to_s + '2').intern if i == 7 | |
else | |
field = fields_array[i/2] | |
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
def address(separator, seperator2=' ') | |
fields_array = %w(address1 address2 city state zip phone).map {|t| [:billing,t].join('_').to_sym} | |
(0..10).inject("") { |string, i| | |
if i.odd? | |
field = :seperator | |
field = (field.to_s + '2').intern if i == 7 | |
else | |
field = fields_array[i/2] | |
end | |
temp = send(field) rescue nil |
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
def address(separator, seperator2=' ') | |
fields_array = [:billing_address1, :billing_address2, :billing_city, :billing_state, :billing_zip, :billing_phone] | |
(0..10).inject("") { |string, i| | |
if i.odd? | |
field = :seperator | |
field = (field.to_s + '2').intern if i == 7 | |
else | |
field = fields_array[i/2] | |
end | |
temp = send(field) rescue nil |
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
def address(separator) | |
"#{billing_address1}#{separator}#{billing_address2}#{separator}#{billing_city}#{separator}#{billing_state} #{billing_zip}#{separator}#{billing_phone}" | |
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
require "test_helper" | |
require "yaml" | |
class FixtureTest < ActiveSupport::TestCase | |
fixtures :all | |
Dir[File.join Rails.root, "test", "fixtures", "**", "*.yml"].each do |file| | |
if fixtures = YAML.load(IO.read(file)) | |
kind = File.basename file, ".yml" |
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
if a3 | |
name, params, ret = a1, a1, a2 | |
else | |
name, params, ret = nil, a2, a3 | |
end | |