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


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”)

  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- `block in execute_hook'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/activesupport- `with_execution_control'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/activesupport- `execute_hook'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/activesupport- `block in run_load_hooks'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/activesupport- `each'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/activesupport- `run_load_hooks'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/railties- `block in <module:Finisher>'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/railties- `instance_exec'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/railties- `run'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/railties- `block in run_initializers'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/railties- `run_initializers'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/railties- `initialize!'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/railties- `public_send'
# /Users/myUser/.rvm/gems/ruby-2.7.0/gems/railties- `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?


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)


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.