[rspec-users] Rspec approach to test model
James Byrne
lists at ruby-forum.com
Wed Feb 11 12:47:21 EST 2009
Scott Taylor wrote:
> On Feb 11, 2009, at 8:51 AM, Kaleem Ullah wrote:
>
>> @user=User.new
>> @user.active= '1'
>> @user.reset_password_token= ''
>> end
>
> You could benefit from a factory / data builder. See
> FixtureReplacement, Fixjour, Factory girl, one of the many others out
> there which would build this stuff *once* for you.
Kaleem,
I recently installed nakajima-acts_as_fu (0.0.3) gem. This provides a
rather painless way of specifying ActiveRecord model schemata on the fly
in your specifications. You might find it helpful to look into this.
You will discover that some people favour mocks and stubs when dealing
with AR models in tests/specifications and some favour hitting the
database. Once you decide on your own preference in this matter the
choice of approach is somewhat simplified.
--
Posted via http://www.ruby-forum.com/.
More information about the rspec-users
mailing list