How Stop Autotest From Running After Each Failed Test Was Fixed

Autotest until recently only had one flaw: it could not be used for large test suites, since after each red-green cycle I had to wait x minutes for all tests to pass, which made autotest really frustrating.

So grep autotest (the ‘without ZenTest version’) from github and enjoy “autotest -c” (also works with auospec).

And remember kids: always run autospec with script/spec_server and its twice the fun 😉

Umlaut Aware Alphabetical Sorting

The simples solution i could come up with, convert all chars to their base (á -> a), using String.tr would be ideal for this task, but its not UTF8 aware…

If you dare to digg deeper, more information can be found on wiki and on coding horror

list.sort_by{|name| convert_umlaut_to_base(name)}

  def convert_umlaut_to_base(input)
    text = input.dup
    %w[áäa ÁÄA óöo ÓÖO íi ÍI úüu ÚÜU ée ÉE ßs].each do |set|
      text.gsub!(/[#{set[0..-2]}]/,set[-1..-1])
    end
    text
  end

Lessons learned from upgrading Rails 2.1 to 2.3

Just my collection, so you do not need to find it out on your own 😉

  • :expire now is called :expires_in, update your cache calls or timed expiring will fail
  • get rspec edge/ rspec-rails edge
    detailed instruction
    also possible and easy: sudo gem install dchelimsky-rspec dchelimsky-rspec-railsyou may need to add this when you are on 1.1.99.9 and get
    no such file to load — spec/rails/example/routing_example_group
    from github
  • get webrat 0.4.2 (atm only by installing from github clone + rake gem + sudo gem install)
  • truncate(‘xxx’,3) ==> truncate(‘xxx’,:length=>3)
  • Model.find_by_xxx will now call Model.find with :conditions=>{:xxx=>something}, this broke some of my stubs/mocks, e.g. User.stubs(:find) worked before but now came in conflict with user login that used find_by_id
  • render :inline seems not to be testable, all my request.body from render :inline are blank now (rspec 1.1.12)
  • stub_model install rspec-rails-mocha — ./script/plugin install git://github.com/mislav/rspec-rails-mocha.git
  • count returns OrderedHash, so tests now look like xxx.to_a.should == [[‘name’,2]]
  • String.chars does not have the [] method anymore, so e.g. only “xxx”.mb_chars[1..4] will work
  • @template will no longer work in vie tests, use response instead
  • have_tag returns
    undefined method `id2name’ for {:instance_writer=>false}:Hash
    , upgrade the money gem!
  • controller tests are no longer able to call actions that are not defined (e.g. no action was defined because it only renders a view and does nothing or because the action was included from a module)
  • HopToad will silently fail, use this branch instead: http://github.com/pzingg/hoptoad_notifier (as long as thoughbot does not update their own of course)
  • work systematically e.g. rake spec:models, then rake spec:controllers … or you may get mad 😉