Skip to content

Commit

Permalink
fix notification args problem [fix 765]
Browse files Browse the repository at this point in the history
  • Loading branch information
e2 committed Jun 8, 2015
1 parent 360f504 commit 3d66e36
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
9 changes: 9 additions & 0 deletions features/init.feature
Expand Up @@ -21,3 +21,12 @@ Feature: Guard "init" command
When I run `guard init rspec`
Then the output should match /rspec guard added to Guardfile, feel free to edit it$/
And the file "Guardfile" should match /^guard :rspec, cmd: ['"]bundle exec rspec["'] do$/

Scenario: Add plugin when Guardfile contains only options
Given my Guardfile contains:
"""
notification :off
"""
When I run `guard init rspec`
Then the output should match /rspec guard added to Guardfile, feel free to edit it$/
And the file "Guardfile" should match /^guard :rspec, cmd: ['"]bundle exec rspec["'] do$/
2 changes: 1 addition & 1 deletion lib/guard/dsl_reader.rb
Expand Up @@ -15,7 +15,7 @@ def guard(name, _options = {})
end

# Stub everything else
def notification
def notification(_notifier, _opts = {})
end

def interactor(_options)
Expand Down
38 changes: 38 additions & 0 deletions spec/lib/guard/dsl_reader_spec.rb
@@ -0,0 +1,38 @@
require "guard/dsl_reader"

RSpec.describe Guard::DslReader, exclude_stubs: [Guard::Dsl] do
methods = %w(
initialize guard notification interactor group watch callback
ignore ignore! logger scope directories clearing
).map(&:to_sym)

methods.each do |meth|
describe "\##{meth} signature" do
it "matches base signature" do
expected = Guard::Dsl.instance_method(meth).arity
expect(subject.method(meth).arity).to eq(expected)
end
end
end

describe "guard" do
it "works without errors" do
expect { subject.guard("foo", bar: :baz) }.to_not raise_error
end
end

describe "plugin_names" do
it "returns encountered names" do
subject.guard("foo", bar: :baz)
subject.guard("bar", bar: :baz)
subject.guard("baz", bar: :baz)
expect(subject.plugin_names).to eq(%w(foo bar baz))
end
end

describe "notification" do
it "handles arguments without errors" do
expect { subject.notification(:off) }.to_not raise_error
end
end
end

0 comments on commit 3d66e36

Please sign in to comment.