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
[RFC] Add a Guard::API module that Guard plugins should include #873
base: master
Are you sure you want to change the base?
Conversation
Looks good to me! 👍 |
lib/guard/api.rb
Outdated
def self.included(base) | ||
base.extend(ClassMethods) | ||
base.class_eval do | ||
attr_accessor :group, :watchers, :callbacks, :options |
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 suggest you add documentation.
lib/guard/api.rb
Outdated
# Guardfile. | ||
# | ||
def callbacks | ||
@callbacks ||= Hash.new { |hash, key| hash[key] = [] } |
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 think Ruby will complain about this as it wasn't defined prior. Unfortunately, I think you need to do something like this: https://github.com/ioquatix/utopia/blob/9239e84edfeaf7177f74ae9408c4e16468faa505/lib/utopia/controller/actions.rb#L126-L131
Check by running tests with warnings turned on.
lib/guard/api.rb
Outdated
# @return [String] | ||
# | ||
def non_namespaced_classname | ||
to_s.sub("Guard::", "") |
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.
What's this used for? What about to_s.split('::').last
?
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.
Will this work for, say, Guard::Falcon::Plugin
- what is the desired output?
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 think the desired output would be Falcon
in the last case.
# @param [String] plugin_location the plugin location | ||
# | ||
def template(plugin_location) | ||
File.read(format(TEMPLATE_FORMAT, plugin_location, non_namespaced_name)) |
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.
Can we do something better than this? Rather than putting templates in lib/...
, which is a tiny bit odd since it's not code - why not put it in templates/
of root of gem?
Just for comparison, a long time ago I wrote a general How does this allow us to avoid global state? I don't think there is something fundamentally wrong with inheritance, but I do have an extreme distaste for global state in general. So, for me, I'm more interested in how you propose to reduce global state/API. |
This is a first step toward a sanitized plugin architecture: Mixin instead of inheritance. Signed-off-by: Rémy Coutable <remy@rymai.me>
Signed-off-by: Rémy Coutable <remy@rymai.me>
{ name: :gntp, options: { sticky: true } } | ||
] | ||
]) |
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.
Indent the right bracket the same as the first position after the preceding left parenthesis.
{ name: :gntp, options: { sticky: true } } | ||
] | ||
]) |
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.
Indent the right bracket the same as the first position after the preceding left parenthesis.
Signed-off-by: Rémy Coutable <remy@rymai.me>
end | ||
# | ||
# allow(ENV).to receive(:[]=) do |*args| | ||
# abort "stub me: ENV[#{args.first}]= #{args.map(&:inspect)[1..-1] * ','}!" |
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.
Line is too long. [81/80]
# Initialize before Guard::Interactor const is stubbed | ||
let!(:interactor) { instance_double("Guard::Interactor") } | ||
describe '.init' do | ||
it 'creates a new Engine object' do |
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.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
@@ -1,247 +1,13 @@ | |||
require "guard" | |||
|
|||
RSpec.describe Guard do | |||
# Initialize before Guard::Interactor const is stubbed | |||
let!(:interactor) { instance_double("Guard::Interactor") } | |||
describe '.init' do |
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.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
|
||
it "returns :task_has_failed" do | ||
symbol = described_class.stopping_symbol_for(guard_plugin) | ||
expect(symbol).to eq :task_has_failed | ||
expect(described_class.stopping_symbol_for(foo_plugin)).to eq :task_has_failed |
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.
Line is too long. [86/80]
end | ||
end | ||
|
||
describe "#run_on_changes" do |
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.
Block has too many lines. [103/25]
end | ||
end | ||
|
||
context "with a task that succeeds" do |
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.
Block has too many lines. [27/25]
@@ -164,7 +155,7 @@ class DashedClassName | |||
|
|||
context "with a name with underscores" do | |||
it "returns the Guard class" do | |||
plugin = described_class.new("underscore_class_name") | |||
plugin = described_class.new(engine: engine, name: "underscore_class_name") |
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.
Line is too long. [83/80]
end | ||
it "instantiate the plugin" do | ||
options = { watchers: ["watcher"], group: "foo" } | ||
expect(guard_rspec_class).to receive(:new).with(engine: engine, options: options) { guard_rspec } |
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.
Line is too long. [103/80]
end | ||
|
||
it "accepts a name with guard-" do | ||
expect(described_class.new("guard-rspec").name).to eq "rspec" | ||
expect(described_class.new(engine: engine, name: "guard-rspec").name).to eq "rspec" |
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.
Line is too long. [89/80]
@@ -52,39 +47,35 @@ | |||
|
|||
describe "#initialize" do | |||
it "accepts a name without guard-" do | |||
expect(described_class.new("rspec").name).to eq "rspec" | |||
expect(described_class.new(engine: engine, name: "rspec").name).to eq "rspec" |
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.
Line is too long. [83/80]
end | ||
|
||
it "returns a plugin and group scope" do | ||
scopes, = subject.convert_scope %w(foo backend) | ||
expect(scopes).to eq(plugins: [foo], groups: [backend]) | ||
|
||
expect(scopes).to eq(plugins: [subject.plugins.find(:foo)], groups: [subject.groups.find(:backend)]) |
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.
Line is too long. [106/80]
@@ -0,0 +1,7 @@ | |||
RSpec.shared_context 'with fake_pry_class' do |
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.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
# end | ||
# | ||
# allow(ENV).to receive(:[]=) do |*args| | ||
# abort "stub me: ENV[#{args.first}]= #{args.map(&:inspect)[1..-1] * ','}!" |
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.
Line is too long. [81/80]
# excluded << Guard::Internals::Queue if Guard.constants.include?(:Internals) | ||
# excluded << Guard::Internals::Scope if Guard.constants.include?(:Internals) | ||
# excluded << Guard::Internals::Session if Guard.constants.include?(:Internals) | ||
# excluded << Guard::Internals::State if Guard.constants.include?(:Internals) |
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.
Line is too long. [81/80]
# excluded << Guard::Internals::Plugins if Guard.constants.include?(:Internals) | ||
# excluded << Guard::Internals::Queue if Guard.constants.include?(:Internals) | ||
# excluded << Guard::Internals::Scope if Guard.constants.include?(:Internals) | ||
# excluded << Guard::Internals::Session if Guard.constants.include?(:Internals) |
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.
Line is too long. [83/80]
# excluded << Guard::Internals::Groups if Guard.constants.include?(:Internals) | ||
# excluded << Guard::Internals::Plugins if Guard.constants.include?(:Internals) | ||
# excluded << Guard::Internals::Queue if Guard.constants.include?(:Internals) | ||
# excluded << Guard::Internals::Scope if Guard.constants.include?(:Internals) |
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.
Line is too long. [81/80]
# excluded << Guard::Jobs::TerminalSettings if Guard.constants.include?(:Jobs) | ||
# excluded << Guard::Internals::Groups if Guard.constants.include?(:Internals) | ||
# excluded << Guard::Internals::Plugins if Guard.constants.include?(:Internals) | ||
# excluded << Guard::Internals::Queue if Guard.constants.include?(:Internals) |
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.
Line is too long. [81/80]
# excluded << Guard::Jobs::PryWrapper if Guard.constants.include?(:Jobs) | ||
# excluded << Guard::Jobs::TerminalSettings if Guard.constants.include?(:Jobs) | ||
# excluded << Guard::Internals::Groups if Guard.constants.include?(:Internals) | ||
# excluded << Guard::Internals::Plugins if Guard.constants.include?(:Internals) |
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.
Line is too long. [83/80]
# excluded << Guard::Jobs::Base if Guard.constants.include?(:Jobs) | ||
# excluded << Guard::Jobs::PryWrapper if Guard.constants.include?(:Jobs) | ||
# excluded << Guard::Jobs::TerminalSettings if Guard.constants.include?(:Jobs) | ||
# excluded << Guard::Internals::Groups if Guard.constants.include?(:Internals) |
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.
Line is too long. [82/80]
# excluded << Guard::Options if Guard.constants.include?(:Options) | ||
# excluded << Guard::Jobs::Base if Guard.constants.include?(:Jobs) | ||
# excluded << Guard::Jobs::PryWrapper if Guard.constants.include?(:Jobs) | ||
# excluded << Guard::Jobs::TerminalSettings if Guard.constants.include?(:Jobs) |
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.
Line is too long. [82/80]
# excluded << Guard::Commands::Notification if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Notification) | ||
# excluded << Guard::Commands::Pause if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Pause) | ||
# excluded << Guard::Commands::Reload if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Reload) | ||
# excluded << Guard::Commands::Scope if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Scope) |
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.
Line is too long. [125/80]
# excluded << Guard::Commands::Change if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Change) | ||
# excluded << Guard::Commands::Notification if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Notification) | ||
# excluded << Guard::Commands::Pause if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Pause) | ||
# excluded << Guard::Commands::Reload if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Reload) |
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.
Line is too long. [127/80]
# excluded << Guard::Commands::All if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:All) | ||
# excluded << Guard::Commands::Change if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Change) | ||
# excluded << Guard::Commands::Notification if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Notification) | ||
# excluded << Guard::Commands::Pause if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Pause) |
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.
Line is too long. [125/80]
# excluded << Guard::Engine if Guard.constants.include?(:Engine) | ||
# excluded << Guard::Commands::All if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:All) | ||
# excluded << Guard::Commands::Change if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Change) | ||
# excluded << Guard::Commands::Notification if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Notification) |
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.
Line is too long. [139/80]
# excluded += Array(example.metadata[:exclude_stubs]) | ||
# excluded << Guard::Engine if Guard.constants.include?(:Engine) | ||
# excluded << Guard::Commands::All if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:All) | ||
# excluded << Guard::Commands::Change if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Change) |
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.
Line is too long. [127/80]
# excluded << Guard::Internals::Groups if Guard.constants.include?(:Internals) | ||
# excluded << Guard::Internals::Plugins if Guard.constants.include?(:Internals) | ||
# excluded << Guard::Internals::Queue if Guard.constants.include?(:Internals) | ||
# excluded << Guard::Internals::Scope if Guard.constants.include?(:Internals) |
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.
Line is too long. [81/80]
# excluded << Guard::Jobs::TerminalSettings if Guard.constants.include?(:Jobs) | ||
# excluded << Guard::Internals::Groups if Guard.constants.include?(:Internals) | ||
# excluded << Guard::Internals::Plugins if Guard.constants.include?(:Internals) | ||
# excluded << Guard::Internals::Queue if Guard.constants.include?(:Internals) |
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.
Line is too long. [81/80]
# excluded << Guard::Jobs::PryWrapper if Guard.constants.include?(:Jobs) | ||
# excluded << Guard::Jobs::TerminalSettings if Guard.constants.include?(:Jobs) | ||
# excluded << Guard::Internals::Groups if Guard.constants.include?(:Internals) | ||
# excluded << Guard::Internals::Plugins if Guard.constants.include?(:Internals) |
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.
Line is too long. [83/80]
# excluded << Guard::Jobs::Base if Guard.constants.include?(:Jobs) | ||
# excluded << Guard::Jobs::PryWrapper if Guard.constants.include?(:Jobs) | ||
# excluded << Guard::Jobs::TerminalSettings if Guard.constants.include?(:Jobs) | ||
# excluded << Guard::Internals::Groups if Guard.constants.include?(:Internals) |
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.
Line is too long. [82/80]
# excluded << Guard::Options if Guard.constants.include?(:Options) | ||
# excluded << Guard::Jobs::Base if Guard.constants.include?(:Jobs) | ||
# excluded << Guard::Jobs::PryWrapper if Guard.constants.include?(:Jobs) | ||
# excluded << Guard::Jobs::TerminalSettings if Guard.constants.include?(:Jobs) |
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.
Line is too long. [82/80]
# excluded << Guard::Commands::Notification if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Notification) | ||
# excluded << Guard::Commands::Pause if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Pause) | ||
# excluded << Guard::Commands::Reload if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Reload) | ||
# excluded << Guard::Commands::Scope if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Scope) |
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.
Line is too long. [125/80]
# excluded << Guard::Commands::Change if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Change) | ||
# excluded << Guard::Commands::Notification if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Notification) | ||
# excluded << Guard::Commands::Pause if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Pause) | ||
# excluded << Guard::Commands::Reload if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Reload) |
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.
Line is too long. [127/80]
# excluded << Guard::Commands::All if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:All) | ||
# excluded << Guard::Commands::Change if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Change) | ||
# excluded << Guard::Commands::Notification if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Notification) | ||
# excluded << Guard::Commands::Pause if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Pause) |
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.
Line is too long. [125/80]
# excluded << Guard::Engine if Guard.constants.include?(:Engine) | ||
# excluded << Guard::Commands::All if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:All) | ||
# excluded << Guard::Commands::Change if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Change) | ||
# excluded << Guard::Commands::Notification if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Notification) |
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.
Line is too long. [139/80]
# excluded += Array(example.metadata[:exclude_stubs]) | ||
# excluded << Guard::Engine if Guard.constants.include?(:Engine) | ||
# excluded << Guard::Commands::All if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:All) | ||
# excluded << Guard::Commands::Change if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Change) |
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.
Line is too long. [127/80]
Signed-off-by: Rémy Coutable <remy@rymai.me>
Update rubocop to match hound Adapt hound style to new rubocop version Add style config file for specs Exclude vendor/**/* Default for rubocop is to overwrite arrays. This happens here and leads to uncomfortable usage of rubocop locally. Update target version to minimum supported version Autoupdate rubocop settings using mry
Co-Authored-By: chadmetcalf <chadmetcalf@users.noreply.github.com>
Pry 0.12.0 Deprecation warnings
Signed-off-by: Rémy Coutable <remy@rymai.me>
Bump to 2.15.0
Add a "Reviewed by Hound" badge
- Avoid warnings like: [UnknownParam] @param tag has unknown parameter name: options
Fix YARD annotation
- jruby-9.1.17.0, jruby-9.2.6.0 - rbx-3.107
CI: Use 2.4.6, 2.5.5, 2.6.2...
- service closed
README: Drop outdated badge for Gemnasium
Ruby 2.6 changed Pathname#read from using IO.read to File.read.
Signed-off-by: Rémy Coutable <remy@rymai.me>
Stub Pathname instead of IO.read in spec
Ensure Guard calls `#stop` even if an exception is raised
Add a `simplecov` filter for the `/spec` folder
This is a first step toward a sanitized plugin architecture: Mixin instead of inheritance. Signed-off-by: Rémy Coutable <remy@rymai.me>
Signed-off-by: Rémy Coutable <remy@rymai.me>
Signed-off-by: Rémy Coutable <remy@rymai.me>
Signed-off-by: Rémy Coutable <remy@rymai.me>
Signed-off-by: Rémy Coutable <remy@rymai.me>
Signed-off-by: Rémy Coutable <remy@rymai.me>
Signed-off-by: Rémy Coutable <remy@rymai.me>
@@ -0,0 +1,7 @@ | |||
RSpec.shared_context 'with fake_pry_class' do |
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.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
# excluded << Guard::Commands::Change if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Change) | ||
# excluded << Guard::Commands::Notification if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Notification) | ||
# excluded << Guard::Commands::Pause if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Pause) | ||
# excluded << Guard::Commands::Reload if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Reload) |
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.
Metrics/LineLength: Line is too long. [127/125]
# excluded << Guard::Engine if Guard.constants.include?(:Engine) | ||
# excluded << Guard::Commands::All if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:All) | ||
# excluded << Guard::Commands::Change if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Change) | ||
# excluded << Guard::Commands::Notification if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Notification) |
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.
Metrics/LineLength: Line is too long. [139/125]
# excluded += Array(example.metadata[:exclude_stubs]) | ||
# excluded << Guard::Engine if Guard.constants.include?(:Engine) | ||
# excluded << Guard::Commands::All if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:All) | ||
# excluded << Guard::Commands::Change if Guard.constants.include?(:Commands) && Guard::Commands.constants.include?(:Change) |
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.
Metrics/LineLength: Line is too long. [127/125]
subject | ||
end | ||
describe '.init' do | ||
it 'creates a new Engine object' do |
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.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
end | ||
end | ||
|
||
context "without a group in the options" do | ||
it "assigns a default group" do | ||
allow(groups).to receive(:add).with(:default).and_return(default) | ||
expect(Guard::Plugin.new.group).to eq default | ||
expect(Guard::Bar.new(engine: engine).group). |
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.
Layout/DotPosition: Place the . on the next line, together with the method name.
end | ||
|
||
context "with a group in the options" do | ||
it "assigns the given group" do | ||
expect(Guard::Plugin.new(group: :test).group).to eq test | ||
expect(Guard::Bar.new(engine: engine, options: { group: :test }).group). |
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.
Layout/DotPosition: Place the . on the next line, together with the method name.
it "display a deprecation message" do | ||
expect(Guard::UI).to receive(:deprecation). | ||
with(format(Guard::Deprecated::Plugin::INHERITHING_FROM_PLUGIN, | ||
"Bar", "/lib/guard/bar.rb", "Bar")) |
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.
Layout/AlignParameters: Align the parameters of a method call if they span more than one line.
end | ||
|
||
it "display a deprecation message" do | ||
expect(Guard::UI).to receive(:deprecation). |
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.
Layout/DotPosition: Place the . on the next line, together with the method name.
end | ||
|
||
describe "#initialize" do | ||
it "assigns the defined watchers" do | ||
watchers = [double("foo")] | ||
expect(Guard::Plugin.new(watchers: watchers).watchers).to eq watchers | ||
|
||
expect(Guard::Bar.new(engine: engine, options: { watchers: watchers }).watchers). |
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.
Layout/DotPosition: Place the . on the next line, together with the method name.
This is a first step toward a sanitized plugin architecture: Mixin instead of inheritance.
@ioquatix @e2 @thibaudgg What do you think?
Compatibility layer has been added at guard/guard-compat#6.
Example of implementation for
guard-rspec
can be found at guard/guard-rspec#397.Related to #691 and #713 (comment).