I refactored my controllers by introducing request and response models to do some of the logic that was hanging around the controllers following this presentation. I wrapped all the response and request models with a module Responses and Requests respectively. The applications runs perfectly but when I run tests, I get the error below.
Failure/Error: Unable to find matching line from backtrace
RuntimeError:
Circular dependency detected while autoloading constant Responses::FolderContentResponse
My directory structure is as follows:
- app/
- models/
- responses/
Note: I have seen the questions related to this issue but, their issues didn't seem similar to mine. In my case it happens randomly, and only when running tests (RAILS TEST ENV), the application is working perfectly.
module Responses
class ContentResponse
include ActiveAttr::Model
#some attributes
#some methods
end
end
module Responses
class FolderContentResponse < ContentResponse
end
end
The FolderContent response class inherits from ContentResponse which has more generic methods that FolderContent other content responses use.
This sounds a lot like an issue found recently by Xavier Noria. In a nutshell, capybara boots your application in multithreaded mode for the test even though the setting to load all app code upfront is not activated (needed because require
and friends are not threadsafe)
It's been fixed for rails 4.2, on earlier versions
config.allow_concurrency = false
in test.rb should do the trick
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With