Closed gpinkham closed 9 years ago
Feel free to send a pull request. Could you provide the error message?
NameError: uninitialized constant Regressor
/home/gpinkham/mv/portal/config/initializers/regressor.rb:1:in `<top (required)>'
/home/gpinkham/.rvm/gems/ruby-2.1.2@portal/gems/railties-4.1.1/lib/rails/engine.rb:648:in `block in load_config_initializer'
/home/gpinkham/.rvm/gems/ruby-2.1.2@portal/gems/activesupport-4.1.1/lib/active_support/notifications.rb:161:in `instrument'
/home/gpinkham/.rvm/gems/ruby-2.1.2@portal/gems/railties-4.1.1/lib/rails/engine.rb:647:in `load_config_initializer'
So this error appears if you want to run your spec suite?
yes.. well it did until I changed the code to:
if Rails.env.development?
Regressor.configure do |config|
config.regression_path = 'spec/models/regression'
config.excluded_models = []
end
end
Yes that seems about right if you have put the gem into the development group it is not available for your specs/tests. The if block in the initializer would solve this problem. Would you like to send a pull request?
Another similar pattern according to: http://stackoverflow.com/questions/4820987/rails-per-environment-initializers could be:
if defined?(Regressor)
Regressor.configure do |config|
config.regression_path = 'spec/models/regression'
config.excluded_models = []
end
end
I put the regressor gem in the development group in my GemFile but because of the app won't start in test mode due to the initializer. I wrapped the initializer in "if Rails.env.development?" and the test now starts up. not sure if this is the best way.. if so I'll send a long a pull request..