ruby-on-railsrspecdisposablereform

Fails to run Rspec due to Reform error: "undefined method `feature' for Reform::Form:Class (NoMethodError)"


I'm just trying to run some tests, and I get this error:

undefined method `feature' for Reform::Form:Class (NoMethodError)

It happens in /usr/local/bundle/gems/reform-2.2.3/lib/reform/form.rb:75, that line in form.rb is the first time the DSL word feature is used. Of course this does not happen when I run my rails app but only when I run rspec..

It is defined in the Disposable gem used by reform. At first I thought that the problem is with an older version of rspec but even after I updated to the latest versions, things are still broken. Reading the code or documentation did not lead me to any specific behavior of loading that is different between tests and application runs.

The versions of gems I use are: rspec-3.3.0, reform-2.2.3, disposable-0.3.2

Does anyone have a clue?

-- Update --

After removing the entire test framework (removing RSpec and deleting all related files) and installing again I got to the point that RSpec is running by itself but when trying to load my environment in the test file it fails on the same error.


Solution

  • Well, the problem was that we added an override of Reform's Contract and did not do it too gracefully, thus not requiring all the things the original Reform Contract required. As a fix we now created a base Contract that inherits from Reform::Contract instead of overriding it and now all works well. The only reason we found it when running RSpec and not in running Rails c is because of different loading order of things.