Rails on the Run

Rails experiments by Matt Aimonetti

Browsing Posts tagged zentest

I haven’t posted for quite a long time. The thing is I moved to a new place and I’m really busy on working clients + setting up my new office + dealing with way too much paperwork.

Anyway, enough excuses, here are few tips that I believe will be useful to some of you:

ZenTest Autotest

I love autotest, but you might have noticed that sometimes (especially on big projects), ZenTest might start using more CPU than expected. On my machine, that results in the fan going off and annoying the crap out of me.

The solution is quite simple, exclude all folders you don’t need to monitor. To do that, update ZenTest to version 3.8.X

sudo gem update ZenTest

(older version had a different syntax)

Now, edit your .autotest that should be located in ~/.autotest (if it doesn’t exist, create it).

Finally add the following code:

1
2
3
4

  Autotest.add_hook :initialize do |at|
    %w{.svn .hg .git vendor}.each {|exception| at.add_exception(exception)}
  end

I personally freeze rails in vendor and I autotest is way happier when it doesn’t have to monitor some extra files. (note that we also exclude folders such as .git or .svn)
(you can also include files etc… read more there)

RSpec

RSpec is certainly my favorite Ruby tool and I’m glad to say that most of my SD.rb friends finally got convinced!

Now, few people complained to me about spec failures outputting the full stack such as:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

 The Sessions controller should fail since it's a test' FAILED
 expected true, got false
 test_app-git/trunk/vendor/plugins/rspec/lib/spec/expectations.rb:52:in `fail_with'
 test_app-git/trunk/vendor/plugins/rspec/lib/spec/expectations/handler.rb:21:in `handle_matcher'
 test_app-git/trunk/vendor/plugins/rspec/lib/spec/expectations/extensions/object.rb:34:in `should'
 ./spec/controllers/sessions_controller_spec.rb:25:
 test_app-git/trunk/vendor/plugins/rspec/lib/spec/example/example_methods.rb:78:in `instance_eval'
 test_app-git/trunk/vendor/plugins/rspec/lib/spec/example/example_methods.rb:78:in `run_with_description_capturing'
 test_app-git/trunk/vendor/plugins/rspec/lib/spec/example/example_methods.rb:19:in `execute'
 /opt/local/lib/ruby/1.8/timeout.rb:48:in `timeout'
 test_app-git/trunk/vendor/plugins/rspec/lib/spec/example/example_methods.rb:16:in `execute'
 test_app-git/trunk/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:288:in `execute_examples'
 test_app-git/trunk/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:287:in `each'
 test_app-git/trunk/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:287:in `execute_examples'
 test_app-git/trunk/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:121:in `run'
 test_app-git/trunk/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:22:in `run'
 test_app-git/trunk/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in `each'
 test_app-git/trunk/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in `run'
 test_app-git/trunk/vendor/plugins/rspec/lib/spec/runner/options.rb:89:in `run_examples'
 test_app-git/trunk/vendor/plugins/rspec/lib/spec/runner/command_line.rb:19:in `run'
 script/spec:4:

  Finished in 6.035147 seconds

  400 examples, 1 failure

We can really easily change that, open you spec.opts file located in your spec folder.

it probably looks like that:

1
2
3
4
5
6
7
8

  --colour
  --format
  progress
  --loadby
  mtime
  --reverse
  --backtrace

Get rid of “–backtrace” and your new failure should look like:

1
2
3
4
5
6
7
8
9
10
11

  1)
  'The Sessions controller The Sessions controller should fail since it's a test' FAILED
  expected false, got true
  ./spec/controllers/sessions_controller_spec.rb:25:
  script/spec:4:

  Finished in 0.269956 seconds

  15 examples, 1 failure
  

Other stuff you may find interesting (in no particular order):

mac os X leopard

As many of you know, I’m a great RSpec and autotest fan.

Last night, I upgraded my MacBook to from Tiger to Leopard and I everything went very well… apart that Autotest stopped notifying me using Growl when my tests pass or fail :(

Growl itself works fine, even when using spaces.

However growlNotify, the Growl plugin used by autotest doesn’t seem to be Leopard compatible yet.

Just thought you guys should know that before upgrading.

growl

In case you missed the latest great extension for Zentest Autotest, here is the blog post you have to read.

Jeremy from Switzerland came up with this great idea of adding audio report to Autotest. I’ve been using Growl to notify me when my tests would pass or fail, but I simply love just hearing a different sound based on the result of the tests.

growl (screenshot from this post)

Watch the screencast

p.s: I’m working on redesigning this blog, I don’t have much time and I hate IE :) I hope to get things fixed soon.