Posts Tagged ‘test’

Check if selected date is correct with cucumber

Monday, January 4th, 2010

The default web steps provided by cucumber provide a way to check the content of a text field : the "..." field should contain "...", but how to check if the date selected by default in a form is correct ?

To describe some of the features of the coming PigeBox web interface, we needed something like : the "..." datetime should contain "17:00:00".

Even if webrat doesn’t provide the builtin method to “read” a Rails datetime select, this piece of code adds the method selected_datetime to webrate scope.

With this small webrat extension, the following step becomes possible :

(more…)

CruiseControl.rb 1.4.0 debian packages

Wednesday, August 19th, 2009

CruiseControl.rb packages have been updated today. They are based on the 1.4.0 sources released on June. The Debian packages are for stable (using lenny-backports dist) and unstable on Tryphon Debian Repository.

If needed, see how to install CruiseControl.rb on debian or ubuntu.

Agile Puppet at RMLL 2009

Monday, July 20th, 2009

Puppet is a great tool for automating system administration tasks. But it will transform your way of administrating … by integrating development methods.

It was the subject of this talk “Agile Puppet” at the RMLL in Nantes :

(more…)

Install CruiseControl.rb on debian or ubuntu

Saturday, February 21st, 2009

CruiseControl.rb is a continuous integration tool. It runs a build process when modifications are detected in a project. Java developers know CruiseControl (often discussed in this blog). CruiseControl.rb is very practical for projects built with rake, especially rails projects.

For example, CruiseControl.rb can:

  • follow several branches of your project,
  • run tests or specs in a clean environment,
  • notify our team when something goes wrong (by email, twitter, jabber, irc, campfire, …),
  • deploy with capistrano our development stage when specs are verified,

This CruiseControl.rb debian package is based on CruiseControl.rb github branch of ThoughtWorks.

(more…)

Test ActionMailer for a multipart mail

Thursday, November 22nd, 2007

When your ActionMailer creates multipart mails with both html et text bodies, your unit test can become a nightmare. The default policy to test ActionMailer (provided by the generated testcase) is comparing the created mail content with a static fixture. It’s very difficult to maintain. And this approach is impossible with a multipart mail. Several things in the encoded mail are randomly created (like the mimepart boundaries).

Another policy is promoted by Dave Thomas in his book Agile Web Development with Rails or Shanti A. Braford. The principle is simple : test only that the important information is present into the mail body.

This approach is meanful in a html/text mail. The two parts contain often the same important information. So the same assertions can be performed on the two parts of the mail :

sent.parts.each do |part|
  assert_match #{user.name}, part.body, "#{part.content_type} invalid"
  ...
end