Improved deprecation warning message
This commit is contained in:
parent
1831bf752f
commit
ebe94d213b
@ -9,7 +9,8 @@ module Guard
|
|||||||
# deprecation warning
|
# deprecation warning
|
||||||
if @pattern.is_a?(String) && @pattern =~ /(^(\^))|(>?(\\\.)|(\.\*))|(\(.*\))|(\[.*\])|(\$$)/
|
if @pattern.is_a?(String) && @pattern =~ /(^(\^))|(>?(\\\.)|(\.\*))|(\(.*\))|(\[.*\])|(\$$)/
|
||||||
unless @@warning_printed
|
unless @@warning_printed
|
||||||
UI.info "DEPRECATED!\nYou have strings in your Guardfile's watch patterns that seem to represent regexps.\nGuard matchs String with == and Regexp with Regexp#match.\nYou should either use plain String (without Regexp special characters) or real Regexp.\n"
|
UI.info "*"*20 + "\nDEPRECATION WARNING!\n" + "*"*20
|
||||||
|
UI.info "You have strings in your Guardfile's watch patterns that seem to represent regexps.\nGuard matchs String with == and Regexp with Regexp#match.\nYou should either use plain String (without Regexp special characters) or real Regexp.\n"
|
||||||
@@warning_printed = true
|
@@warning_printed = true
|
||||||
end
|
end
|
||||||
UI.info "\"#{@pattern}\" has been converted to #{Regexp.new(@pattern).inspect}\n"
|
UI.info "\"#{@pattern}\" has been converted to #{Regexp.new(@pattern).inspect}\n"
|
||||||
|
@ -51,12 +51,12 @@ describe Guard::Watcher do
|
|||||||
describe "a watcher's action with an arity equal to 0" do
|
describe "a watcher's action with an arity equal to 0" do
|
||||||
before(:all) do
|
before(:all) do
|
||||||
@guard.watchers = [
|
@guard.watchers = [
|
||||||
Guard::Watcher.new(/spec_helper\.rb/, lambda { 'spec' }),
|
Guard::Watcher.new('spec_helper.rb', lambda { 'spec' }),
|
||||||
Guard::Watcher.new(/addition\.rb/, lambda { 1 + 1 }),
|
Guard::Watcher.new('addition.rb', lambda { 1 + 1 }),
|
||||||
Guard::Watcher.new(/hash\.rb/, lambda { Hash[:foo, 'bar'] }),
|
Guard::Watcher.new('hash.rb', lambda { Hash[:foo, 'bar'] }),
|
||||||
Guard::Watcher.new(/array\.rb/, lambda { ['foo', 'bar'] }),
|
Guard::Watcher.new('array.rb', lambda { ['foo', 'bar'] }),
|
||||||
Guard::Watcher.new(/blank\.rb/, lambda { '' }),
|
Guard::Watcher.new('blank.rb', lambda { '' }),
|
||||||
Guard::Watcher.new(/uptime\.rb/, lambda { `uptime > /dev/null` })
|
Guard::Watcher.new('uptime.rb', lambda { `uptime > /dev/null` })
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ describe Guard::Watcher do
|
|||||||
@guard.watchers = [
|
@guard.watchers = [
|
||||||
Guard::Watcher.new(%r{lib/(.*)\.rb}, lambda { |m| "spec/#{m[1]}_spec.rb" }),
|
Guard::Watcher.new(%r{lib/(.*)\.rb}, lambda { |m| "spec/#{m[1]}_spec.rb" }),
|
||||||
Guard::Watcher.new(/addition(.*)\.rb/, lambda { |m| 1 + 1 }),
|
Guard::Watcher.new(/addition(.*)\.rb/, lambda { |m| 1 + 1 }),
|
||||||
Guard::Watcher.new(/hash\.rb/, lambda { Hash[:foo, 'bar'] }),
|
Guard::Watcher.new('hash.rb', lambda { Hash[:foo, 'bar'] }),
|
||||||
Guard::Watcher.new(/array(.*)\.rb/, lambda { |m| ['foo', 'bar'] }),
|
Guard::Watcher.new(/array(.*)\.rb/, lambda { |m| ['foo', 'bar'] }),
|
||||||
Guard::Watcher.new(/blank(.*)\.rb/, lambda { |m| '' }),
|
Guard::Watcher.new(/blank(.*)\.rb/, lambda { |m| '' }),
|
||||||
Guard::Watcher.new(/uptime(.*)\.rb/, lambda { |m| `uptime > /dev/null` })
|
Guard::Watcher.new(/uptime(.*)\.rb/, lambda { |m| `uptime > /dev/null` })
|
||||||
@ -125,7 +125,7 @@ describe Guard::Watcher do
|
|||||||
describe ".match_files?" do
|
describe ".match_files?" do
|
||||||
before(:all) do
|
before(:all) do
|
||||||
@guard1 = Guard::Guard.new([Guard::Watcher.new(/.*_spec\.rb/)])
|
@guard1 = Guard::Guard.new([Guard::Watcher.new(/.*_spec\.rb/)])
|
||||||
@guard2 = Guard::Guard.new([Guard::Watcher.new(/spec_helper\.rb/, 'spec')])
|
@guard2 = Guard::Guard.new([Guard::Watcher.new('spec_helper.rb', 'spec')])
|
||||||
@guards = [@guard1, @guard2]
|
@guards = [@guard1, @guard2]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user