Skip to content

Instantly share code, notes, and snippets.

# require 'webrat_ext'
module Webrat
module Methods
delegate_to_session :current_path
end
class Session
def current_path
URI.parse(current_url).path
end
class Hash
def intersection_equal?(other)
all? {|k, v| other.has_key?(k) ? other[k] == v : true }
end
end
#!/usr/bin/env ruby
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path(File.dirname(__FILE__) + "/../config/environment") unless defined?(RAILS_ROOT)
start_time = Time.now
puts "Starting CouchDB Benchmark..."
100000.times do |n|
Person.new(:first_name => "Couch_#{n}", :last_name => "Man_#{n}").save
end
puts (Time.now - start_time)
#!/usr/bin/env ruby
if ARGV.any? {|arg| %w[--drb -X --generate-options -G --help -h --version -v].include?(arg)}
require 'rubygems' unless ENV['NO_RUBYGEMS']
else
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path(File.dirname(__FILE__) + "/../config/environment") unless defined?(RAILS_ROOT)
end
start_time = Time.now
puts "Starting MongoDB Benchmark..."
100000.times do |n|
module AVCacheTTL
def self.included(base)
base.alias_method_chain :cache, :ttl
end
def cache_with_ttl(name = {}, options = nil, &block)
options = (options || {}).dup
return block.call if options.delete(:ignore_cache)
time = options.delete(:ttl)
time = time.from_now if time.respond_to?(:from_now)
Dir[File.dirname(__FILE__) + '/factories/*.rb'].each { |file| require file }