Ruby on rails 3.1 命名者验证是否存在应使用的名称a
好吧,我很困惑。我尝试在Rails3.1下将shoulda与Test::Unit结合使用,之前在Rails2.3.11中已经成功地这样做了 我的档案中有以下内容:Ruby on rails 3.1 命名者验证是否存在应使用的名称a,ruby-on-rails-3.1,shoulda,Ruby On Rails 3.1,Shoulda,好吧,我很困惑。我尝试在Rails3.1下将shoulda与Test::Unit结合使用,之前在Rails2.3.11中已经成功地这样做了 我的档案中有以下内容: group :test do gem 'shoulda' end (我已经运行了bundle install-bundle show shouldashowsc:/Ruby192/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3) 我有下面的test_helper.rb ENV["RAILS_ENV
group :test do
gem 'shoulda'
end
(我已经运行了bundle install
-bundle show shoulda
showsc:/Ruby192/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3
)
我有下面的test_helper.rb
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'shoulda'
class ActiveSupport::TestCase
end
以及以下用户_test.rb
require 'test_helper'
class UserTest < ActiveSupport::TestCase
should validate_presence_of :email
should validate_format_of(:email).with("user+throwaway@subdom.example.com").with_message(/valid email address/)
should validate_presence_of(:encrypted_password)
should validate_confirmation_of :password
end
我没有正确设置什么?解决了它。你需要:
require 'shoulda/rails'
在test_helper.rb
(不是'require'shoulda');测试用例需要是:
class Usertest < ActiveRecord::TestCase
classusertest
(不是
)
这两个我都试过了,但不是一起试的
class Usertest < ActiveRecord::TestCase