This file contains hidden or 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
#!/usr/bin/env ruby | |
# Rotate rails logs with more flexibility than system logrotate | |
# requires logrotate gem and written for use with passenger | |
# can easily be adapted to mongrel | |
require 'fileutils' | |
require 'rubygems' | |
require 'logrotate' | |
This file contains hidden or 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
class CommentsController < CorporateBaseController | |
resource_controller | |
belongs_to :product_list | |
actions :only => [:create, :update, :destroy] | |
create.before do | |
raise @comment.inspect | |
end |
This file contains hidden or 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.should_delegate(*options) | |
klass = self.name.gsub(/Test$/, '').constantize | |
receiver = options.pop[:to] | |
context "#{klass}" do | |
setup do | |
klass.any_instance.stubs(receiver).returns(receiver_stub = stub) | |
options.each { |opt| receiver_stub.expects(opt) } | |
end |
This file contains hidden or 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
Code: | |
base.before_validation do |review| | |
review.design = review.moderation.design | |
end | |
Test: | |
it "validates presence of design_id" do | |
@review.should validate_presence_of(:design_id, @design.id) | |
end |
This file contains hidden or 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
ENV["RAILS_ENV"] = "test" | |
require File.expand_path('../../config/environment', __FILE__) | |
require 'rails/test_help' | |
Bundler.require(:shoulda) | |
class ActiveSupport::TestCase | |
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. | |
# | |
# Note: You'll currently still have to declare fixtures explicitly in integration tests |
This file contains hidden or 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
group :test do | |
gem 'rspec', '2.0.0.beta.11' | |
gem 'rspec-rails', '2.0.0.beta.11' | |
gem 'factory_girl', | |
:git => 'git://github.com/danielb2/factory_girl.git', | |
:branch => 'rails3' | |
end |
This file contains hidden or 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 Functional Test | |
def self.authorize_actions | |
[ | |
"get :index", | |
"get :new", | |
"get :edit, :id => 1", | |
"post :create", | |
"put :update, :id => 1", | |
"delete :destroy, :id => 1" |
This file contains hidden or 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 attr | |
self[:attr] || "Some Default" | |
end |
This file contains hidden or 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
class Float | |
def approx_equal?(other,threshold) | |
if (self-other).abs<threshold # "<" not exact either ;-) | |
return true | |
else | |
return false | |
end | |
end | |
end |
This file contains hidden or 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
Usage: rpm [-aKfgpWHqV] [-aKfgpWHqVcdils] [-aKfgpWHqVcdilsaKfgpWHqV] [-aKfgpWHqVcdilsaKfgpWHqV] [-aKfgpWHqVcdilsaKfgpWHqV] [-aKfgpWHqVcdilsaKfgpWHqVK] [-aKfgpWHqVcdilsaKfgpWHqVK] [-aKfgpWHqVcdilsaKfgpWHqVKi] [-aKfgpWHqVcdilsaKfgpWHqVKiv] [-aKfgpWHqVcdilsaKfgpWHqVKiv] [-aKfgpWHqVcdilsaKfgpWHqVKiv?] [-a|--all] [-f|--file] [-g|--group] | |
[-p|--package] [-W|--ftswalk] [--pkgid] [--hdrid] [--fileid] | |
[--specfile] [--triggeredby] [--whatrequires] [--whatprovides] | |
[--nomanifest] [-c|--configfiles] [-d|--docfiles] [--dump] [-l|--list] | |
[--queryformat=QUERYFORMAT] [-s|--state] [--nomd5] [--nofiles] | |
[--nodeps] [--noscript] [--comfollow] [--logical] [--nochdir] | |
[--nostat] [--physical] [--seedot] [--xdev] [--whiteout] | |
[--addsign] [-K|--checksig] [--delsign] [--import] [--resign] | |
[--nodigest] [--nosignature] [--initdb] [--rebuilddb] [--aid] | |
[--allfiles] [--allmatches] [--badreloc] [-e|--erase <package>+] |
OlderNewer