VijayVijay
Standup 10/2/2008: rspec running describes in order
edit Posted by Vijay on Thursday October 02, 2008 at 05:31PM

Interesting Things

  • Rspec - stubbing a class method

In Rspec you can stub a class method in a module using Module::Class:Stubs('method') similar to Mocha syntax stub! does not work for Module::Class:method in rspec

  • Rspec - running test in order

If someone knows of a way to run describes in order in rspec test, please let me know

Ask for Help

"Finder conditions in rails?"

    find(:all, :conditions => 'flag is null')  where flag is boolean

This would work in tests but not in development mode. They tried changing it to

    find(:all, :conditions => 'flag != 1')  where flag is boolean

and this would work in dev mode but not in test.

Try having boolean values in database as not null and never pass null to boolean. Make sure fixtures and development data have similar data sets.

"Selenium tests failing to load associations"

Check if you RAILS_ENV is set to test while running Selenium. There has been some cases of weird rails behavior running tests when RAILS_ENV is set to development

Comments

  1. Jeff Dean Jeff Dean on October 03, 2008 at 01:47PM

    How about:

    find(:all, :conditions => ['flag != ?', true])

  2. Joseph Palermo Joseph Palermo on October 04, 2008 at 01:06AM

    That generates

    WHERE (flag != 1)
    

    which still won't find you NULL values, you need

    WHERE flag IS NULL OR flag = 0
    

    but it probably make more sense to just make your column :null => false and ensure you only have 0's in there.