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
# Sample custom rake-like command supporting three options. | |
# | |
# mycmd start | |
# mycmd stop | |
# mycmd restart | |
require 'rake' | |
Rake.application.init('mycmd') |
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 RSpec::Matchers | |
matcher :be_a_bad_triangle do |expected| | |
match do |sides| | |
begin | |
TriangleClassifier.new.classify(*sides) | |
false | |
rescue ArgumentError => ex | |
true | |
end | |
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
# My take on Mike's source_for method. | |
# (see http://pragmaticstudio.com/blog/2013/2/13/view-source-ruby-methods) | |
# | |
# (1) I named it 'src' rather than source_for (ok, I'm a lazy typer). | |
# (2) The edit function was broken out as a separate function. | |
# (3) The edit function is for emacs | |
# (4) If the method is not defined on the object, and the object | |
# is a class, then see if it is an instance method on the class. | |
# | |
# The fourth point allows my to say: |
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 -fd thing_spec.rb | |
thing | |
matches thing a | |
Then { subject.should include thing } | |
matches thing b | |
Then { subject.should include thing } | |
matches thing c | |
Then { subject.should include thing } | |
matches thing d |
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
# Sample Rakefile for the Digispark/Arduino build script | |
require './arduino' | |
# Create an arduino builder | |
Avr = Rake::Arduino.new do |cfg| | |
# There are lots of configuration options, but I don't know | |
# yet what ones will survive. At the very least you must | |
# specify the location of the of the Arduino IDE application | |
# that comes with the special DigiSpark support. |
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
class ApproximateNumber | |
attr_reader :number, :delta | |
def initialize(number, delta) | |
@number = number | |
@delta = delta | |
end | |
def ==(value) | |
(number-value).abs <= delta |
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
1) Natural Assertions | |
Failure/Error: Then { foo + bar == 2 } | |
Then expression failed at /Users/jim/working/git/rspec-given/examples/failing/sample_spec.rb:6 | |
expected: 3 | |
to equal: 2 | |
false <- foo + bar == 2 | |
3 <- foo + bar | |
1 <- foo | |
2 <- bar | |
# ./lib/rspec/given/extensions.rb:64:in `_rg_evaluate' |
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
/Users/jim/.rvm/gems/ruby-1.9.3-p286@visibill/gems/ruby_parser-3.0.4/lib/ruby_parser_extras.rb:1292:in `process': wrong number of arguments (3 for 2) (ArgumentError) | |
from /Users/jim/.rvm/gems/ruby-1.9.3-p286@visibill/gems/flog-3.2.0/lib/flog.rb:296:in `flog_ruby!' | |
from /Users/jim/.rvm/gems/ruby-1.9.3-p286@visibill/gems/flog-3.2.0/lib/flog.rb:266:in `flog_ruby' | |
from /Users/jim/.rvm/gems/ruby-1.9.3-p286@visibill/gems/flog-3.2.0/lib/flog.rb:256:in `block in flog' | |
from /Users/jim/.rvm/gems/ruby-1.9.3-p286@visibill/gems/flog-3.2.0/lib/flog.rb:253:in `each' | |
from /Users/jim/.rvm/gems/ruby-1.9.3-p286@visibill/gems/flog-3.2.0/lib/flog.rb:253:in `flog' | |
from /Users/jim/.rvm/gems/ruby-1.9.3-p286@visibill/gems/flog-3.2.0/bin/flog:13:in `<top (required)>' | |
from /Users/jim/.rvm/gems/ruby-1.9.3-p286@visibill/bin/flog:19:in `load' | |
from /Users/jim/.rvm/gems/ruby-1.9.3-p286@visibill/bin/flog:19:in `<main>' | |
from /Users/jim/.rvm/gems/ruby-1.9.3-p286@visibill/bin/ruby_noexec_wrapper:14:in `eval' |
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
Today I ran a quick twitter poll asking: "What is the state of the art | |
in Ruby SOAP clients". | |
Savon (http://savonrb.com/) was by far the big winner with 29 | |
recommendations. | |
Surprisingly Soap4r actually got 6 votes, but most were accompanied by | |
comments like "the last time I used SOAP". It was also the only entry | |
that got negative votes (3) with comments like "soap4r is broken and | |
crap by the way". |
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
Rubinius Crash Report #rbxcrashreport | |
Error: signal SIGILL | |
[[Backtrace]] | |
0 ruby 0x00000001021056d0 _ZN8rubiniusL12segv_handlerEi + 544 | |
1 libsystem_c.dylib 0x00007fff912818ea _sigtramp + 26 | |
2 ??? 0x0000000000000006 0x0 + 6 | |
3 ruby 0x0000000102109848 _ZN8rubinius3bugEPKc + 72 | |
4 ruby 0x00000001022481bc _ZN8rubinius6Object2idEPNS_5StateE + 94 |