In a Dev category discussion titled “How do I run only discourse/plugins/poll/spec?”, dachary seeks to run only the poll plugin’s specs without triggering the full test suite. gerhard suggests manually running specs via LOAD_PLUGINS=1 bundle exec rspec plugins/poll/spec, which dachary confirms works in CLI. tgxworld proposes using bundle exec rake plugin:spec["poll"], though dachary finds bundle exec rake plugin:spec poll works better. dachary submits a PR to update VAGRANT.md with this info. sam recommends bin/rake autospec, which now auto-detects plugin changes if plugins are symlinked, and reminds users to run RAILS_ENV=test bin/rake db:migrate to load plugin migrations. markvanlan reports that plugin migrations don’t run in test env without LOAD_PLUGINS=1, which david explains is intentional to avoid plugin interference with core tests. sam laments that users often skip binstubs, while david notes rails s benefits from binstub magic but rake does not — suggesting aliases or direnv as workarounds. The thread concludes with practical CLI commands and insight into Discourse’s plugin testing architecture.
Not sure how it works with autospec since I’m running the specs manually most of the time.
In order to run the plugin specs I’m always setting an environment variable in my IDE: LOAD_PLUGINS=1
# this runs just the specs in one file
LOAD_PLUGINS=1 bundle exec rspec plugins/poll/spec/controllers/posts_controller_spec.rb
# this runs all the specs of the poll plugin
LOAD_PLUGINS=1 bundle exec rspec plugins/poll/spec
It works, thanks ! Where would be the most relevant topic for this information ? Or maybe there is a file in the git repository that should be updated ? The closest thing I found is the Beginner’s Guide to Creating Discourse Plugins Part 6: Acceptance Tests but it only covers part of the qunit tests.
@sam added some magic here, so if you do RAILS_ENV=test /bin/rake db:migrate then it will automatically load plugins. But I think most people don’t use the bin stubs, so this issue keeps happening to different people. Maybe we need to embed the logic in the db:migrate rake task, rather than in the bin stub
When we run the test suite normally, we don’t want plugins to be loaded - often plugins override functionality and would cause the core tests to fail.