Rails integration test: setting the host

10/02/2009
def test_something_else
  sess = open_session
  sess.host = "foo.bar.com"
end
No Comments

Running individual tests with rake

10/02/2009
rake TEST=test/units/foo_test.rb

Source: http://rails.lighthouseapp.com/projects/8994/tickets/168-patch-generators-create-tests-with-require-test_helper-which-doesn-t-work

No Comments

Rails: test fixtures are hashes with special powers

7/12/2006

If you’ve included fixtures in your unit test:

class UserTest <  Test::Unit::TestCase
  fixtures :users

… the data will be available using:

users(:johnny)

A fixtures object behaves like a hash but is actually a method. It is a “hash with special powers“. To get Johnny’s surname you would do:

users(:johnny).surname

The YAML fixture might look something like this:

johnny:
  id: 2
  first_name: Johnny
  surname: Smith
  email_address: jsmith@jsmith.cc
No Comments