gem install rails --pre
rails new my_app -T
require 'xamltools.rb' | |
require 'PresentationFramework' | |
class ViewModel | |
attr :greeting, true | |
def initialize(greet) | |
@greeting = greet | |
end | |
end |
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com | |
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below) | |
module Player | |
describe MovieList, "with optional description" do | |
it "is pending example, so that you can write ones quickly" | |
it "is already working example that we want to suspend from failing temporarily" do | |
pending("working on another feature that temporarily breaks this one") |
after "deploy:symlink", "deploy:restart_workers" | |
## | |
# Rake helper task. | |
# http://pastie.org/255489 | |
# http://geminstallthat.wordpress.com/2008/01/27/rake-tasks-through-capistrano/ | |
# http://ananelson.com/said/on/2007/12/30/remote-rake-tasks-with-capistrano/ | |
def run_remote_rake(rake_cmd) | |
rake_args = ENV['RAKE_ARGS'].to_s.split(',') | |
cmd = "cd #{fetch(:latest_release)} && #{fetch(:rake, "rake")} RAILS_ENV=#{fetch(:rails_env, "production")} #{rake_cmd}" |
require 'spork' | |
ENV["RAILS_ENV"] = 'test' | |
Spork.prefork do | |
require "rails/application" | |
Spork.trap_method(Rails::Application, :reload_routes!) | |
require File.expand_path("../../config/environment", __FILE__) |
# acceptance/acceptance_helper.rb | |
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") | |
# Put your acceptance spec helpers inside /spec/acceptance/support | |
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} |
def tip(msg); puts; puts msg; puts "-"*100; end | |
# | |
# 30 Ruby 1.9 Tips, Tricks & Features: | |
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/ | |
# | |
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2" | |
tip "Ruby 1.9 supports named captures in regular expressions!" |
require File.expand_path(File.dirname(__FILE__) + '/request_helper') | |
feature "Show User Photos Feature", %q{ | |
In order to vote in friends photos | |
As an User | |
I want to see the photos of my friends | |
} do | |
background do | |
stub_facebook_profile |
# Simple JOIN | |
User.joins(:account) # User -> Account | |
# Will produce | |
# SELECT `users`.* FROM `users` INNER JOIN `accounts` ON `accounts`.`user_id` = `users`.`id` | |
# Complicated JOIN | |
Trait.joins(:user => :account) # Trait -> User -> Account | |
# Will produce | |
# SELECT `traits`.* FROM `traits` INNER JOIN `users` ON `users`.`id` = `traits`.`user_id` INNER JOIN `accounts` ON `accounts`.`user_id` = `users`.`id` |
#!/usr/bin/env ruby | |
mount = '/Volumes/ramdisk' | |
newfs = '/dev/disk1' | |
if !ARGV.empty? and ARGV.first =~ /^-+u$/i | |
system "umount #{mount} && hdiutil detach #{newfs}" | |
else | |
if File.exists? newfs | |
STDERR.puts "already mounted - #{mount}" | |
STDERR.puts "use \"#{$0.split('/').last} -u\"" |