erwinjunker / regressor

Generate specs for your rails application the easy way. Regressor generates model and controller specs based on validations, associations, enums, database, routes, callbacks. Use regressor to capture your rails application behaviour.
MIT License
206 stars 33 forks source link

Can't put Regressor gem in the development group #1

Closed gpinkham closed 9 years ago

gpinkham commented 9 years ago

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

erwinjunker commented 9 years ago

Feel free to send a pull request. Could you provide the error message?

gpinkham commented 9 years ago
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'
erwinjunker commented 9 years ago

So this error appears if you want to run your spec suite?

gpinkham commented 9 years ago

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
erwinjunker commented 9 years ago

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