"No setting named __ exists" when trying to run specs on poll plugin

Hi,

I’m making a plugin and am trying to write some tests, but when I try to run the specs of poll plugin via

bundle exec rake plugin:spec poll

as seen here, I’m getting this error:

An error occurred while loading ./plugins/poll/spec/integration/poll_endpoints_spec.rb.
Failure/Error: raise ArgumentError.new(“No setting named ‘#{name}’ exists”)

ArgumentError:
  No setting named 'discourse_narrative_bot_enabled' exists
# ./lib/site_settings/defaults_provider.rb:58:in `set_regardless_of_locale'
# ./config/environments/test.rb:74:in `block (3 levels) in <main>'
# ./config/environments/test.rb:63:in `tap'
# ./config/environments/test.rb:63:in `block (2 levels) in <main>'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.3.2/lib/active_support/lazy_load_hooks.rb:68:in `block in execute_hook'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.3.2/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.3.2/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.3.2/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.3.2/lib/active_support/lazy_load_hooks.rb:51:in `each'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.3.2/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/railties-6.1.3.2/lib/rails/application/finisher.rb:140:in `block in <module:Finisher>'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/railties-6.1.3.2/lib/rails/initializable.rb:32:in `instance_exec'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/railties-6.1.3.2/lib/rails/initializable.rb:32:in `run'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/railties-6.1.3.2/lib/rails/initializable.rb:61:in `block in run_initializers'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/railties-6.1.3.2/lib/rails/initializable.rb:60:in `run_initializers'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/railties-6.1.3.2/lib/rails/application.rb:384:in `initialize!'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/railties-6.1.3.2/lib/rails/railtie.rb:207:in `public_send'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/railties-6.1.3.2/lib/rails/railtie.rb:207:in `method_missing'
# ./config/environment.rb:7:in `<top (required)>'
# ./spec/rails_helper.rb:56:in `require'
# ./spec/rails_helper.rb:56:in `<top (required)>'
# ./plugins/poll/spec/integration/poll_endpoints_spec.rb:3:in `require'
# ./plugins/poll/spec/integration/poll_endpoints_spec.rb:3:in `<top (required)>'

What am I doing wrong when trying to run the poll plugin’s tests? Why would this particular setting not be loaded to the default locale?

Thanks.

To run just the poll specs the command is: bundle exec rake "plugin:spec[poll]" (or shorter: bin/rake "plugin:spec[poll]") otherwise you’re running all plugins specs.

Regarding the error you’re getting, I’m not sure. Is the test database migrated? (bin/rails db:migrate RAILS_ENV=test)

2 Likes

Thanks. Like you said, it did run all the plugin specs, which I worked around by removing the other plugins. I was basing off of this, but it turns out the parentheses were in the wrong spot.

Yes, the database is migrated in the test environment. I worked around this error by commenting out the raise ArgumentError.new("No setting named '#{name}' exists") line and replacing it with a puts, and it shows only discourse_narrative_bot_enabled triggers this error; all other settings are fine. I don’t think we did anything with this setting. Anyway, since my spec run properly while ignoring this error, I can leave the workaround in my local discourse. When I find what actually caused this, I’ll update this post.