Skip to content

Instantly share code, notes, and snippets.

View motdotla's full-sized avatar
🏆

Mot motdotla

🏆
View GitHub Profile
require File.join( File.dirname(__FILE__), '..', "spec_helper" )
describe Stock do
it "should be valid when new" do
stock = Stock.new(:symbol => 'GOOG')
stock.should be_valid
end
it "should be invalid when symbol is empty" do
# http://www.peterryan.net/2007/08/08/bdd-model-validation-using-rspec-and-extensions-to-hash/
1. before(:each) do
2. @team = Team.new
3. end
4.
5. def valid_team
6. {
7. :name => "team name",
8. :contact_number => "call me here!",
it "should have comments" do
stock = Stock.create(:symbol => 'GOOG')
stock.comments << Comment.new(:body => "First comment")
stock.comments << Comment.new(:body => "Second comment")
stock.should have(2).comments
end
or
it "should have comments" do
render :update do |page|
div_id = "panel_"{var.id}"
div_id.to_sym
page[div_id].set_style...
# default rails environment to development
ENV['RAILS_ENV'] ||= 'development'
# require rails environment file which basically "boots" up rails for this script
require File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment')
require 'net/imap'
require 'net/http'
# mail.yml is the imap config for the email account (ie: username, host, etc.)
config = YAML.load(File.read(File.join(RAILS_ROOT, 'config', 'mail.yml')))
# default rails environment to development
ENV['RAILS_ENV'] ||= 'development'
# require rails environment file which basically "boots" up rails for this script
require File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment')
require 'net/imap'
require 'net/http'
# mail.yml is the imap config for the email account (ie: username, host, etc.)
config = YAML.load(File.read(File.join(RAILS_ROOT, 'config', 'mail.yml')))
\[Project:.*]
namespace :chores do
task :each_minute => :environment do
chore("Each minute") do
# our code will go here
end
end
task :hourly => :environment do
chore("Hourly") do
namespace :chores do
task :each_minute => :environment do
chore("Each minute") do
# our code will go here
end
end
task :hourly => :environment do
chore("Hourly") do
* * * * * RAILS_ENV=production rake -f <%= current_path %>/Rakefile chores:each_minute >> <%= deploy_to %>/shared/log/cron/each_minute.txt
00 * * * * RAILS_ENV=production rake -f <%= current_path %>/Rakefile chores:hourly >> <%= deploy_to %>/shared/log/cron/hourly.txt
01 0 * * * RAILS_ENV=production rake -f <%= current_path %>/Rakefile chores:daily >> <%= deploy_to %>/shared/log/cron/daily.txt
02 0 * * 1 RAILS_ENV=production rake -f <%= current_path %>/Rakefile chores:weekly >> <%= deploy_to %>/shared/log/cron/weekly.txt