require 'spec_helper'
describe User do
before(:each) do
@attr = {
:username => "User",
:email => "[email protected]",
:password => "foobar",
:password_confirmation => "foobar",
:phone_no => "0808322222"
}
end
it "should create a new instance given a valid attribute" do
User.create!(@attr)
end
end
測試持續失敗,請不知道爲什麼設計,RSpec的和Mongoid測試失敗
Failures:
1) User should create a new instance given a valid attribute
Failure/Error: User.create!(@attr)
Mongoid::Errors::Validations:
Validation failed - Phone no can't be blank, Username can't be blank.
# ./spec/models/user_spec.rb:16:in `block (2 levels) in <top (required)>'
Finished in 0.2505 seconds
2 examples, 1 failure
我們需要的型號知道哪裏是你的內部錯誤。也許你使用attr_accessible或attr_protected – shingara 2012-02-15 13:49:29
@shingara我在https://gist.github.com/1835904粘貼了User模型我正在使用attr_accessible – bjhaid 2012-02-15 13:59:59