[rspec-users] My first tests, backwards. Please help

Jesse Crockett lists at ruby-forum.com
Wed Dec 31 13:46:49 EST 2008


I hope to be on my feet after a few more basic questions..


> Take a look at these:
> 
> http://github.com/flogic/object_daddy/tree/master
> http://github.com/thoughtbot/factory_girl/tree/master
> http://github.com/notahat/machinist/tree/master


Deciding on factory_girl due to it's popularity, I wrote a factories 
file:

== spec/factories.rb

# This will guess the User class
Factory.define :user do |u|
  u.login 'John'
  u.password 'foobar'
  u.password_confirmation  'foobar'
  u.email  'john at pandawin.com'
  u.pref_charity_one_id  1
  u.pref_charity_two_id  2
  u.pref_charity_three_id  3
  u.credits  0
  u.register! # do these work?
  u.activate! #
end

== but the test still gets 'quentin' from the bort fixtures for user 1
require File.dirname(__FILE__) + '/../spec_helper'
require 'factory_girl' # don't know if this works
==

Do I need to require the file like the spec_helper for factory_girl?

For instance, will you write a simple case that puts the factory user id 
and login?  I think that would help a lot.

Also, your patience is appreciated.  I may have a New years resolution 
knocked out before the year starts :-)
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list