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 MyTestController < ApplicationController | |
def test_stuff | |
# bla | |
end | |
end | |
# Add to config/routes.rb... | |
# | |
# if Rails.env.test? | |
# map.connect '/:controller/:action/:id' |
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
$ ruby rack_proxy.rb | |
Loaded suite rack_proxy | |
Started | |
E | |
Finished in 0.004785 seconds. | |
1) Error: | |
test_foo(AppTest): | |
NoMethodError: undefined method `closed?' for nil:NilClass | |
/home/turnip/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/net/http.rb:1069:in `begin_transport' |
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
// Converts an ArrayBuffer directly to base64, without any intermediate 'convert to string then | |
// use window.btoa' step. According to my tests, this appears to be a faster approach: | |
// http://jsperf.com/encoding-xhr-image-data/5 | |
/* | |
MIT LICENSE | |
Copyright 2011 Jon Leighton | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
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
From 42a20533837e925030b07132eaf0a2a6534ad235 Mon Sep 17 00:00:00 2001 | |
From: Jon Leighton <[email protected]> | |
Date: Fri, 13 May 2011 20:03:57 +0100 | |
Subject: [PATCH] Unfailing test case | |
--- | |
.../has_many_through_associations_test.rb | 21 ++++++++++++++++++++ | |
activerecord/test/schema/schema.rb | 11 ++++++++++ | |
2 files changed, 32 insertions(+), 0 deletions(-) |
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 'benchmark' | |
class Object | |
def public_send_public_method_defined(method, *args, &block) | |
singleton_class = (class << self; self; end) | |
if singleton_class.public_method_defined?(method) | |
send(method, *args, &block) | |
else | |
raise # this doesn't matter, as it's not the path we're benchmarking |
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
# 1.9.2 | |
Rehearsal ------------------------------------------------------- | |
no-send 1.950000 0.000000 1.950000 ( 1.961587) | |
symbol-send 2.190000 0.000000 2.190000 ( 2.192600) | |
string-send 4.790000 0.000000 4.790000 ( 4.812341) | |
---------------------------------------------- total: 8.930000sec | |
user system total real | |
no-send 2.330000 0.000000 2.330000 ( 2.332294) |
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 'active_record' | |
require 'logger' | |
puts "Active Record #{ActiveRecord::VERSION::STRING}" | |
ActiveRecord::Base.establish_connection( | |
:adapter => 'mysql', | |
:user => 'root', | |
:database => 'test' | |
) |
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
# encoding: utf-8 | |
def λ(&block) | |
block | |
end | |
I = λ { |x| x } | |
I.(3) # => 3 |
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
##### Pointless: ##### | |
# Bad: | |
Foo.new.tap do |foo| | |
foo.bar = "<3" | |
end | |
# Good: | |
foo = Foo.new | |
foo.bar = "<3" |
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 A | |
def foo | |
"<3" | |
end | |
end | |
class B < A | |
def foo | |
# super will still call A#foo, even after the method is aliased | |
super * 2 |
OlderNewer