Kelly Felkins's blog



Kelly FelkinsKelly Felkins
Standup 9/11/2009: to_param now required in functional tests
edit Posted by Kelly Felkins on Friday September 11, 2009 at 10:08AM

Ask for Help

"Do you have to use to_param in functional tests?"

In the past you could simply provide an object in a param list in functional tests and the to_param for the object would be called to get the proper value for the parameter. This is now broken, forcing you to use object.to_param every time.

Perhaps not helpful for existing projects but I recommend you use cucumber, webrat, or even selenium rather than Rails functional tests. Rails functional tests require that you specify parameters and specify them correctly. If you get them wrong your functional tests might continue to pass for the wrong reason. Here's another "bad params in functional tests" post.

Interesting Things

Kelly FelkinsKelly Felkins
Standup 9/9/2009: Unicorn, Thin, and Mongrel
edit Posted by Kelly Felkins on Wednesday September 09, 2009 at 09:39AM

Ask for Help

"Has anyone used Unicorn"

No one present is using Unicorn. Some wondered how it differs from Thin.

This raised the question:

"Is there a road map for mongrel and rails? Mongrel uses CGI and Rails 2.3 has removed CGI."

In the Ruby on Rails 2.3 Release Notes, there is the statement

...but if you use CGI, don’t worry; Rails now supports CGI through a proxy interface...

Ask for Help

"How do you test request headers? The request object is frozen..."

The team is using rspec to test an OAuth implementation and needs better access to the request object.

  • Possibly modify the request environment prior to running the test -or-
  • Instantiate a new, non-frozen request object.

Kelly FelkinsKelly Felkins
Standup 3/25/2009: Branches + JSUnit + CI + IE = :-(
edit Posted by Kelly Felkins on Wednesday March 25, 2009 at 04:57PM

Interesting Things

  • Branches + JsUnit + CI + IE = :-( : Apparently it is difficult to manage IE's cache in CI. One project apparently has a bat file on CI that clears the cache every 30 minutes. Another team solved this by making the cache directory read only. Often browser/OS combinations have some technique for disabling caching.
  • Test Swarm Alpha: this is a crowd sourced javascript testing solution (think seti@home for javascript testing) being developed by John Resig.

Ask for Help

"AR attribute appears to be skipped by text field helper?!" Apparently the model method is bypassed by the text field helper if a column of the same name is present in the underlying table. This was experienced in Rails 2.2.

Others have apparently experienced this in the past but a clear answer did not surface.

Kelly FelkinsKelly Felkins
Standup 7/28/2008
edit Posted by Kelly Felkins on Monday July 28, 2008 at 04:17PM

Interesting

Ask for Help

We upgraded to rails 2.1 and polonium and our rspecs are not running on CI, but run fine if you simply use rake on the command line.

Check to see if you are using the rake extensions in pivotal core bundle.

Using setTimeout() to wait for DOM to update in JsUnit does not work.

Using setTimeout in tests is not going to do what you want, unless you mock setTimeout. Basically, setTimeout kicks off another thread which is not likely to effect the current test.

Kelly FelkinsKelly Felkins
Happy Path Testing With Selenium RC Fu
edit Posted by Kelly Felkins on Tuesday February 05, 2008 at 03:51AM

Selenium RC Fu is a fantastic system for testing Ruby On Rails applications. It is the blending of xUnit testing with Selenium. Selenium is a cool system that operates your browser as if a human were sitting there moving the mouse pressing buttons and keys.

Selenium RC Fu is also a remarkable example of the power of open source. It's selenium remotely controlled by rails and ruby. You can learn more about it by viewing the slides for Full-stack webapp testing with Selenium and Rails presented by my colleagues Alex Chaffee and Brian Takita at the SDForum Silicon Valley Ruby Conference.

Now that you are excited about Selenium RC Fu, by law I must inform you that this wonderful testing tool comes with some costs. First, this is the daisy cutter of testing -- problems will be detected, but it won't be too specific about those problems. A failed selenium test will likely only tell you some expected text was not present on the page -- you have to do some digging to discover the real problem.

It's also slow. To be fair, a lot of software is running to do this testing.

So use selenium testing sparingly. A good strategy is to restrict selenium testing to "happy path" testing. These happy path tests become a compliment to other more focused and faster unit and integration tests.

Kelly FelkinsKelly Felkins
Teaching Your Tests To Report Unused Parameters
edit Posted by Kelly Felkins on Wednesday January 23, 2008 at 07:06PM

Recently I was about to check in some changes and did a last minute click through of the application. All of a sudden I'm staring at a stack trace. My tests were green and I had functional tests for the failing controller/action.

Tests are like pants -- they cover your backside while you focus on other things like adding features to your application. Suddenly I felt a breeze on my cheeks. Something was amiss.