Ruby on Rails와 mongoDB로 작은 webapp를 만들고 싶습니다. 나는 Rails 3.0.3과 mongoid-gem을 사용한다. 이제 rspec으로 몇 가지 테스트를하고 싶지만 예상대로 작동하지 않습니다. 시험 결과가 정확하지 않습니다. 내가 RSpec에와 시험을 수행 할 때 알고 있어야 뭔가 특별한mongoDB로 Rspec 테스트가 작동하지 않습니다.
require 'spec_helper'
describe User do
before(:each) do
@attr = { :nickname => "Example", :email => "[email protected]" }
@unvalid = {:nickname => "Bla"}
end
...
it "should reject invalid email addresses" do
address = "[email protected],com"
invalid_email_user = User.new(@attr.merge(:email => address))
invalid_email_user.should_not be_valid
end
있습니까 : 작동하지 않습니다 테스트 여기
class User
include Mongoid::Document
field :nickname, :type => String
field :email, :type => String
field :firstname, :type => String
field :lastname, :type => String
field :birthday, :type => Date
field :picture, :type => String
email_regex = /\A[\w+\-.][email protected][a-z\d\-.]+\.[a-z]+\z/i
validates :nickname, :presence => true
validates :email, :presence => true,
:format => { :with => email_regex }
end
그리고입니다 : 여기 내가 테스트 할 모델입니다 및 mongoDB/mongoid?
답해 주셔서 감사합니다.
spec_helper의 소스를 추가 할 수 있습니까? –