danmayer/coverband

Issue on Coverband initializer on Ruby 3.1.2

dynelight opened this issue · 9 comments

I'm not sure if this is because I need to do any new or different write up for Ruby 3, but this fails:

# config/coverband.rb
Coverband.configure do |config|
  config.store = Coverband::Adapters::RedisStore.new(
    Redis.new(
      url: ENV['REDIS_URL'],
      ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE }
    )
  )
end
/Users/dynelight/Projects/v/config/initializers/coverband.rb:2:in `<main>': uninitialized constant Coverband (NameError)

Are you sure you have it in your gemfile, if you have require: false you will need to require it manually in something like application.rb or remove the require: false from your gemfile. We have this running in several Ruby 3.1.2 apps without anything like this.

sorry for the delay @dynelight I was on vacation so it took a bit to get back to you on the issue.

No problem.
I double checked and I don't have require: false:

gem 'coverband'

... on my gemfile.

Are you initializing in a similar way as me?

Ah... sorry, the coverband configuration file should be config/coverband.rb not config/initializers/coverband.rb This came up in another recent github issue and I will be making some changes to help avoid this issue.... move the file and you should be good.

Oh wow... is this a Ruby 3 issue? I'm having several initializers have this same problem

No, this shouldn't be Ruby 3 and most things use initializers, I should perhaps allow that for Coverband, but it is a bit odd in that I need to bootstrap it BEFORE most of Rails is up and running, hence the unique configuration file location.

=> Run `bin/rails server --help` for more startup options
Exiting
/Users/dynelight/Projects/v/config/routes.rb:27:in `block in <main>': uninitialized constant Coverband (NameError)

Routes file:

  mount Coverband::Reporters::Web.new, at: '/coverage', constraints: Routing::AdminConstraint.new

On the routes file, it doesn't find it..

% cat Gemfile.lock | grep coverband
    coverband (5.2.3)

if you have bundler setup correctly it should definitely be there before routes... you can just require 'coverband' at the top of the routes file, but something seems odd about your setup.

since some other folk shave also had some issues with configuration, I added an install task that makes it more clear where to add the config file.

#450