mongomapper を使用して、Rails 2.3.5 アプリに shoulda 単体テストを実装しようとしています。
これまでのところ:
- mongomapper を使用する Rails アプリを構成しました (アプリは動作します)
- 私の宝石にshouldaを追加し、それをインストールしました
rake gems:install
config.frameworks -= [ :active_record, :active_resource
] を追加したconfig/environment.rb
のでActiveRecord
使用しません。
私のモデルは次のようになります。
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
そのモデルの私のテストはこれです:
class AccountTest < Test::Unit::TestCase
should_belong_to :company
should_have_many :operations
should_validate_presence_of :name
end
最初に失敗しますshould_belong_to
:
./test/unit/account_test.rb:3: undefined method `should_belong_to' for AccountTest:Class (NoMethodError)
これが機能しない理由はありますか?shouldaとは違うものを試してみるべきですか?
shoulda を使用するのはこれが初めてであり、それ自体をテストするのはかなり新しいことを指摘しなければなりません。