我正在尝试使用 rspec 测试我的管理模型,但我遇到了错误如何解决此错误,请给我一些想法。
我的模型/admin_spec.rb 是
require 'spec_helper'
describe Admin do
before do
@admin = Admin.new(email: "superuser@superuser.com", hash: "iJXdppRiI52XsqJe", password: "736fc7f1f4f382e79f2278817d056a0ec14b9ff5", city_id: "", role_id: 4, request_hash: "", status: 1)
end
subject { @admin }
it { should respond_to :email }
it { should respond_to :password }
it { should respond_to :phone }
it { should be_valid }
end
错误是:
) Admin phone with valid format
Failure/Error: it { should be_valid }
expected valid? to return true, got false
# ./spec/models/admin_spec.rb:15:in `block (3 levels) in <top (required)>'
Finished in 16.08 seconds
34 examples, 1 failure
Failed examples:
rspec ./spec/models/admin_spec.rb:15 # Admin phone with valid format
Randomized with seed 31486