我在轨道上使用红宝石。我也使用 minitest 框架进行测试,使用 mongoid 进行数据库。我想写一个模型测试。我的模型如下:
class Identity
include Mongoid::Document
include OmniAuth::Identity::Models::Mongoid
field :name
field :email
field :password_digest
validates :name, uniqueness: true
end
模型测试是:
describe Identity do
it "must include OmniAuth::Identity::Models::Mongoid" do
Identity.must_include OmniAuth::Identity::Models::Mongoid
end
it "should have name" do
Identity.new.must_respond_to :name
end
it "should have email" do
Identity.new.must_respond_to :email
end
it "should have password_digest" do
Identity.new.must_respond_to :password_digest
end
it "should type of String" do
Identity.new.name.type.must_equal "String"
end
end
我的问题是关于测试字段的类型
it "should type of String" do
Identity.new.name.type.must_equal "String"
end
如何测试字段的类型?提前致谢。