-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integration tests harness for plugins #497
Comments
@timdiggins That said, I think Notifier plugin tests could just be unit tests for now. The API is tested from Thredded already. |
@glebm Some thoughts:
But still need to set up a database with users, posts and privates -- which means a dummy app, and then factories or similar. Yes could mock out the post and private post, but then insulating the plugin from changes in thredded which is a bad idea. Would rather somehow just use the dummyapp and factories from thredded (choice of branches (e.g as you say, latest release and master)). So maybe the above approach (with git submodule or simpler git checkout) would be appropriate for notifier plugin, but not using feature tests, but using just the dummy app / harness -- and just run the plugin's own unit tests |
@glebm what do you think about including the /spec directory within the published gem so that other gems can use the spec files (particularly factories and dummy) -- without having to use submodule or separate checkout and |
NB - this would be only first step to integration test harness, but we can slowly make this happen. For the notifiers plugin I was initially thinking of using factories and DB, but will first of all try a mocking approach and see if that is good enough (though not sure how easy it is to mock an ActiveRecord with a validating double and no db... -- could end up baking in expectations about the fields that could change...) |
Thinking about this a bit further (after implementing) -- what we really want are objects which are like partial doubles for the key models which we can use as either mocks or stubs in rspec without needing the base models or the db. These should be tested in the thredded/thredded that the models conform to them (ie. every method they validate exists in the original model). They can then be used in a plugin (and optionally in unit tests too). Obviously some plugins are going to need the engine and views and db anyway. (that's separate). Just sketching some ideas for a mock:
thoughts @glebm -- or know of a library that will help?
|
better name for |
We need to figure out how to test plugins easily.
For plugins that only affect a small part of Thredded, such as
markdown_coderay
, unit tests are sufficient, and we only need to make sure that we test with the latest release and the current master.However, for plugins that change Thredded more extensively it would be nice to run some of the existing Thredded tests and reuse the current Thredded test harness.
One way this can be achieved:
Have the plugin test harness perform the following setup:
spec/support/thredded
).path
dependency on the plugin code to thespec/support/thredded/thredded.gemspec
andspec/support/thredded/spec/dummy/config/application.rb
. Hopefully this doesn't create a dependency cycle (thredded depends on the plugin which depends on thredded).bundle
.rails g thredded:my_plugin:install
.spec/thredded/my_plugin
intospec/support/thredded/spec/my_plugin
.With this setup, the integration tests can then be run from within the modified thredded submodule directory. The unit tests can still run as usual.
Raised by @timdiggins in #441 (comment):
The text was updated successfully, but these errors were encountered: