-
Notifications
You must be signed in to change notification settings - Fork 8
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
PR for Refactor shutdown sequence to use plugin.stop #4
Conversation
end # def register | ||
|
||
public | ||
# for testing access | ||
attr_reader :client, :muc_clients |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we move this to the top or bottom of the file for easy finding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thinking: as its used in methods from register downwards it should be above def register
.
We don't really enforce the classic ruby file layout and for plugins I think the config DSL should standout at the top. My 2c.
end # def run | ||
|
||
def stop | ||
super |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super is no longer needed
require "logstash/devutils/rspec/spec_helper" | ||
require 'logstash/inputs/xmpp' | ||
|
||
module Jabber |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this mocks to an spec_helper.rb
file or other kind of support helper concept.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered this and made a point about it in the Reviewers Notes above. What rule of thumb should we apply here? On the one hand it is tidy to move the mocks to their own file and on the other hand, moving them will make it less easy to read and follow the whole spec suite in one go.
I cannot find any solid guidance in the Internet about extract or not wrt helpers. Even the Rspec style guide is silent on this.
The only RSpec convention is to put them in /support and they get auto-loaded but then the same people that don't know what described_class means will not know about this RSpec convention either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
as there no official logstash style guide about it, it end up very personal. But in my experience, keeping the test without the definition of mocks and other support classes makes sense as code is simpler and easier to understand then.
I would strongly recommend you to do it as will keep things easy to understand and manage in the long term. But again this is my opinion, i tend to like everything in their place, and for this example mocks belong to their definition files and test belong here, mixing them confuses the read, and somehow makes stuff tied up.
On the other side, even if not official this is a pattern I'm trying to enforce in the hole code base, so it would be nice to have mocks defined in helper files that then gets used in the examples.
Again, is the same example as having smoller methods as possible, we're humans and to understand big pieces of code it gets error prone.
LGTM, keep in mind to squash the commits before merging 👍 |
Add general tests (none before) slight refactor tests pass oops uncomment (was troubleshooting) move attr_reader up and actually use them in this class fix typo in test context string remove call to super in `stop` method use Stub.stoppable_sleep(Float::INFINITY){ stop? }, remove own thread ivar move mocks to own file + DRY up specs. closes 3
Merged sucessfully into master! |
Shutdown semantics: Add stop method and shared_example
Add general tests (none before)
slight refactor
tests pass
Notes for Reviewers:
require
s are not lazy loaded.initialize
method.Closes #3