Testing Rails Helpers

Posted by Doug Fri, 31 Mar 2006 18:52:40 GMT

I’ve asked Scott four times now how write functional tests for helper methods. He’s replied the same all four times, and this time I’m going to “remember” it…

require File.dirname(__FILE__) + '/../test_helper'

class HelperTest < Test::Unit::TestCase
  include ActionView::Helpers::TextHelper
  include ActionView::Helpers::TagHelper
  include ApplicationHelper
  # include whatever helpers you want to test here, sometimes you'll need
  # to include some of the Rails helpers, as I've done above.

  def test_some_helper
  end
end

By including the ApplicationHelper in your test class, you have all the methods defined on that class available as local functions. If you have helpers in other classes, you’d need to include those as well.

Posted in ,  | no comments

Emacs and Ruby

Posted by Doug Fri, 24 Mar 2006 13:39:56 GMT

I’ve been doing some hacking on my Ruby and Ruby on Rails configuration for Emacs. I don’t think it’s done (are these things ever?), and maybe not even as good as TextMate. I’ll share it anyway in the hopes that someone can find it useful. You can find my writeup and the configuration file on my Emacs And Ruby wiki page. Notable funcationality:

  • Interactively running tests in various ways
  • Go To Alternate File
  • Snippets

Posted in , ,  | 2 comments

Finally... Macbook Pro benchmarks

Posted by Doug Thu, 23 Mar 2006 20:14:06 GMT

After wrestling extensively with my main Rails project, I finally got all tests passing again. Here’s the results of various systems I have access to for running the tests:

system time rake
2.0 GHz Macbook Pro 2GB 1:38
2.66Ghz Xeon 1GB server 1:35
2.0 GHz G5 iMac 2:08
1.33GHz G4 Powerbook 1.25GB 3:45
866MHz G4 Powerbook 2GB 6:45

Those times seems really precise, but they are just single runs of our tests (324 tests, 1343 assertions). What this means is that it’s as fast for me to do local development now as it was to ssh into the server and develop there. Also worth noting but not included above; When I used my PowerPC DarwinPorts binaries for Ruby, Mysql, and all my other libraries the test time was nearly 4 minutes.

Posted in , , ,  | no comments

Older posts: 1 2 3 4 5 6 ... 14

Copyright 2001 - 2005 by Lathi.net and Doug Alcorn

Creative Commons, Some Rights Reserved Ruby on Rails Developer Powered by Debian GNU/Linux Powered by Typo