I hereby claim:
- I am timocratic on github.
- I am timocratic (https://keybase.io/timocratic) on keybase.
- I have a public key whose fingerprint is 7E07 1867 9F3F 2174 FA58 27C5 B405 8899 5CD3 22B9
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
# If you return self you have either mutated self, mutated something else (essentially global, even worse) | |
# or thrown away the change as a NOOP. Let's play with examples? |
namespace :db do | |
task :migrate => :clear_load_paths do | |
Dependencies.load_paths = @old_load_paths | |
end | |
task :clear_load_paths do | |
@old_load_paths = Dependencies.load_paths | |
Dependencies.load_paths = [] | |
end | |
end |
def Object.method_defined_where(method) | |
self.ancestors.detect { |a| a.methods(false).include?(method.to_s) } | |
end | |
#Usage - define in your .irbrc and then: | |
#File.method_defined_where('read') | |
#=> IO | |
#Alternatively it has been added to my copy of utility_belt: http://github.com/timocratic/utility-belt/commit/74397c4f8be135cf46f65ca509ddb90e2e47799e | |
def foo(value) | |
"#{value}foo" | |
end | |
[1,2].map &method(:foo) | |
#=> ["1foo", "2foo"] | |
def foo(value) | |
"#{value[0]}foo" | |
end | |
[[1,2],[3,4]].map &method(:foo) |
test = Rake::Task['test'] | |
test.clear | |
desc 'Run all units, functionals, integration, libs' | |
task :test do | |
run_sets_of_tests(%w(test:units test:functionals test:integration test:libs)) | |
end |
#stolen from http://pastie.org/395671 twitter:@seacreature. Just repo'ed here so I can find it again | |
require "irb" | |
IRB.setup(nil) | |
IRB.conf[:MAIN_CONTEXT] = IRB::Context.new(IRB::Irb.new) | |
require "irb/ext/multi-irb" | |
IRB.irb(nil,binding) |
class RspecInTU | |
class << self | |
alias it define_method | |
end | |
it "should say hello" do | |
puts "hello" | |
end | |
end | |
RspecInTU.new.send "should say hello" |
#Or just check-out: http://github.com/timocratic/test_benchmark/tree/master | |
#It's only one file too: http://github.com/timocratic/test_benchmark/blob/832b2217451b49ed218d2db31dfad2b81a2399eb/lib/test_benchmark.rb | |
#Go ahead and steal anything you want from it - or even better fork it and add what features you like |