Rails 4 gem - ActiveSupport - method already defined

267 Views Asked by At

I'm trying to make this gem (https://github.com/gshaw/common_validators) Rails 4 compatible and I'm having a bit of a trouble.

Changing gemspec line 22 to spec.add_dependency "rails", ">= 3.2" will generate an error that

app/validators/date_format_validator.rb:8:in `<top (required)>': uninitialized constant ActiveModel (NameError)

Looks like that I have to explicitly require active_record, so I've added require 'active_record' to test_helper.rb.

Now the error received is

/.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)

Looks like I'm missing something basic, but not sure what. I've tried various things to no avail.

Any thoughts are much appreciated. Thanks!

1

There are 1 best solutions below

0
On BEST ANSWER

The only way to make it work was to generate a new rails plugin as described on http://guides.rubyonrails.org/plugins.html and use the test framework from there.