Skip to content
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

Open
wants to merge 66 commits into
base: master
Choose a base branch
from

Conversation

rymai
Copy link
Member

@rymai rymai commented Jun 17, 2017

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

lib/guard/api.rb Outdated Show resolved Hide resolved
lib/guard/api.rb Outdated Show resolved Hide resolved
lib/guard/api.rb Outdated Show resolved Hide resolved
lib/guard/api.rb Outdated Show resolved Hide resolved
lib/guard/api.rb Outdated Show resolved Hide resolved
lib/guard/api.rb Outdated Show resolved Hide resolved
lib/guard/api.rb Outdated Show resolved Hide resolved
lib/guard/api.rb Outdated Show resolved Hide resolved
lib/guard/api.rb Outdated Show resolved Hide resolved
lib/guard/api.rb Outdated Show resolved Hide resolved
@thibaudgg
Copy link
Member

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
Copy link
Member

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] = [] }
Copy link
Member

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::", "")
Copy link
Member

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?

Copy link
Member

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?

Copy link
Member Author

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))
Copy link
Member

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?

@ioquatix
Copy link
Member

Just for comparison, a long time ago I wrote a general EventEmitter like controller class. It might be interesting just to eye over https://github.com/ioquatix/synco/blob/master/lib/synco/controller.rb as it handles generic events. It's a bit more complex as I needed to be able to nest things easily, but it's an interesting idea, especially #try method, and looks a (tiny) bit similar to things like add_callback, etc.

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>
spec/lib/guard/plugin_spec.rb Outdated Show resolved Hide resolved
spec/lib/guard/plugin_spec.rb Outdated Show resolved Hide resolved
spec/lib/guard/plugin_spec.rb Outdated Show resolved Hide resolved
spec/lib/guard/dsl_describer_spec.rb Outdated Show resolved Hide resolved
spec/lib/guard/deprecated/guard_spec.rb Outdated Show resolved Hide resolved
spec/lib/guard/commands/pause_spec.rb Outdated Show resolved Hide resolved
spec/lib/guard/commands/notification_spec.rb Outdated Show resolved Hide resolved
spec/lib/guard/commands/change_spec.rb Outdated Show resolved Hide resolved
spec/lib/guard/commands/all_spec.rb Outdated Show resolved Hide resolved
lib/guard/api.rb Outdated Show resolved Hide resolved
Signed-off-by: Rémy Coutable <remy@rymai.me>
{ name: :gntp, options: { sticky: true } }
]
])

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 } }
]
])

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] * ','}!"

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]

spec/spec_helper.rb Outdated Show resolved Hide resolved
spec/spec_helper.rb Outdated Show resolved Hide resolved
spec/spec_helper.rb Outdated Show resolved Hide resolved
spec/spec_helper.rb Outdated Show resolved Hide resolved
# Initialize before Guard::Interactor const is stubbed
let!(:interactor) { instance_double("Guard::Interactor") }
describe '.init' do
it 'creates a new Engine object' do

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

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

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

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

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

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 }

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"

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"

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

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]

spec/lib/guard/internals/plugins_spec.rb Outdated Show resolved Hide resolved
@@ -0,0 +1,7 @@
RSpec.shared_context 'with fake_pry_class' do

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] * ','}!"

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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
rymai and others added 29 commits November 9, 2018 08:08
Co-Authored-By: chadmetcalf <chadmetcalf@users.noreply.github.com>
Signed-off-by: Rémy Coutable <remy@rymai.me>
Add a "Reviewed by Hound" badge
 - Avoid warnings like:  [UnknownParam] @param tag has unknown parameter name: options
   - jruby-9.1.17.0, jruby-9.2.6.0
  - rbx-3.107
CI: Use 2.4.6, 2.5.5, 2.6.2...
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

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)

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)

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)

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

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

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

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

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

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants