2011-06-21 13:48:27 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Guard::DslDescriber do
|
2011-08-31 07:47:03 +00:00
|
|
|
before(:each) do
|
|
|
|
::Guard.stub!(:guards).and_return([mock('Guard')])
|
|
|
|
user_config_path = File.expand_path(File.join('~', '.guard.rb'))
|
|
|
|
File.stub(:exist?).with(user_config_path) { false }
|
|
|
|
end
|
2011-07-02 08:01:45 +00:00
|
|
|
|
2011-06-21 13:48:27 +00:00
|
|
|
it 'should evaluate a Guardfile and create the right structure' do
|
|
|
|
mixed_guardfile_string = <<-GUARD
|
|
|
|
guard 'test', :a => :b do
|
|
|
|
watch('c')
|
|
|
|
end
|
|
|
|
|
|
|
|
group :a do
|
|
|
|
guard 'test' do
|
|
|
|
watch('c')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
group "b" do
|
|
|
|
guard 'another' do
|
|
|
|
watch('c')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
GUARD
|
|
|
|
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.evaluate_guardfile(:guardfile_contents => mixed_guardfile_string)
|
2011-06-21 13:48:27 +00:00
|
|
|
|
2011-09-22 22:22:44 +00:00
|
|
|
described_class.guardfile_structure.should == [
|
2011-06-21 13:48:27 +00:00
|
|
|
{ :guards => [ { :name => 'test', :options => { :a => :b } } ] },
|
|
|
|
{ :group => :a, :guards => [ { :name => 'test', :options => {} } ] },
|
|
|
|
{ :group => :b, :guards => [ { :name => 'another', :options => {} } ] }
|
|
|
|
]
|
|
|
|
end
|
2011-09-22 22:22:44 +00:00
|
|
|
|
2011-06-21 13:48:27 +00:00
|
|
|
end
|