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
Loaded suite test/unit/feature_test | |
Started | |
/Users/light/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/minitest/unit.rb:725:in `sort_by': comparison of String with nil failed (ArgumentError) | |
from /Users/light/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/minitest/unit.rb:725:in `test_suites' | |
from /Users/light/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/minitest/unit.rb:634:in `run_test_suites' | |
from /Users/light/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/minitest/unit.rb:594:in `run' | |
from /Users/light/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/minitest/unit.rb:492:in `block in autorun' |
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
require 'rubygems' | |
require 'redis' | |
r = Redis.new | |
r.flushdb | |
42.times { |i| r.lpush "nums", i } | |
42.times { |i| r.set "weight_#{i}", i * 2 + 1 } | |
42.times { |i| r.set "weight2_#{i}", i * 4 + 3 } | |
42.times { |i| r.set "weight3_#{i}", i * 8 + 5 } |
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 conditionally_cache(key, args = {}, &block) | |
positive, negative = args[:if], args[:unless] | |
fail "Must supply at most one of :if or :unless" if positive && negative | |
if (positive && positive.call(key)) || (negative && !negative.call(key)) | |
Rails.logger.debug "BENCH: cache hit, #{key.cache_key}" | |
cache(key, &block) | |
else | |
Rails.logger.debug "BENCH: NOT cache hit, #{key.cache_key}" | |
yield |
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
# Copy/paste of simple_format from Rails but with <p> removed. | |
def simpler_format(text, html_options={}, options={}) | |
text = text ? String.new(text) : '' | |
text = sanitize(text) unless options[:sanitize] == false | |
text = text.gsub(/\r\n?/, "\n") | |
text.gsub!(/\n\n+/, "<br /><br />") | |
text.gsub!(/\n/, "<br />") | |
text.concat!("<br />") | |
text.html_safe | |
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
gem uninstall actionmailer actionpack activemodel activerecord activeresource activesupport railties |
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
ruby-1.9.2-p180-patched :016 > Time.zone = "UTC" | |
=> "UTC" | |
ruby-1.9.2-p180-patched :017 > Post.find(514).cache_key | |
=> "posts/514-20110713185059" | |
ruby-1.9.2-p180-patched :018 > Time.zone = User.last.time_zone | |
=> "Eastern Time (US & Canada)" | |
ruby-1.9.2-p180-patched :019 > Time.zone = "Eastern Time (US & Canada)" | |
=> "Eastern Time (US & Canada)" | |
ruby-1.9.2-p180-patched :020 > Post.find(514).cache_key | |
=> "posts/514-20110713145059" |
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 test_cache_key_for_existing_record_is_not_timezone_dependent | |
p Time.zone | |
Time.zone = "UTC" | |
p Time.zone | |
p Developer.find(1) | |
utc_key = Developer.find(1).cache_key | |
p utc_key | |
ActiveRecord::Base.connection.clear_query_cache |
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 | |
CHARACTERS = (('A'..'Z').to_a + ('a'..'z').to_a + (0..9).to_a) | |
GROUP = 53 | |
def ridiculous_password | |
(1..20).map do | |
CHARACTERS[rand(CHARACTERS.length)] | |
end.join | |
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
# Based on the discussion here: https://github.com/aiwilliams/dataset/issues/3 | |
# Used to optimized the datasets being created in your tests. | |
# Currently works in a test suite for a production app with Postgresql | |
# | |
# TODO | |
# - gemify | |
# - add tests | |
# - be able to reuse datasets accross files (declare them in a shared context) | |
# - support other databases than postgres | |
# - file access optimization (only read once during a test run) |
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
***************************************************************** | |
DEPRECATION WARNING: you are using deprecated behaviour that will | |
be removed from RSpec 3. | |
You have set some configuration options after an example group has | |
already been defined. In RSpec 3, this will not be allowed. All | |
configuration should happen before the first example group is | |
defined. The configuration is happening at: | |
/Users/evan/.rvm/gems/ruby-1.9.2-p290@rubypair/gems/rspec-rails-2.6.1/lib/rspec/rails.rb:3:in `<top (required)>' |