Refactor & fix specs
This commit is contained in:
parent
916613c027
commit
1cd669bf60
@ -6,8 +6,6 @@ describe Guard::DslDescriber do
|
|||||||
user_config_path = File.expand_path(File.join('~', '.guard.rb'))
|
user_config_path = File.expand_path(File.join('~', '.guard.rb'))
|
||||||
File.stub(:exist?).with(user_config_path) { false }
|
File.stub(:exist?).with(user_config_path) { false }
|
||||||
end
|
end
|
||||||
subject { described_class }
|
|
||||||
|
|
||||||
|
|
||||||
it 'should evaluate a Guardfile and create the right structure' do
|
it 'should evaluate a Guardfile and create the right structure' do
|
||||||
mixed_guardfile_string = <<-GUARD
|
mixed_guardfile_string = <<-GUARD
|
||||||
@ -28,13 +26,13 @@ group "b" do
|
|||||||
end
|
end
|
||||||
GUARD
|
GUARD
|
||||||
|
|
||||||
subject.evaluate_guardfile(:guardfile_contents => mixed_guardfile_string)
|
described_class.evaluate_guardfile(:guardfile_contents => mixed_guardfile_string)
|
||||||
|
|
||||||
subject.guardfile_structure.should == [
|
described_class.guardfile_structure.should == [
|
||||||
{ :guards => [ { :name => 'test', :options => { :a => :b } } ] },
|
{ :guards => [ { :name => 'test', :options => { :a => :b } } ] },
|
||||||
{ :group => :a, :guards => [ { :name => 'test', :options => {} } ] },
|
{ :group => :a, :guards => [ { :name => 'test', :options => {} } ] },
|
||||||
{ :group => :b, :guards => [ { :name => 'another', :options => {} } ] }
|
{ :group => :b, :guards => [ { :name => 'another', :options => {} } ] }
|
||||||
]
|
]
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
|||||||
require 'guard/guard'
|
require 'guard/guard'
|
||||||
|
|
||||||
describe Guard::Dsl do
|
describe Guard::Dsl do
|
||||||
subject { described_class }
|
|
||||||
class Guard::Dummy < Guard::Guard; end
|
class Guard::Dummy < Guard::Guard; end
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@ -24,24 +24,24 @@ describe Guard::Dsl do
|
|||||||
|
|
||||||
it "should use a string for initializing" do
|
it "should use a string for initializing" do
|
||||||
Guard::UI.should_not_receive(:error)
|
Guard::UI.should_not_receive(:error)
|
||||||
lambda { subject.evaluate_guardfile(:guardfile_contents => valid_guardfile_string) }.should_not raise_error
|
lambda { described_class.evaluate_guardfile(:guardfile_contents => valid_guardfile_string) }.should_not raise_error
|
||||||
subject.guardfile_contents.should == valid_guardfile_string
|
described_class.guardfile_contents.should == valid_guardfile_string
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should use a given file over the default loc" do
|
it "should use a given file over the default loc" do
|
||||||
fake_guardfile('/abc/Guardfile', "guard :foo")
|
fake_guardfile('/abc/Guardfile', "guard :foo")
|
||||||
|
|
||||||
Guard::UI.should_not_receive(:error)
|
Guard::UI.should_not_receive(:error)
|
||||||
lambda { subject.evaluate_guardfile(:guardfile => '/abc/Guardfile') }.should_not raise_error
|
lambda { described_class.evaluate_guardfile(:guardfile => '/abc/Guardfile') }.should_not raise_error
|
||||||
subject.guardfile_contents.should == "guard :foo"
|
described_class.guardfile_contents.should == "guard :foo"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should use a default file if no other options are given" do
|
it "should use a default file if no other options are given" do
|
||||||
fake_guardfile(@local_guardfile_path, "guard :bar")
|
fake_guardfile(@local_guardfile_path, "guard :bar")
|
||||||
|
|
||||||
Guard::UI.should_not_receive(:error)
|
Guard::UI.should_not_receive(:error)
|
||||||
lambda { subject.evaluate_guardfile }.should_not raise_error
|
lambda { described_class.evaluate_guardfile }.should_not raise_error
|
||||||
subject.guardfile_contents.should == "guard :bar"
|
described_class.guardfile_contents.should == "guard :bar"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should use a string over any other method" do
|
it "should use a string over any other method" do
|
||||||
@ -49,8 +49,8 @@ describe Guard::Dsl do
|
|||||||
fake_guardfile(@local_guardfile_path, "guard :bar")
|
fake_guardfile(@local_guardfile_path, "guard :bar")
|
||||||
|
|
||||||
Guard::UI.should_not_receive(:error)
|
Guard::UI.should_not_receive(:error)
|
||||||
lambda { subject.evaluate_guardfile(:guardfile_contents => valid_guardfile_string) }.should_not raise_error
|
lambda { described_class.evaluate_guardfile(:guardfile_contents => valid_guardfile_string) }.should_not raise_error
|
||||||
subject.guardfile_contents.should == valid_guardfile_string
|
described_class.guardfile_contents.should == valid_guardfile_string
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should use the given Guardfile over default Guardfile" do
|
it "should use the given Guardfile over default Guardfile" do
|
||||||
@ -58,31 +58,31 @@ describe Guard::Dsl do
|
|||||||
fake_guardfile(@local_guardfile_path, "guard :bar")
|
fake_guardfile(@local_guardfile_path, "guard :bar")
|
||||||
|
|
||||||
Guard::UI.should_not_receive(:error)
|
Guard::UI.should_not_receive(:error)
|
||||||
lambda { subject.evaluate_guardfile(:guardfile => '/abc/Guardfile') }.should_not raise_error
|
lambda { described_class.evaluate_guardfile(:guardfile => '/abc/Guardfile') }.should_not raise_error
|
||||||
subject.guardfile_contents.should == "guard :foo"
|
described_class.guardfile_contents.should == "guard :foo"
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should append the user config file if present' do
|
it 'should append the user config file if present' do
|
||||||
fake_guardfile('/abc/Guardfile', "guard :foo")
|
fake_guardfile('/abc/Guardfile', "guard :foo")
|
||||||
fake_guardfile(@user_config_path, "guard :bar")
|
fake_guardfile(@user_config_path, "guard :bar")
|
||||||
Guard::UI.should_not_receive(:error)
|
Guard::UI.should_not_receive(:error)
|
||||||
lambda { subject.evaluate_guardfile(:guardfile => '/abc/Guardfile') }.should_not raise_error
|
lambda { described_class.evaluate_guardfile(:guardfile => '/abc/Guardfile') }.should_not raise_error
|
||||||
subject.guardfile_contents_with_user_config.should == "guard :foo\nguard :bar"
|
described_class.guardfile_contents_with_user_config.should == "guard :foo\nguard :bar"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "displays an error message when no Guardfile is found" do
|
it "displays an error message when no Guardfile is found" do
|
||||||
subject.stub(:guardfile_default_path).and_return("no_guardfile_here")
|
described_class.stub(:guardfile_default_path).and_return("no_guardfile_here")
|
||||||
Guard::UI.should_receive(:error).with("No Guardfile found, please create one with `guard init`.")
|
Guard::UI.should_receive(:error).with("No Guardfile found, please create one with `guard init`.")
|
||||||
lambda { subject.evaluate_guardfile }.should raise_error
|
lambda { described_class.evaluate_guardfile }.should raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
it "displays an error message when no guard are defined in Guardfile" do
|
it "displays an error message when no guard are defined in Guardfile" do
|
||||||
::Guard::Dsl.stub!(:instance_eval_guardfile)
|
::Guard::Dsl.stub!(:instance_eval_guardfile)
|
||||||
::Guard.stub!(:guards).and_return([])
|
::Guard.stub!(:guards).and_return([])
|
||||||
Guard::UI.should_receive(:error)
|
Guard::UI.should_receive(:error)
|
||||||
subject.evaluate_guardfile(:guardfile_contents => valid_guardfile_string)
|
described_class.evaluate_guardfile(:guardfile_contents => valid_guardfile_string)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "correctly reads data from its valid data source" do
|
describe "correctly reads data from its valid data source" do
|
||||||
@ -90,22 +90,22 @@ describe Guard::Dsl do
|
|||||||
disable_user_config
|
disable_user_config
|
||||||
|
|
||||||
it "reads correctly from a string" do
|
it "reads correctly from a string" do
|
||||||
lambda { subject.evaluate_guardfile(:guardfile_contents => valid_guardfile_string) }.should_not raise_error
|
lambda { described_class.evaluate_guardfile(:guardfile_contents => valid_guardfile_string) }.should_not raise_error
|
||||||
subject.guardfile_contents.should == valid_guardfile_string
|
described_class.guardfile_contents.should == valid_guardfile_string
|
||||||
end
|
end
|
||||||
|
|
||||||
it "reads correctly from a Guardfile" do
|
it "reads correctly from a Guardfile" do
|
||||||
fake_guardfile('/abc/Guardfile', "guard :foo" )
|
fake_guardfile('/abc/Guardfile', "guard :foo" )
|
||||||
|
|
||||||
lambda { subject.evaluate_guardfile(:guardfile => '/abc/Guardfile') }.should_not raise_error
|
lambda { described_class.evaluate_guardfile(:guardfile => '/abc/Guardfile') }.should_not raise_error
|
||||||
subject.guardfile_contents.should == "guard :foo"
|
described_class.guardfile_contents.should == "guard :foo"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "reads correctly from a Guardfile" do
|
it "reads correctly from a Guardfile" do
|
||||||
fake_guardfile(File.join(Dir.pwd, 'Guardfile'), valid_guardfile_string)
|
fake_guardfile(File.join(Dir.pwd, 'Guardfile'), valid_guardfile_string)
|
||||||
|
|
||||||
lambda { subject.evaluate_guardfile }.should_not raise_error
|
lambda { described_class.evaluate_guardfile }.should_not raise_error
|
||||||
subject.guardfile_contents.should == valid_guardfile_string
|
described_class.guardfile_contents.should == valid_guardfile_string
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -117,14 +117,14 @@ describe Guard::Dsl do
|
|||||||
File.stub!(:read).with('/def/Guardfile') { raise Errno::EACCES.new("permission error") }
|
File.stub!(:read).with('/def/Guardfile') { raise Errno::EACCES.new("permission error") }
|
||||||
|
|
||||||
Guard::UI.should_receive(:error).with(/^Error reading file/)
|
Guard::UI.should_receive(:error).with(/^Error reading file/)
|
||||||
lambda { subject.evaluate_guardfile(:guardfile => '/def/Guardfile') }.should raise_error
|
lambda { described_class.evaluate_guardfile(:guardfile => '/def/Guardfile') }.should raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises error when given Guardfile doesn't exist" do
|
it "raises error when given Guardfile doesn't exist" do
|
||||||
File.stub!(:exist?).with('/def/Guardfile') { false }
|
File.stub!(:exist?).with('/def/Guardfile') { false }
|
||||||
|
|
||||||
Guard::UI.should_receive(:error).with(/No Guardfile exists at/)
|
Guard::UI.should_receive(:error).with(/No Guardfile exists at/)
|
||||||
lambda { subject.evaluate_guardfile(:guardfile => '/def/Guardfile') }.should raise_error
|
lambda { described_class.evaluate_guardfile(:guardfile => '/def/Guardfile') }.should raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises error when resorting to use default, finds no default" do
|
it "raises error when resorting to use default, finds no default" do
|
||||||
@ -132,24 +132,24 @@ describe Guard::Dsl do
|
|||||||
File.stub!(:exist?).with(@home_guardfile_path) { false }
|
File.stub!(:exist?).with(@home_guardfile_path) { false }
|
||||||
|
|
||||||
Guard::UI.should_receive(:error).with("No Guardfile found, please create one with `guard init`.")
|
Guard::UI.should_receive(:error).with("No Guardfile found, please create one with `guard init`.")
|
||||||
lambda { subject.evaluate_guardfile }.should raise_error
|
lambda { described_class.evaluate_guardfile }.should raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises error when guardfile_content ends up empty or nil" do
|
it "raises error when guardfile_content ends up empty or nil" do
|
||||||
Guard::UI.should_receive(:error).with(/The command file/)
|
Guard::UI.should_receive(:error).with(/The command file/)
|
||||||
lambda { subject.evaluate_guardfile(:guardfile_contents => "") }.should raise_error
|
lambda { described_class.evaluate_guardfile(:guardfile_contents => "") }.should raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't raise error when guardfile_content is nil (skipped)" do
|
it "doesn't raise error when guardfile_content is nil (skipped)" do
|
||||||
Guard::UI.should_not_receive(:error)
|
Guard::UI.should_not_receive(:error)
|
||||||
lambda { subject.evaluate_guardfile(:guardfile_contents => nil) }.should_not raise_error
|
lambda { described_class.evaluate_guardfile(:guardfile_contents => nil) }.should_not raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "displays an error message when Guardfile is not valid" do
|
it "displays an error message when Guardfile is not valid" do
|
||||||
Guard::UI.should_receive(:error).with(/Invalid Guardfile, original error is:/)
|
Guard::UI.should_receive(:error).with(/Invalid Guardfile, original error is:/)
|
||||||
|
|
||||||
lambda { subject.evaluate_guardfile(:guardfile_contents => invalid_guardfile_string ) }.should raise_error
|
lambda { described_class.evaluate_guardfile(:guardfile_contents => invalid_guardfile_string ) }.should raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".reevaluate_guardfile" do
|
describe ".reevaluate_guardfile" do
|
||||||
@ -157,10 +157,10 @@ describe Guard::Dsl do
|
|||||||
|
|
||||||
it "resets already definded guards before calling evaluate_guardfile" do
|
it "resets already definded guards before calling evaluate_guardfile" do
|
||||||
Guard::Notifier.turn_off
|
Guard::Notifier.turn_off
|
||||||
subject.evaluate_guardfile(:guardfile_contents => invalid_guardfile_string)
|
described_class.evaluate_guardfile(:guardfile_contents => invalid_guardfile_string)
|
||||||
::Guard.guards.should_not be_empty
|
::Guard.guards.should_not be_empty
|
||||||
::Guard::Dsl.should_receive(:evaluate_guardfile)
|
::Guard::Dsl.should_receive(:evaluate_guardfile)
|
||||||
subject.reevaluate_guardfile
|
described_class.reevaluate_guardfile
|
||||||
::Guard.guards.should be_empty
|
::Guard.guards.should be_empty
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -173,14 +173,14 @@ describe Guard::Dsl do
|
|||||||
context "when there is a local Guardfile" do
|
context "when there is a local Guardfile" do
|
||||||
it "returns the path to the local Guardfile" do
|
it "returns the path to the local Guardfile" do
|
||||||
File.stub(:exist?).with(local_path).and_return(true)
|
File.stub(:exist?).with(local_path).and_return(true)
|
||||||
subject.guardfile_default_path.should == local_path
|
described_class.guardfile_default_path.should == local_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when there is a Guardfile in the user's home directory" do
|
context "when there is a Guardfile in the user's home directory" do
|
||||||
it "returns the path to the user Guardfile" do
|
it "returns the path to the user Guardfile" do
|
||||||
File.stub(:exist?).with(user_path).and_return(true)
|
File.stub(:exist?).with(user_path).and_return(true)
|
||||||
subject.guardfile_default_path.should == user_path
|
described_class.guardfile_default_path.should == user_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -188,34 +188,34 @@ describe Guard::Dsl do
|
|||||||
it "returns the path to the local Guardfile" do
|
it "returns the path to the local Guardfile" do
|
||||||
File.stub(:exist?).with(local_path).and_return(true)
|
File.stub(:exist?).with(local_path).and_return(true)
|
||||||
File.stub(:exist?).with(user_path).and_return(true)
|
File.stub(:exist?).with(user_path).and_return(true)
|
||||||
subject.guardfile_default_path.should == local_path
|
described_class.guardfile_default_path.should == local_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".guardfile_include?" do
|
describe ".guardfile_include?" do
|
||||||
it "detects a guard specified by a string with double quotes" do
|
it "detects a guard specified by a string with double quotes" do
|
||||||
subject.stub(:guardfile_contents => 'guard "test" {watch("c")}')
|
described_class.stub(:guardfile_contents => 'guard "test" {watch("c")}')
|
||||||
|
|
||||||
subject.guardfile_include?('test').should be_true
|
described_class.guardfile_include?('test').should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "detects a guard specified by a string with single quote" do
|
it "detects a guard specified by a string with single quote" do
|
||||||
subject.stub(:guardfile_contents => 'guard \'test\' {watch("c")}')
|
described_class.stub(:guardfile_contents => 'guard \'test\' {watch("c")}')
|
||||||
|
|
||||||
subject.guardfile_include?('test').should be_true
|
described_class.guardfile_include?('test').should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "detects a guard specified by a symbol" do
|
it "detects a guard specified by a symbol" do
|
||||||
subject.stub(:guardfile_contents => 'guard :test {watch("c")}')
|
described_class.stub(:guardfile_contents => 'guard :test {watch("c")}')
|
||||||
|
|
||||||
subject.guardfile_include?('test').should be_true
|
described_class.guardfile_include?('test').should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "detects a guard wrapped in parentheses" do
|
it "detects a guard wrapped in parentheses" do
|
||||||
subject.stub(:guardfile_contents => 'guard(:test) {watch("c")}')
|
described_class.stub(:guardfile_contents => 'guard(:test) {watch("c")}')
|
||||||
|
|
||||||
subject.guardfile_include?('test').should be_true
|
described_class.guardfile_include?('test').should be_true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ describe Guard::Dsl do
|
|||||||
::Guard.stub!(:listener).and_return(mock('Listener'))
|
::Guard.stub!(:listener).and_return(mock('Listener'))
|
||||||
::Guard.listener.should_receive(:ignore_paths).and_return(ignore_paths = ['faz'])
|
::Guard.listener.should_receive(:ignore_paths).and_return(ignore_paths = ['faz'])
|
||||||
|
|
||||||
subject.evaluate_guardfile(:guardfile_contents => "ignore_paths 'foo', 'bar'")
|
described_class.evaluate_guardfile(:guardfile_contents => "ignore_paths 'foo', 'bar'")
|
||||||
ignore_paths.should == ['faz', 'foo', 'bar']
|
ignore_paths.should == ['faz', 'foo', 'bar']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -238,18 +238,14 @@ describe Guard::Dsl do
|
|||||||
::Guard.should_receive(:add_guard).with('pow', [], [], { :group => :default })
|
::Guard.should_receive(:add_guard).with('pow', [], [], { :group => :default })
|
||||||
::Guard.should_receive(:add_guard).with('test', [], [], { :group => :w })
|
::Guard.should_receive(:add_guard).with('test', [], [], { :group => :w })
|
||||||
|
|
||||||
subject.evaluate_guardfile(:guardfile_contents => valid_guardfile_string, :group => [:w])
|
described_class.evaluate_guardfile(:guardfile_contents => valid_guardfile_string, :group => [:w])
|
||||||
|
|
||||||
::Guard.groups.should eql [{ :name => :default, :options => {} }, { :name => :w, :options => {} }]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "evaluates only the specified symbol group" do
|
it "evaluates only the specified symbol group" do
|
||||||
::Guard.should_receive(:add_guard).with('pow', [], [], { :group => :default })
|
::Guard.should_receive(:add_guard).with('pow', [], [], { :group => :default })
|
||||||
::Guard.should_receive(:add_guard).with('test', [], [], { :group => :w })
|
::Guard.should_receive(:add_guard).with('test', [], [], { :group => :w })
|
||||||
|
|
||||||
subject.evaluate_guardfile(:guardfile_contents => valid_guardfile_string, :group => [:w])
|
described_class.evaluate_guardfile(:guardfile_contents => valid_guardfile_string, :group => [:w])
|
||||||
|
|
||||||
::Guard.groups.should eql [{ :name => :default, :options => {} }, { :name => :w, :options => {} }]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "evaluates only the specified groups (with their options)" do
|
it "evaluates only the specified groups (with their options)" do
|
||||||
@ -258,18 +254,14 @@ describe Guard::Dsl do
|
|||||||
::Guard.should_receive(:add_guard).with('ronn', [], [], { :group => :x })
|
::Guard.should_receive(:add_guard).with('ronn', [], [], { :group => :x })
|
||||||
::Guard.should_receive(:add_guard).with('less', [], [], { :group => :y })
|
::Guard.should_receive(:add_guard).with('less', [], [], { :group => :y })
|
||||||
|
|
||||||
subject.evaluate_guardfile(:guardfile_contents => valid_guardfile_string, :group => [:x, :y])
|
described_class.evaluate_guardfile(:guardfile_contents => valid_guardfile_string, :group => [:x, :y])
|
||||||
|
|
||||||
::Guard.groups.should eql [{ :name => :default, :options => {} }, { :name => :x, :options => { :halt_on_fail => true } }, { :name => :y, :options => {} }]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "evaluates always guard outside any group (even when a group is given)" do
|
it "evaluates always guard outside any group (even when a group is given)" do
|
||||||
::Guard.should_receive(:add_guard).with('pow', [], [], { :group => :default })
|
::Guard.should_receive(:add_guard).with('pow', [], [], { :group => :default })
|
||||||
::Guard.should_receive(:add_guard).with('test', [], [], { :group => :w })
|
::Guard.should_receive(:add_guard).with('test', [], [], { :group => :w })
|
||||||
|
|
||||||
subject.evaluate_guardfile(:guardfile_contents => valid_guardfile_string, :group => [:w])
|
described_class.evaluate_guardfile(:guardfile_contents => valid_guardfile_string, :group => [:w])
|
||||||
|
|
||||||
::Guard.groups.should eql [{ :name => :default, :options => {} }, { :name => :w, :options => {} }]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "evaluates all groups when no group option is specified (with their options)" do
|
it "evaluates all groups when no group option is specified (with their options)" do
|
||||||
@ -279,10 +271,7 @@ describe Guard::Dsl do
|
|||||||
::Guard.should_receive(:add_guard).with('ronn', [], [], { :group => :x })
|
::Guard.should_receive(:add_guard).with('ronn', [], [], { :group => :x })
|
||||||
::Guard.should_receive(:add_guard).with('less', [], [], { :group => :y })
|
::Guard.should_receive(:add_guard).with('less', [], [], { :group => :y })
|
||||||
|
|
||||||
subject.evaluate_guardfile(:guardfile_contents => valid_guardfile_string)
|
described_class.evaluate_guardfile(:guardfile_contents => valid_guardfile_string)
|
||||||
|
|
||||||
::Guard.groups.should eql [{ :name => :default, :options => {} }, { :name => :w, :options => {} }, { :name => :x, :options => { :halt_on_fail => true } }, { :name => :y, :options => {} }]
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -292,31 +281,31 @@ describe Guard::Dsl do
|
|||||||
it "loads a guard specified as a quoted string from the DSL" do
|
it "loads a guard specified as a quoted string from the DSL" do
|
||||||
::Guard.should_receive(:add_guard).with('test', [], [], { :group => :default })
|
::Guard.should_receive(:add_guard).with('test', [], [], { :group => :default })
|
||||||
|
|
||||||
subject.evaluate_guardfile(:guardfile_contents => "guard 'test'")
|
described_class.evaluate_guardfile(:guardfile_contents => "guard 'test'")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "loads a guard specified as a double quoted string from the DSL" do
|
it "loads a guard specified as a double quoted string from the DSL" do
|
||||||
::Guard.should_receive(:add_guard).with('test', [], [], { :group => :default })
|
::Guard.should_receive(:add_guard).with('test', [], [], { :group => :default })
|
||||||
|
|
||||||
subject.evaluate_guardfile(:guardfile_contents => 'guard "test"')
|
described_class.evaluate_guardfile(:guardfile_contents => 'guard "test"')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "loads a guard specified as a symbol from the DSL" do
|
it "loads a guard specified as a symbol from the DSL" do
|
||||||
::Guard.should_receive(:add_guard).with('test', [], [], { :group => :default })
|
::Guard.should_receive(:add_guard).with('test', [], [], { :group => :default })
|
||||||
|
|
||||||
subject.evaluate_guardfile(:guardfile_contents => "guard :test")
|
described_class.evaluate_guardfile(:guardfile_contents => "guard :test")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "loads a guard specified as a symbol and called with parens from the DSL" do
|
it "loads a guard specified as a symbol and called with parens from the DSL" do
|
||||||
::Guard.should_receive(:add_guard).with('test', [], [], { :group => :default })
|
::Guard.should_receive(:add_guard).with('test', [], [], { :group => :default })
|
||||||
|
|
||||||
subject.evaluate_guardfile(:guardfile_contents => "guard(:test)")
|
described_class.evaluate_guardfile(:guardfile_contents => "guard(:test)")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "receives options when specified, from normal arg" do
|
it "receives options when specified, from normal arg" do
|
||||||
::Guard.should_receive(:add_guard).with('test', [], [], { :opt_a => 1, :opt_b => 'fancy', :group => :default })
|
::Guard.should_receive(:add_guard).with('test', [], [], { :opt_a => 1, :opt_b => 'fancy', :group => :default })
|
||||||
|
|
||||||
subject.evaluate_guardfile(:guardfile_contents => "guard 'test', :opt_a => 1, :opt_b => 'fancy'")
|
described_class.evaluate_guardfile(:guardfile_contents => "guard 'test', :opt_a => 1, :opt_b => 'fancy'")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -331,7 +320,7 @@ describe Guard::Dsl do
|
|||||||
watchers[1].pattern.should == 'c'
|
watchers[1].pattern.should == 'c'
|
||||||
watchers[1].action.should == nil
|
watchers[1].action.should == nil
|
||||||
end
|
end
|
||||||
subject.evaluate_guardfile(:guardfile_contents => "
|
described_class.evaluate_guardfile(:guardfile_contents => "
|
||||||
guard :dummy do
|
guard :dummy do
|
||||||
watch('a') { 'b' }
|
watch('a') { 'b' }
|
||||||
watch('c')
|
watch('c')
|
||||||
@ -354,7 +343,7 @@ describe Guard::Dsl do
|
|||||||
callbacks[1][:events].should == [:start_begin, :run_all_begin]
|
callbacks[1][:events].should == [:start_begin, :run_all_begin]
|
||||||
callbacks[1][:listener].should == MyCustomCallback
|
callbacks[1][:listener].should == MyCustomCallback
|
||||||
end
|
end
|
||||||
subject.evaluate_guardfile(:guardfile_contents => '
|
described_class.evaluate_guardfile(:guardfile_contents => '
|
||||||
guard :dummy do
|
guard :dummy do
|
||||||
callback(:start_end) { |guard_class, event, args| "#{guard_class} executed \'#{event}\' hook with #{args}!" }
|
callback(:start_end) { |guard_class, event, args| "#{guard_class} executed \'#{event}\' hook with #{args}!" }
|
||||||
callback(MyCustomCallback, [:start_begin, :run_all_begin])
|
callback(MyCustomCallback, [:start_begin, :run_all_begin])
|
||||||
|
@ -2,48 +2,47 @@ require 'spec_helper'
|
|||||||
require 'guard/guard'
|
require 'guard/guard'
|
||||||
|
|
||||||
describe Guard::Hook do
|
describe Guard::Hook do
|
||||||
subject { Guard::Hook }
|
|
||||||
|
|
||||||
class Guard::Dummy < Guard::Guard; end
|
class Guard::Dummy < Guard::Guard; end
|
||||||
|
|
||||||
let(:guard_class) { ::Guard::Dummy }
|
let(:guard_class) { ::Guard::Dummy }
|
||||||
let(:listener) { double('listener').as_null_object }
|
let(:listener) { double('listener').as_null_object }
|
||||||
|
|
||||||
after { subject.reset_callbacks! }
|
after { described_class.reset_callbacks! }
|
||||||
|
|
||||||
context "--module methods--" do
|
describe "--module methods--" do
|
||||||
before { subject.add_callback(listener, guard_class, :start_begin) }
|
before { described_class.add_callback(listener, guard_class, :start_begin) }
|
||||||
|
|
||||||
describe ".add_callback" do
|
describe ".add_callback" do
|
||||||
it "can add a single callback" do
|
it "can add a single callback" do
|
||||||
subject.has_callback?(listener, guard_class, :start_begin).should be_true
|
described_class.has_callback?(listener, guard_class, :start_begin).should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "can add multiple callbacks" do
|
it "can add multiple callbacks" do
|
||||||
subject.add_callback(listener, guard_class, [:event1, :event2])
|
described_class.add_callback(listener, guard_class, [:event1, :event2])
|
||||||
subject.has_callback?(listener, guard_class, :event1).should be_true
|
described_class.has_callback?(listener, guard_class, :event1).should be_true
|
||||||
subject.has_callback?(listener, guard_class, :event2).should be_true
|
described_class.has_callback?(listener, guard_class, :event2).should be_true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".notify" do
|
describe ".notify" do
|
||||||
it "sends :call to the given Guard class's callbacks" do
|
it "sends :call to the given Guard class's callbacks" do
|
||||||
listener.should_receive(:call).with(guard_class, :start_begin, "args")
|
listener.should_receive(:call).with(guard_class, :start_begin, "args")
|
||||||
subject.notify(guard_class, :start_begin, "args")
|
described_class.notify(guard_class, :start_begin, "args")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "runs only the given callbacks" do
|
it "runs only the given callbacks" do
|
||||||
listener2 = double('listener2')
|
listener2 = double('listener2')
|
||||||
subject.add_callback(listener2, guard_class, :start_end)
|
described_class.add_callback(listener2, guard_class, :start_end)
|
||||||
listener2.should_not_receive(:call).with(guard_class, :start_end)
|
listener2.should_not_receive(:call).with(guard_class, :start_end)
|
||||||
subject.notify(guard_class, :start_begin)
|
described_class.notify(guard_class, :start_begin)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "runs callbacks only for the guard given" do
|
it "runs callbacks only for the guard given" do
|
||||||
guard2_class = double('Guard::Dummy2').class
|
guard2_class = double('Guard::Dummy2').class
|
||||||
subject.add_callback(listener, guard2_class, :start_begin)
|
described_class.add_callback(listener, guard2_class, :start_begin)
|
||||||
listener.should_not_receive(:call).with(guard2_class, :start_begin)
|
listener.should_not_receive(:call).with(guard2_class, :start_begin)
|
||||||
subject.notify(guard_class, :start_begin)
|
described_class.notify(guard_class, :start_begin)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Guard::Listener do
|
describe Guard::Listener do
|
||||||
subject { Guard::Listener }
|
|
||||||
|
|
||||||
describe ".select_and_init" do
|
describe ".select_and_init" do
|
||||||
before(:each) { @target_os = RbConfig::CONFIG['target_os'] }
|
before(:each) { @target_os = RbConfig::CONFIG['target_os'] }
|
||||||
@ -11,30 +10,30 @@ describe Guard::Listener do
|
|||||||
RbConfig::CONFIG['target_os'] = 'darwin10.4.0'
|
RbConfig::CONFIG['target_os'] = 'darwin10.4.0'
|
||||||
Guard::Darwin.stub(:usable?).and_return(true)
|
Guard::Darwin.stub(:usable?).and_return(true)
|
||||||
Guard::Darwin.should_receive(:new)
|
Guard::Darwin.should_receive(:new)
|
||||||
subject.select_and_init
|
described_class.select_and_init
|
||||||
end
|
end
|
||||||
|
|
||||||
it "uses the Windows listener on Windows" do
|
it "uses the Windows listener on Windows" do
|
||||||
RbConfig::CONFIG['target_os'] = 'mingw'
|
RbConfig::CONFIG['target_os'] = 'mingw'
|
||||||
Guard::Windows.stub(:usable?).and_return(true)
|
Guard::Windows.stub(:usable?).and_return(true)
|
||||||
Guard::Windows.should_receive(:new)
|
Guard::Windows.should_receive(:new)
|
||||||
subject.select_and_init
|
described_class.select_and_init
|
||||||
end
|
end
|
||||||
|
|
||||||
it "uses the Linux listener on Linux" do
|
it "uses the Linux listener on Linux" do
|
||||||
RbConfig::CONFIG['target_os'] = 'linux'
|
RbConfig::CONFIG['target_os'] = 'linux'
|
||||||
Guard::Linux.stub(:usable?).and_return(true)
|
Guard::Linux.stub(:usable?).and_return(true)
|
||||||
Guard::Linux.should_receive(:new)
|
Guard::Linux.should_receive(:new)
|
||||||
subject.select_and_init
|
described_class.select_and_init
|
||||||
end
|
end
|
||||||
|
|
||||||
it "forwards its arguments to the constructor" do
|
it "forwards its arguments to the constructor" do
|
||||||
subject.stub!(:mac?).and_return(true)
|
described_class.stub!(:mac?).and_return(true)
|
||||||
Guard::Darwin.stub!(:usable?).and_return(true)
|
Guard::Darwin.stub!(:usable?).and_return(true)
|
||||||
|
|
||||||
path, opts = 'path', { :foo => 23 }
|
path, opts = 'path', { :foo => 23 }
|
||||||
Guard::Darwin.should_receive(:new).with(path, opts).and_return(true)
|
Guard::Darwin.should_receive(:new).with(path, opts).and_return(true)
|
||||||
subject.select_and_init(path, opts)
|
described_class.select_and_init(path, opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -172,11 +171,11 @@ describe Guard::Listener do
|
|||||||
|
|
||||||
describe "#ignore_paths" do
|
describe "#ignore_paths" do
|
||||||
it "defaults to the default ignore paths" do
|
it "defaults to the default ignore paths" do
|
||||||
subject.new.ignore_paths.should == Guard::Listener::DEFAULT_IGNORE_PATHS
|
described_class.new.ignore_paths.should == Guard::Listener::DEFAULT_IGNORE_PATHS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "can be added to via :ignore_paths option" do
|
it "can be added to via :ignore_paths option" do
|
||||||
listener = subject.new 'path', :ignore_paths => ['foo', 'bar']
|
listener = described_class.new 'path', :ignore_paths => ['foo', 'bar']
|
||||||
listener.ignore_paths.should include('foo', 'bar')
|
listener.ignore_paths.should include('foo', 'bar')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -197,4 +196,5 @@ describe Guard::Listener do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -2,26 +2,26 @@ require 'spec_helper'
|
|||||||
require 'guard/listeners/darwin'
|
require 'guard/listeners/darwin'
|
||||||
|
|
||||||
describe Guard::Darwin do
|
describe Guard::Darwin do
|
||||||
subject { Guard::Darwin }
|
|
||||||
|
|
||||||
if windows?
|
if windows?
|
||||||
it "isn't usable on windows" do
|
it "isn't usable on windows" do
|
||||||
subject.should_not be_usable
|
described_class.should_not be_usable
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if linux?
|
if linux?
|
||||||
it "isn't usable on linux" do
|
it "isn't usable on linux" do
|
||||||
subject.should_not be_usable
|
described_class.should_not be_usable
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if mac? && Guard::Darwin.usable?
|
if mac? && Guard::Darwin.usable?
|
||||||
it "is usable on 10.6" do
|
it "is usable on 10.6" do
|
||||||
subject.should be_usable
|
described_class.should be_usable
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like "a listener that reacts to #on_change"
|
it_should_behave_like "a listener that reacts to #on_change"
|
||||||
it_should_behave_like "a listener scoped to a specific directory"
|
it_should_behave_like "a listener scoped to a specific directory"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -3,23 +3,22 @@ require 'fileutils'
|
|||||||
require 'guard/listeners/linux'
|
require 'guard/listeners/linux'
|
||||||
|
|
||||||
describe Guard::Linux do
|
describe Guard::Linux do
|
||||||
subject { Guard::Linux }
|
|
||||||
|
|
||||||
if mac?
|
if mac?
|
||||||
it "isn't usable on 10.6" do
|
it "isn't usable on 10.6" do
|
||||||
subject.should_not be_usable
|
described_class.should_not be_usable
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if windows?
|
if windows?
|
||||||
it "isn't usable on windows" do
|
it "isn't usable on windows" do
|
||||||
subject.should_not be_usable
|
described_class.should_not be_usable
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if linux? && Guard::Linux.usable?
|
if linux? && Guard::Linux.usable?
|
||||||
it "is usable on linux" do
|
it "is usable on linux" do
|
||||||
subject.should be_usable
|
described_class.should be_usable
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#start", :long_running => true do
|
describe "#start", :long_running => true do
|
||||||
@ -72,6 +71,6 @@ describe Guard::Linux do
|
|||||||
stop
|
stop
|
||||||
File.open(file, 'w') {|f| f.write('') }
|
File.open(file, 'w') {|f| f.write('') }
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -2,8 +2,8 @@ require 'spec_helper'
|
|||||||
require 'guard/listeners/polling'
|
require 'guard/listeners/polling'
|
||||||
|
|
||||||
describe Guard::Polling do
|
describe Guard::Polling do
|
||||||
subject { Guard::Polling }
|
|
||||||
|
|
||||||
it_should_behave_like "a listener that reacts to #on_change"
|
it_should_behave_like "a listener that reacts to #on_change"
|
||||||
it_should_behave_like "a listener scoped to a specific directory"
|
it_should_behave_like "a listener scoped to a specific directory"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -2,27 +2,26 @@ require 'spec_helper'
|
|||||||
require 'guard/listeners/windows'
|
require 'guard/listeners/windows'
|
||||||
|
|
||||||
describe Guard::Windows do
|
describe Guard::Windows do
|
||||||
subject { Guard::Windows }
|
|
||||||
|
|
||||||
if linux?
|
if linux?
|
||||||
it "isn't usable on linux" do
|
it "isn't usable on linux" do
|
||||||
subject.should_not be_usable
|
described_class.should_not be_usable
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if mac?
|
if mac?
|
||||||
it "isn't usable on Mac" do
|
it "isn't usable on Mac" do
|
||||||
subject.should_not be_usable
|
described_class.should_not be_usable
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if windows?
|
if windows?
|
||||||
it "is usable on Windows 2000 and later" do
|
it "is usable on Windows 2000 and later" do
|
||||||
subject.should be_usable
|
described_class.should be_usable
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like "a listener that reacts to #on_change"
|
it_should_behave_like "a listener that reacts to #on_change"
|
||||||
it_should_behave_like "a listener scoped to a specific directory"
|
it_should_behave_like "a listener scoped to a specific directory"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Guard::Notifier do
|
describe Guard::Notifier do
|
||||||
subject { Guard::Notifier }
|
|
||||||
|
|
||||||
describe ".turn_off" do
|
describe ".turn_off" do
|
||||||
before do
|
before do
|
||||||
ENV["GUARD_NOTIFY"] = 'true'
|
ENV["GUARD_NOTIFY"] = 'true'
|
||||||
subject.turn_off
|
described_class.turn_off
|
||||||
end
|
end
|
||||||
|
|
||||||
it "disables the notifications" do
|
it "disables the notifications" do
|
||||||
@ -28,10 +27,10 @@ describe Guard::Notifier do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "loads the library and enables the notifications" do
|
it "loads the library and enables the notifications" do
|
||||||
subject.should_receive(:require).with('growl_notify').and_return true
|
described_class.should_receive(:require).with('growl_notify').and_return true
|
||||||
GrowlNotify.should_receive(:application_name).and_return ''
|
GrowlNotify.should_receive(:application_name).and_return ''
|
||||||
subject.turn_on
|
described_class.turn_on
|
||||||
subject.should be_enabled
|
described_class.should be_enabled
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
@ -41,19 +40,19 @@ describe Guard::Notifier do
|
|||||||
|
|
||||||
context "with the Growl library available" do
|
context "with the Growl library available" do
|
||||||
it "loads the library and enables the notifications" do
|
it "loads the library and enables the notifications" do
|
||||||
subject.should_receive(:require).with('growl_notify').and_raise LoadError
|
described_class.should_receive(:require).with('growl_notify').and_raise LoadError
|
||||||
subject.should_receive(:require).with('growl').and_return true
|
described_class.should_receive(:require).with('growl').and_return true
|
||||||
subject.turn_on
|
described_class.turn_on
|
||||||
subject.should be_enabled
|
described_class.should be_enabled
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "without the Growl library available" do
|
context "without the Growl library available" do
|
||||||
it "disables the notifications" do
|
it "disables the notifications" do
|
||||||
subject.should_receive(:require).with('growl_notify').and_raise LoadError
|
described_class.should_receive(:require).with('growl_notify').and_raise LoadError
|
||||||
subject.should_receive(:require).with('growl').and_raise LoadError
|
described_class.should_receive(:require).with('growl').and_raise LoadError
|
||||||
subject.turn_on
|
described_class.turn_on
|
||||||
subject.should_not be_enabled
|
described_class.should_not be_enabled
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -65,17 +64,17 @@ describe Guard::Notifier do
|
|||||||
|
|
||||||
context "with the Libnotify library available" do
|
context "with the Libnotify library available" do
|
||||||
it "loads the library and enables the notifications" do
|
it "loads the library and enables the notifications" do
|
||||||
subject.should_receive(:require).with('libnotify').and_return true
|
described_class.should_receive(:require).with('libnotify').and_return true
|
||||||
subject.turn_on
|
described_class.turn_on
|
||||||
subject.should be_enabled
|
described_class.should be_enabled
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "without the Libnotify library available" do
|
context "without the Libnotify library available" do
|
||||||
it "disables the notifications" do
|
it "disables the notifications" do
|
||||||
subject.should_receive(:require).with('libnotify').and_raise LoadError
|
described_class.should_receive(:require).with('libnotify').and_raise LoadError
|
||||||
subject.turn_on
|
described_class.turn_on
|
||||||
subject.should_not be_enabled
|
described_class.should_not be_enabled
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -87,29 +86,29 @@ describe Guard::Notifier do
|
|||||||
|
|
||||||
context "with the rb-notifu library available" do
|
context "with the rb-notifu library available" do
|
||||||
it "loads the library and enables the notifications" do
|
it "loads the library and enables the notifications" do
|
||||||
subject.should_receive(:require).with('rb-notifu').and_return true
|
described_class.should_receive(:require).with('rb-notifu').and_return true
|
||||||
subject.turn_on
|
described_class.turn_on
|
||||||
subject.should be_enabled
|
described_class.should be_enabled
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "without the rb-notify library available" do
|
context "without the rb-notify library available" do
|
||||||
it "disables the notifications" do
|
it "disables the notifications" do
|
||||||
subject.should_receive(:require).with('rb-notifu').and_raise LoadError
|
described_class.should_receive(:require).with('rb-notifu').and_raise LoadError
|
||||||
subject.turn_on
|
described_class.turn_on
|
||||||
subject.should_not be_enabled
|
described_class.should_not be_enabled
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".notify" do
|
describe ".notify" do
|
||||||
before { subject.stub(:enabled?).and_return(true) }
|
before { described_class.stub(:enabled?).and_return(true) }
|
||||||
|
|
||||||
context "on Mac OS" do
|
context "on Mac OS" do
|
||||||
before do
|
before do
|
||||||
RbConfig::CONFIG.should_receive(:[]).with('target_os').and_return 'darwin'
|
RbConfig::CONFIG.should_receive(:[]).with('target_os').and_return 'darwin'
|
||||||
subject.stub(:require_growl)
|
described_class.stub(:require_growl)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with growl gem' do
|
context 'with growl gem' do
|
||||||
@ -128,13 +127,13 @@ describe Guard::Notifier do
|
|||||||
:icon => Pathname.new(File.dirname(__FILE__)).join('../../images/success.png').to_s,
|
:icon => Pathname.new(File.dirname(__FILE__)).join('../../images/success.png').to_s,
|
||||||
:name => "Guard"
|
:name => "Guard"
|
||||||
)
|
)
|
||||||
subject.notify 'great', :title => 'Guard'
|
described_class.notify 'great', :title => 'Guard'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "don't passes the notification to Growl if library is not available" do
|
it "don't passes the notification to Growl if library is not available" do
|
||||||
Growl.should_not_receive(:notify)
|
Growl.should_not_receive(:notify)
|
||||||
subject.should_receive(:enabled?).and_return(true, false)
|
described_class.should_receive(:enabled?).and_return(true, false)
|
||||||
subject.notify 'great', :title => 'Guard'
|
described_class.notify 'great', :title => 'Guard'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "allows additional notification options" do
|
it "allows additional notification options" do
|
||||||
@ -144,7 +143,7 @@ describe Guard::Notifier do
|
|||||||
:name => "Guard",
|
:name => "Guard",
|
||||||
:priority => 1
|
:priority => 1
|
||||||
)
|
)
|
||||||
subject.notify 'great', :title => 'Guard', :priority => 1
|
described_class.notify 'great', :title => 'Guard', :priority => 1
|
||||||
end
|
end
|
||||||
|
|
||||||
it "allows to overwrite a default notification option" do
|
it "allows to overwrite a default notification option" do
|
||||||
@ -153,7 +152,7 @@ describe Guard::Notifier do
|
|||||||
:icon => Pathname.new(File.dirname(__FILE__)).join('../../images/success.png').to_s,
|
:icon => Pathname.new(File.dirname(__FILE__)).join('../../images/success.png').to_s,
|
||||||
:name => "Guard-Cucumber"
|
:name => "Guard-Cucumber"
|
||||||
)
|
)
|
||||||
subject.notify 'great', :title => 'Guard', :name => "Guard-Cucumber"
|
described_class.notify 'great', :title => 'Guard', :name => "Guard-Cucumber"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -174,13 +173,13 @@ describe Guard::Notifier do
|
|||||||
:application_name => "Guard",
|
:application_name => "Guard",
|
||||||
:description => 'great'
|
:description => 'great'
|
||||||
)
|
)
|
||||||
subject.notify 'great', :title => 'Guard'
|
described_class.notify 'great', :title => 'Guard'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "don't passes the notification to Growl if library is not available" do
|
it "don't passes the notification to Growl if library is not available" do
|
||||||
GrowlNotify.should_not_receive(:send_notification)
|
GrowlNotify.should_not_receive(:send_notification)
|
||||||
subject.should_receive(:enabled?).and_return(true, false)
|
described_class.should_receive(:enabled?).and_return(true, false)
|
||||||
subject.notify 'great', :title => 'Guard'
|
described_class.notify 'great', :title => 'Guard'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "allows additional notification options" do
|
it "allows additional notification options" do
|
||||||
@ -191,7 +190,7 @@ describe Guard::Notifier do
|
|||||||
:description => 'great',
|
:description => 'great',
|
||||||
:priority => 1
|
:priority => 1
|
||||||
)
|
)
|
||||||
subject.notify 'great', :title => 'Guard', :priority => 1
|
described_class.notify 'great', :title => 'Guard', :priority => 1
|
||||||
end
|
end
|
||||||
|
|
||||||
it "throws out the application name since Guard should only use one Growl App Name while running" do
|
it "throws out the application name since Guard should only use one Growl App Name while running" do
|
||||||
@ -201,15 +200,15 @@ describe Guard::Notifier do
|
|||||||
:application_name => "Guard",
|
:application_name => "Guard",
|
||||||
:description => 'great'
|
:description => 'great'
|
||||||
)
|
)
|
||||||
subject.notify 'great', :title => 'Guard', :name => "Guard-Cucumber"
|
described_class.notify 'great', :title => 'Guard', :name => "Guard-Cucumber"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "on Linux" do
|
context "on Linux" do
|
||||||
before do
|
before do
|
||||||
RbConfig::CONFIG.should_receive(:[]).with('target_os').and_return 'linux'
|
RbConfig::CONFIG.should_receive(:[]).with('target_os').and_return 'linux'
|
||||||
subject.stub(:require_libnotify)
|
described_class.stub(:require_libnotify)
|
||||||
Object.send(:remove_const, :Libnotify) if defined?(Libnotify)
|
Object.send(:remove_const, :Libnotify) if defined?(Libnotify)
|
||||||
Libnotify = Object.new
|
Libnotify = Object.new
|
||||||
end
|
end
|
||||||
@ -225,13 +224,13 @@ describe Guard::Notifier do
|
|||||||
:icon_path => Pathname.new(File.dirname(__FILE__)).join('../../images/success.png').to_s,
|
:icon_path => Pathname.new(File.dirname(__FILE__)).join('../../images/success.png').to_s,
|
||||||
:transient => true
|
:transient => true
|
||||||
)
|
)
|
||||||
subject.notify 'great', :title => 'Guard'
|
described_class.notify 'great', :title => 'Guard'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "don't passes the notification to Libnotify if library is not available" do
|
it "don't passes the notification to Libnotify if library is not available" do
|
||||||
Libnotify.should_not_receive(:show)
|
Libnotify.should_not_receive(:show)
|
||||||
subject.should_receive(:enabled?).and_return(true, false)
|
described_class.should_receive(:enabled?).and_return(true, false)
|
||||||
subject.notify 'great', :title => 'Guard'
|
described_class.notify 'great', :title => 'Guard'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "allows additional notification options" do
|
it "allows additional notification options" do
|
||||||
@ -242,7 +241,7 @@ describe Guard::Notifier do
|
|||||||
:transient => true,
|
:transient => true,
|
||||||
:urgency => :critical
|
:urgency => :critical
|
||||||
)
|
)
|
||||||
subject.notify 'great', :title => 'Guard', :urgency => :critical
|
described_class.notify 'great', :title => 'Guard', :urgency => :critical
|
||||||
end
|
end
|
||||||
|
|
||||||
it "allows to overwrite a default notification option" do
|
it "allows to overwrite a default notification option" do
|
||||||
@ -252,14 +251,14 @@ describe Guard::Notifier do
|
|||||||
:icon_path => '~/.guard/success.png',
|
:icon_path => '~/.guard/success.png',
|
||||||
:transient => true
|
:transient => true
|
||||||
)
|
)
|
||||||
subject.notify 'great', :title => 'Guard', :icon_path => '~/.guard/success.png'
|
described_class.notify 'great', :title => 'Guard', :icon_path => '~/.guard/success.png'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "on Windows" do
|
context "on Windows" do
|
||||||
before do
|
before do
|
||||||
RbConfig::CONFIG.should_receive(:[]).with('target_os').and_return 'mswin'
|
RbConfig::CONFIG.should_receive(:[]).with('target_os').and_return 'mswin'
|
||||||
subject.stub(:require_rbnotifu)
|
described_class.stub(:require_rbnotifu)
|
||||||
Object.send(:remove_const, :Notifu) if defined?(Notifu)
|
Object.send(:remove_const, :Notifu) if defined?(Notifu)
|
||||||
Notifu = Object.new
|
Notifu = Object.new
|
||||||
end
|
end
|
||||||
@ -275,13 +274,13 @@ describe Guard::Notifier do
|
|||||||
:type => :info,
|
:type => :info,
|
||||||
:time => 3
|
:time => 3
|
||||||
)
|
)
|
||||||
subject.notify 'great', :title => 'Guard'
|
described_class.notify 'great', :title => 'Guard'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "don't passes the notification to rb-notifu if library is not available" do
|
it "don't passes the notification to rb-notifu if library is not available" do
|
||||||
Notifu.should_not_receive(:show)
|
Notifu.should_not_receive(:show)
|
||||||
subject.should_receive(:enabled?).and_return(true, false)
|
described_class.should_receive(:enabled?).and_return(true, false)
|
||||||
subject.notify 'great', :title => 'Guard'
|
described_class.notify 'great', :title => 'Guard'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "allows additional notification options" do
|
it "allows additional notification options" do
|
||||||
@ -292,7 +291,7 @@ describe Guard::Notifier do
|
|||||||
:time => 3,
|
:time => 3,
|
||||||
:nosound => true
|
:nosound => true
|
||||||
)
|
)
|
||||||
subject.notify 'great', :title => 'Guard', :nosound => true
|
described_class.notify 'great', :title => 'Guard', :nosound => true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "allows to overwrite a default notification option" do
|
it "allows to overwrite a default notification option" do
|
||||||
@ -302,7 +301,7 @@ describe Guard::Notifier do
|
|||||||
:type => :info,
|
:type => :info,
|
||||||
:time => 10
|
:time => 10
|
||||||
)
|
)
|
||||||
subject.notify 'great', :title => 'Guard', :time => 10
|
described_class.notify 'great', :title => 'Guard', :time => 10
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -320,4 +319,5 @@ describe Guard::Notifier do
|
|||||||
it { should_not be_enabled }
|
it { should_not be_enabled }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -5,19 +5,19 @@ describe Guard::Watcher do
|
|||||||
|
|
||||||
describe "#initialize" do
|
describe "#initialize" do
|
||||||
it "requires a pattern parameter" do
|
it "requires a pattern parameter" do
|
||||||
expect { Guard::Watcher.new }.to raise_error(ArgumentError)
|
expect { described_class.new }.to raise_error(ArgumentError)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with a pattern parameter" do
|
context "with a pattern parameter" do
|
||||||
context "that is a string" do
|
context "that is a string" do
|
||||||
it "keeps the string pattern unmodified" do
|
it "keeps the string pattern unmodified" do
|
||||||
Guard::Watcher.new('spec_helper.rb').pattern.should == 'spec_helper.rb'
|
described_class.new('spec_helper.rb').pattern.should == 'spec_helper.rb'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "that is a regexp" do
|
context "that is a regexp" do
|
||||||
it "keeps the regex pattern unmodified" do
|
it "keeps the regex pattern unmodified" do
|
||||||
Guard::Watcher.new(/spec_helper\.rb/).pattern.should == /spec_helper\.rb/
|
described_class.new(/spec_helper\.rb/).pattern.should == /spec_helper\.rb/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -25,10 +25,10 @@ describe Guard::Watcher do
|
|||||||
before(:each) { Guard::UI.should_receive(:info).any_number_of_times }
|
before(:each) { Guard::UI.should_receive(:info).any_number_of_times }
|
||||||
|
|
||||||
it "converts the string automatically to a regex" do
|
it "converts the string automatically to a regex" do
|
||||||
Guard::Watcher.new('^spec_helper.rb').pattern.should == /^spec_helper.rb/
|
described_class.new('^spec_helper.rb').pattern.should == /^spec_helper.rb/
|
||||||
Guard::Watcher.new('spec_helper.rb$').pattern.should == /spec_helper.rb$/
|
described_class.new('spec_helper.rb$').pattern.should == /spec_helper.rb$/
|
||||||
Guard::Watcher.new('spec_helper\.rb').pattern.should == /spec_helper\.rb/
|
described_class.new('spec_helper\.rb').pattern.should == /spec_helper\.rb/
|
||||||
Guard::Watcher.new('.*_spec.rb').pattern.should == /.*_spec.rb/
|
described_class.new('.*_spec.rb').pattern.should == /.*_spec.rb/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -36,12 +36,12 @@ describe Guard::Watcher do
|
|||||||
|
|
||||||
describe "#action" do
|
describe "#action" do
|
||||||
it "sets the action to nothing by default" do
|
it "sets the action to nothing by default" do
|
||||||
Guard::Watcher.new(/spec_helper\.rb/).action.should be_nil
|
described_class.new(/spec_helper\.rb/).action.should be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it "sets the action to the supplied block" do
|
it "sets the action to the supplied block" do
|
||||||
action = lambda { |m| "spec/#{m[1]}_spec.rb" }
|
action = lambda { |m| "spec/#{m[1]}_spec.rb" }
|
||||||
Guard::Watcher.new(%r{^lib/(.*).rb}, action).action.should == action
|
described_class.new(%r{^lib/(.*).rb}, action).action.should == action
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -50,18 +50,18 @@ describe Guard::Watcher do
|
|||||||
|
|
||||||
context "with a watcher without action" do
|
context "with a watcher without action" do
|
||||||
context "that is a regex pattern" do
|
context "that is a regex pattern" do
|
||||||
before(:all) { @guard.watchers = [Guard::Watcher.new(/.*_spec\.rb/)] }
|
before(:all) { @guard.watchers = [described_class.new(/.*_spec\.rb/)] }
|
||||||
|
|
||||||
it "returns the paths that matches the regex" do
|
it "returns the paths that matches the regex" do
|
||||||
Guard::Watcher.match_files(@guard, ['guard_rocks_spec.rb', 'guard_rocks.rb']).should == ['guard_rocks_spec.rb']
|
described_class.match_files(@guard, ['guard_rocks_spec.rb', 'guard_rocks.rb']).should == ['guard_rocks_spec.rb']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "that is a string pattern" do
|
context "that is a string pattern" do
|
||||||
before(:all) { @guard.watchers = [Guard::Watcher.new('guard_rocks_spec.rb')] }
|
before(:all) { @guard.watchers = [described_class.new('guard_rocks_spec.rb')] }
|
||||||
|
|
||||||
it "returns the path that matches the string" do
|
it "returns the path that matches the string" do
|
||||||
Guard::Watcher.match_files(@guard, ['guard_rocks_spec.rb', 'guard_rocks.rb']).should == ['guard_rocks_spec.rb']
|
described_class.match_files(@guard, ['guard_rocks_spec.rb', 'guard_rocks.rb']).should == ['guard_rocks_spec.rb']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -69,79 +69,79 @@ describe Guard::Watcher do
|
|||||||
context "with a watcher action without parameter" do
|
context "with a watcher action without parameter" do
|
||||||
before(:all) do
|
before(:all) do
|
||||||
@guard.watchers = [
|
@guard.watchers = [
|
||||||
Guard::Watcher.new('spec_helper.rb', lambda { 'spec' }),
|
described_class.new('spec_helper.rb', lambda { 'spec' }),
|
||||||
Guard::Watcher.new('addition.rb', lambda { 1 + 1 }),
|
described_class.new('addition.rb', lambda { 1 + 1 }),
|
||||||
Guard::Watcher.new('hash.rb', lambda { Hash[:foo, 'bar'] }),
|
described_class.new('hash.rb', lambda { Hash[:foo, 'bar'] }),
|
||||||
Guard::Watcher.new('array.rb', lambda { ['foo', 'bar'] }),
|
described_class.new('array.rb', lambda { ['foo', 'bar'] }),
|
||||||
Guard::Watcher.new('blank.rb', lambda { '' }),
|
described_class.new('blank.rb', lambda { '' }),
|
||||||
Guard::Watcher.new(/^uptime\.rb/, lambda { `uptime > /dev/null` })
|
described_class.new(/^uptime\.rb/, lambda { `uptime > /dev/null` })
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns a single file specified within the action" do
|
it "returns a single file specified within the action" do
|
||||||
Guard::Watcher.match_files(@guard, ['spec_helper.rb']).should == ['spec']
|
described_class.match_files(@guard, ['spec_helper.rb']).should == ['spec']
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns multiple files specified within the action" do
|
it "returns multiple files specified within the action" do
|
||||||
Guard::Watcher.match_files(@guard, ['hash.rb']).should == ['foo', 'bar']
|
described_class.match_files(@guard, ['hash.rb']).should == ['foo', 'bar']
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns multiple files by combining the results of different actions" do
|
it "returns multiple files by combining the results of different actions" do
|
||||||
Guard::Watcher.match_files(@guard, ['spec_helper.rb', 'array.rb']).should == ['spec', 'foo', 'bar']
|
described_class.match_files(@guard, ['spec_helper.rb', 'array.rb']).should == ['spec', 'foo', 'bar']
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns nothing if the action returns something other than a string or an array of strings" do
|
it "returns nothing if the action returns something other than a string or an array of strings" do
|
||||||
Guard::Watcher.match_files(@guard, ['addition.rb']).should == []
|
described_class.match_files(@guard, ['addition.rb']).should == []
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns nothing if the action response is empty" do
|
it "returns nothing if the action response is empty" do
|
||||||
Guard::Watcher.match_files(@guard, ['blank.rb']).should == []
|
described_class.match_files(@guard, ['blank.rb']).should == []
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns nothing if the action returns nothing" do
|
it "returns nothing if the action returns nothing" do
|
||||||
Guard::Watcher.match_files(@guard, ['uptime.rb']).should == []
|
described_class.match_files(@guard, ['uptime.rb']).should == []
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with a watcher action that takes a parameter" do
|
context "with a watcher action that takes a parameter" do
|
||||||
before(:all) do
|
before(:all) do
|
||||||
@guard.watchers = [
|
@guard.watchers = [
|
||||||
Guard::Watcher.new(%r{lib/(.*)\.rb}, lambda { |m| "spec/#{m[1]}_spec.rb" }),
|
described_class.new(%r{lib/(.*)\.rb}, lambda { |m| "spec/#{m[1]}_spec.rb" }),
|
||||||
Guard::Watcher.new(/addition(.*)\.rb/, lambda { |m| 1 + 1 }),
|
described_class.new(/addition(.*)\.rb/, lambda { |m| 1 + 1 }),
|
||||||
Guard::Watcher.new('hash.rb', lambda { Hash[:foo, 'bar'] }),
|
described_class.new('hash.rb', lambda { Hash[:foo, 'bar'] }),
|
||||||
Guard::Watcher.new(/array(.*)\.rb/, lambda { |m| ['foo', 'bar'] }),
|
described_class.new(/array(.*)\.rb/, lambda { |m| ['foo', 'bar'] }),
|
||||||
Guard::Watcher.new(/blank(.*)\.rb/, lambda { |m| '' }),
|
described_class.new(/blank(.*)\.rb/, lambda { |m| '' }),
|
||||||
Guard::Watcher.new(/uptime(.*)\.rb/, lambda { |m| `uptime > /dev/null` })
|
described_class.new(/uptime(.*)\.rb/, lambda { |m| `uptime > /dev/null` })
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns a substituted single file specified within the action" do
|
it "returns a substituted single file specified within the action" do
|
||||||
Guard::Watcher.match_files(@guard, ['lib/my_wonderful_lib.rb']).should == ['spec/my_wonderful_lib_spec.rb']
|
described_class.match_files(@guard, ['lib/my_wonderful_lib.rb']).should == ['spec/my_wonderful_lib_spec.rb']
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns multiple files specified within the action" do
|
it "returns multiple files specified within the action" do
|
||||||
Guard::Watcher.match_files(@guard, ['hash.rb']).should == ['foo', 'bar']
|
described_class.match_files(@guard, ['hash.rb']).should == ['foo', 'bar']
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns multiple files by combining the results of different actions" do
|
it "returns multiple files by combining the results of different actions" do
|
||||||
Guard::Watcher.match_files(@guard, ['lib/my_wonderful_lib.rb', 'array.rb']).should == ['spec/my_wonderful_lib_spec.rb', 'foo', 'bar']
|
described_class.match_files(@guard, ['lib/my_wonderful_lib.rb', 'array.rb']).should == ['spec/my_wonderful_lib_spec.rb', 'foo', 'bar']
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns nothing if the action returns something other than a string or an array of strings" do
|
it "returns nothing if the action returns something other than a string or an array of strings" do
|
||||||
Guard::Watcher.match_files(@guard, ['addition.rb']).should == []
|
described_class.match_files(@guard, ['addition.rb']).should == []
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns nothing if the action response is empty" do
|
it "returns nothing if the action response is empty" do
|
||||||
Guard::Watcher.match_files(@guard, ['blank.rb']).should == []
|
described_class.match_files(@guard, ['blank.rb']).should == []
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns nothing if the action returns nothing" do
|
it "returns nothing if the action returns nothing" do
|
||||||
Guard::Watcher.match_files(@guard, ['uptime.rb']).should == []
|
described_class.match_files(@guard, ['uptime.rb']).should == []
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with an exception that is raised" do
|
context "with an exception that is raised" do
|
||||||
before(:all) { @guard.watchers = [Guard::Watcher.new('evil.rb', lambda { raise "EVIL" })] }
|
before(:all) { @guard.watchers = [described_class.new('evil.rb', lambda { raise "EVIL" })] }
|
||||||
|
|
||||||
it "displays the error and backtrace" do
|
it "displays the error and backtrace" do
|
||||||
Guard::UI.should_receive(:error) { |msg|
|
Guard::UI.should_receive(:error) { |msg|
|
||||||
@ -149,31 +149,31 @@ describe Guard::Watcher do
|
|||||||
msg.should include("EVIL")
|
msg.should include("EVIL")
|
||||||
}
|
}
|
||||||
|
|
||||||
Guard::Watcher.match_files(@guard, ['evil.rb'])
|
described_class.match_files(@guard, ['evil.rb'])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
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([described_class.new(/.*_spec\.rb/)])
|
||||||
@guard2 = Guard::Guard.new([Guard::Watcher.new('spec_helper.rb', 'spec')])
|
@guard2 = Guard::Guard.new([described_class.new('spec_helper.rb', 'spec')])
|
||||||
@guards = [@guard1, @guard2]
|
@guards = [@guard1, @guard2]
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with a watcher that matches a file" do
|
context "with a watcher that matches a file" do
|
||||||
specify { Guard::Watcher.match_files?(@guards, ['lib/my_wonderful_lib.rb', 'guard_rocks_spec.rb']).should be_true }
|
specify { described_class.match_files?(@guards, ['lib/my_wonderful_lib.rb', 'guard_rocks_spec.rb']).should be_true }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with no watcher that matches a file" do
|
context "with no watcher that matches a file" do
|
||||||
specify { Guard::Watcher.match_files?(@guards, ['lib/my_wonderful_lib.rb']).should be_false }
|
specify { described_class.match_files?(@guards, ['lib/my_wonderful_lib.rb']).should be_false }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#match_file?" do
|
describe "#match_file?" do
|
||||||
context "with a string pattern" do
|
context "with a string pattern" do
|
||||||
context "that is a normal string" do
|
context "that is a normal string" do
|
||||||
subject { Guard::Watcher.new('guard_rocks_spec.rb') }
|
subject { described_class.new('guard_rocks_spec.rb') }
|
||||||
|
|
||||||
context "with a watcher that matches a file" do
|
context "with a watcher that matches a file" do
|
||||||
specify { subject.match_file?('guard_rocks_spec.rb').should be_true }
|
specify { subject.match_file?('guard_rocks_spec.rb').should be_true }
|
||||||
@ -185,7 +185,7 @@ describe Guard::Watcher do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "that is a string representing a regexp (deprecated)" do
|
context "that is a string representing a regexp (deprecated)" do
|
||||||
subject { Guard::Watcher.new('^guard_rocks_spec\.rb$') }
|
subject { described_class.new('^guard_rocks_spec\.rb$') }
|
||||||
|
|
||||||
context "with a watcher that matches a file" do
|
context "with a watcher that matches a file" do
|
||||||
specify { subject.match_file?('guard_rocks_spec.rb').should be_true }
|
specify { subject.match_file?('guard_rocks_spec.rb').should be_true }
|
||||||
@ -198,7 +198,7 @@ describe Guard::Watcher do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "that is a regexp pattern" do
|
context "that is a regexp pattern" do
|
||||||
subject { Guard::Watcher.new(/.*_spec\.rb/) }
|
subject { described_class.new(/.*_spec\.rb/) }
|
||||||
|
|
||||||
context "with a watcher that matches a file" do
|
context "with a watcher that matches a file" do
|
||||||
specify { subject.match_file?('guard_rocks_spec.rb').should be_true }
|
specify { subject.match_file?('guard_rocks_spec.rb').should be_true }
|
||||||
@ -214,11 +214,11 @@ describe Guard::Watcher do
|
|||||||
before(:all) { Guard::Dsl.stub(:guardfile_path) { Dir.pwd + '/Guardfile' } }
|
before(:all) { Guard::Dsl.stub(:guardfile_path) { Dir.pwd + '/Guardfile' } }
|
||||||
|
|
||||||
context "with files that match the Guardfile" do
|
context "with files that match the Guardfile" do
|
||||||
specify { Guard::Watcher.match_guardfile?(['Guardfile', 'guard_rocks_spec.rb']).should be_true }
|
specify { described_class.match_guardfile?(['Guardfile', 'guard_rocks_spec.rb']).should be_true }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with no files that match the Guardfile" do
|
context "with no files that match the Guardfile" do
|
||||||
specify { Guard::Watcher.match_guardfile?(['guard_rocks.rb', 'guard_rocks_spec.rb']).should be_false }
|
specify { described_class.match_guardfile?(['guard_rocks.rb', 'guard_rocks_spec.rb']).should be_false }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user