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 --version | |
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0] | |
➜ ruby respond_to_missing.rb | |
Using #method works: | |
foo_bar | |
But #method_defined? doesn't: | |
method defined: false | |
And Module#instance_method raises a NameError: | |
respond_to_missing.rb:20:in `instance_method': undefined method `foo_bar' for class `Foo' (NameError) | |
from respond_to_missing.rb:20:in `<main>' |
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 --version | |
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0] | |
$ ruby shallow_exceptions.rb | |
Exception handled: shallow exception | |
shallow_exceptions.rb:13:in `raise_shallow_exception': deep exception (StandardError) | |
from shallow_exceptions.rb:17:in `raise_deep_exception' | |
from shallow_exceptions.rb:27:in `try_handle_deep_exception' | |
from shallow_exceptions.rb:34:in `<main>' |
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
# A sample Gemfile | |
source "https://rubygems.org" | |
gem "rspec", '2.9.0' |
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
#!/bin/sh | |
set -e | |
TIMEFMT='%*E' | |
runtime=$(((bundle install --standalone && time rspec spec/acceptance/silo_spec.rb -e 'end-to-end') | tail -0) 2>&1) | |
ms=$(echo $runtime | ruby -e "puts Integer(Float(gets) * 1000)") |
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
for for_i in [1, 2, 3] | |
end | |
puts "Variable from for: #{for_i.inspect}" | |
[1, 2, 3].each do |each_i| | |
end | |
puts "Variable from each: #{each_i.inspect}" |
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
TriangleError = Class.new(ArgumentError) | |
Triangle = Struct.new(:x, :y, :z) do | |
def initialize(*args) | |
super | |
validate | |
end | |
def type | |
TYPES.fetch(uniq_side_lengths) |
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
module Silo | |
module Client | |
extend self | |
def configuration | |
@configuration ||= Configuration.new | |
end | |
def configure |
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 'net/http' | |
response = Net::HTTP.start("httpstat.us") { |http| http.get("/204") } | |
puts "Body is: #{response.body.inspect}" |
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
➜ rspec return_spec.rb --format doc | |
A | |
1 | |
2 (FAILED - 1) | |
B | |
3 | |
4 |
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
source :rubygems | |
gem "rspec", :git => "git://github.com/rspec/rspec.git" | |
gem "rspec-core", :git => "git://github.com/rspec/rspec-core.git" | |
gem "rspec-expectations", :git => "git://github.com/rspec/rspec-expectations.git" | |
gem "rspec-mocks", :git => "git://github.com/rspec/rspec-mocks.git" | |