Mongomapper - unit testing with shoulda on rails 2.3.5
- by egarcia
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 ] to config/environment.rb so ActiveRecord 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.