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 "spec_helper" | |
describe "any_instance in mocha" do | |
it "should bar" do | |
Array.any_instance.stubs(:foo).returns(1) | |
[].foo.should eq(1) # Every instance of Array seems to be | |
[].foo.should eq(1) # stubbed (as one would expect) | |
end | |
it "should foo" do |
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
e = Exception.new | |
puts e.message # "Exception" | |
def e.backtrace | |
[] | |
end | |
puts e.message # "Exception" on 1.8.6/1.8.7/1.9.2, #<Class:0x11dff2e1b> on JRuby 1.6.0 |
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 https://github.com/rspec/rspec-core/issues/195 | |
# and patched (unsuccessfully on JRuby) in https://github.com/rspec/rspec-core/issues/295 | |
String.send :alias_method, :to_int, :to_i | |
puts File.readlines(__FILE__).empty? # is false on 1.8 and 1.9, true on JRuby 1.6.0 |
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
Seems that I have been held, in some dreaming state | |
A tourist in the waking world, never quite awake | |
No kiss, no gentle word could wake me from this slumber | |
Until I realise that it was you who held me under | |
Felt it in my fist, in my feet, in the hollows of my eyelids | |
Shaking through my skull, through my spine and down through my ribs | |
No more dreaming of the dead as if death itself was undone | |
No more calling like a crow for a boy, for a body in the garden |
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
~ λ rvm jruby-head | |
~ λ ruby -v | |
jruby 1.6.0.dev (ruby 1.8.7 patchlevel 249) (2011-01-13 b9f8624) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_22) [darwin-x86_64-java] | |
~ λ irb | |
jruby-head :001 > {:a => :b, :c => :d}.select{true} | |
=> [[:a, :b], [:c, :d]] | |
jruby-head :002 > {:a => :b, :c => :d}.select{true} | |
=> [[:a, :b], [:c, :d]] | |
jruby-head :003 > {:a => :b, :c => :d}.select{true} | |
=> [[:a, :b], [:c, :d]] |
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
FooNamespace.Routes = { | |
myResourcePath: function(){ return '<%= my_resource_path(:format => 'json') %>' } | |
} |
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
The first myth of management is that it exists. Managers are to management as churches are to religion. |
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-1.8.7-p174 > u = URI.parse('http://foo:bar@localhost:3000') | |
=> #<URI::HTTP:0x101e2bc40 URL:http://foo:bar@localhost:3000> | |
ruby-1.8.7-p174 > u.user=nil | |
=> nil | |
ruby-1.8.7-p174 > u | |
=> #<URI::HTTP:0x101e2bc40 URL:http://localhost:3000> | |
ruby-1.8.7-p174 > u.to_s | |
=> "http://localhost:3000" |
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
IO.popen('pbcopy', "w").tap{|io| io.write "some string"}.close |
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 'net/http' | |
module Net | |
class HTTP | |
def self.enable_debug! | |
raise "You don't want to do this in anything but development mode!" unless Rails.env == 'development' | |
class << self | |
alias_method :__new__, :new | |
def new(*args, &blk) | |
instance = __new__(*args, &blk) | |
instance.set_debug_output($stderr) |