我正在尝试使这个gem(https://github.com/gshaw/common_validators)Rails 4兼容,而且我遇到了一些麻烦。
将gemspec line 22更改为spec.add_dependency "rails", ">= 3.2"
会产生错误
app/validators/date_format_validator.rb:8:in `<top (required)>': uninitialized constant ActiveModel (NameError)
看起来我必须明确要求active_record
,因此我已将require 'active_record'
添加到test_helper.rb
。
现在收到的错误是
/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/testing/declarative.rb:36:in `test': test_invalid_date is already defined in DateFormatValidatorTest (RuntimeError)
看起来我错过了一些基本的东西,但不确定是什么。我尝试了各种各样的事情无济于事。
非常感谢任何想法。谢谢!
答案 0 :(得分:0)
制作work的唯一方法是生成一个新的rails插件,如http://guides.rubyonrails.org/plugins.html所述,并使用那里的测试框架。