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
class IO | |
def readbytes(n) | |
str = read(n) | |
if str == nil | |
raise EOFError, "End of file reached" | |
end | |
if str.size < n | |
raise TruncatedDataError.new("data truncated", str) | |
end | |
str |
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
class RestfulActions | |
include Singleton | |
Action = Struct.new(:name, :method, :args) | |
@@actions = [] | |
[ | |
[:index, :get], | |
[:new, :get], | |
[:show, :get, {:id => 1}], |
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
# custom matchers to expect layouts | |
Spec::Matchers.define :use_layout do |layout| | |
match do |response| | |
response.layout == layout | |
end | |
failure_message_for_should do |employee| | |
"expected response to use layout named #{layout}" | |
end | |
failure_message_for_should_not do |employee| | |
"expected response to not use layout named #{layout}" |
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 File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | |
describe BabysittersController do | |
integrate_views | |
context "when not authenticated" do | |
RestfulActions.for(BabysittersController) do |action| | |
it "should redirect to root path when accessing ##{action.name}" do | |
send action.method, action.name, action.args | |
response.should redirect_to(root_path) |
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
# When deploying for the first time, use vlad:install before vlad:deploy | |
# 1) vlad:install will copy all files matching .sample* in deploy_to/shared/config | |
# 2) edit those files and rename them to their final name | |
# 3) each time you deploy with vlad:deploy, your config files will be symlinked in your application config folder | |
namespace :vlad do | |
def shared_config_path | |
shared_path + '/' + 'config' | |
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
Rake::Task.define_task(:environment) | |
load RAILS_ROOT + '/lib/tasks/seed.rake' | |
Rake.application['db:seed:load'].invoke |
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
module Keywordable | |
module ClassMethods | |
def keyword(symbol, proc) | |
write_inheritable_attribute :keywords, {} unless read_inheritable_attribute :keywords | |
read_inheritable_attribute(:keywords)[symbol] = proc | |
end | |
end | |
module InstanceMethods | |
def keywords |
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
# Autocomplete handler for all core controllers. | |
#---------------------------------------------------------------------------- | |
def auto_complete | |
@query = params[:auto_complete_query] | |
@auto_complete = hook(:auto_complete, self, :query => @query, :user => @current_user) | |
if @auto_complete.empty? | |
@auto_complete = self.controller_name.classify.constantize.my(:user => @current_user, :limit => 10).search(@query) | |
else | |
@auto_complete = @auto_complete.last | |
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 File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | |
describe Snapshot do | |
before(:each) do | |
@observer = PretendObserver.new(@string_io = StringIO.new("","w")) | |
end | |
it "should create a snapshot ready to be applied" do | |
Snapshot.new(:size => "4G", :path => '/dev/vg00/pwet-disk', :name => 'pwet') | |
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
Usine := Object clone do ( | |
DummyObject := Object clone do ( | |
Suite := Object clone do ( | |
variantName := nil | |
bodyBlock := nil | |
eval := method(x, | |
context := Object clone | |
context setSlot(variantName, x) |
OlderNewer