Mongomapper - unit testing with shoulda on rails 2.3.5
Posted
by egarcia
on Stack Overflow
See other posts from Stack Overflow
or by egarcia
Published on 2010-06-02T12:55:00Z
Indexed on
2010/06/02
18:04 UTC
Read the original article
Hit count: 320
I'm trying to implement shoulda unit tests on a rails 2.3.5 app using mongomapper.
So far I've:
- Configured a rails app that uses mongomapper (the app works)
- Added shoulda to my gems, and installed it with
rake gems:install
- Added
config.frameworks -= [ :active_record, :active_resource
] toconfig/environment.rb
soActiveRecord
isn't used.
My models look like this:
class Account
include MongoMapper::Document
key :name, String, :required => true
key :description, String
key :company_id, ObjectId
key :_type, String
belongs_to :company
many :operations
end
My test for that model is this one:
class AccountTest < Test::Unit::TestCase
should_belong_to :company
should_have_many :operations
should_validate_presence_of :name
end
It fails on the first should_belong_to
:
./test/unit/account_test.rb:3: undefined method `should_belong_to' for AccountTest:Class (NoMethodError)
Any ideas why this doesn't work? Should I try something different from shoulda?
I must point out that this is the first time I try to use shoulda, and I'm pretty new to testing itself.
© Stack Overflow or respective owner