Write tests. They'll save your ass.
If it's happened more than twice, don't ever do it by hand again.
>> pp MiniTest::Unit::TestCase.instance_methods.sort - Object.methods | |
["_assertions", | |
"_assertions=", | |
"assert", | |
"assert_block", | |
"assert_empty", | |
"assert_equal", | |
"assert_in_delta", | |
"assert_in_epsilon", | |
"assert_includes", |
Last login: Sun Dec 21 00:55:08 on ttys002 | |
awesomeville:~ soawesomeman$ irb | |
>> a = {} | |
=> {} | |
>> dude = [a] | |
=> [{}] | |
>> b = {} | |
=> {} | |
>> dude.last["k1"] = b | |
=> {} |
# just a little fix for a little bug with rubyforge projects | |
# ~/.rubyforge/auto-config.yml | |
# before | |
1 --- | |
2 processor_ids: | |
3 Other: 9999 | |
4 release_ids: | |
5 traits: | |
6 1.2.3: 666 | |
... |
# http://iamsoawesomeman.com/controller/action?awesome=true | |
assert_kind_of TrueClass, params[:awesome] | |
# nacho average String | |
1 #!/usr/bin/env ruby -w | |
2 | |
3 require 'rubygems' | |
4 require 'minitest/unit' | |
5 $: << 'lib' << 'test' | |
6 require 'cheeba/cash/builder' | |
7 require 'cheeba/defaults' | |
8 MiniTest::Unit.autorun | |
9 | |
10 class TestBuilder < MiniTest::Unit::TestCase |
103 def test_lst | |
104 assert_equal {5 => "line"}, @builder.lst({1 => {}, 2 => {:meta => {:list => {5 => "line"}}}}) | |
105 end | |
$ ruby test/test_builder.rb | |
test/test_builder.rb:104: syntax error, unexpected tASSOC, expecting '}' | |
assert_equal {5 => "line"}, @builder.lst({1 => {}, 2 => {:meta => {:list => {5 => "line"}}}}) | |
^ | |
test/test_builder.rb:104: syntax error, unexpected ',', expecting kEND | |
assert_equal {5 => "line"}, @builder.lst({1 => {}, 2 => {:meta => {:list => {5 => "line"}}}}) |
# forgot where I got this, thanks dude! | |
class String | |
def to_ascii_iconv | |
converter = Iconv.new('ASCII//IGNORE//TRANSLIT', 'UTF-8') | |
converter.iconv(self).unpack('U*').select{ |cp| cp < 127 }.pack('U*') | |
end | |
end |