guard-rocco/spec/lib/guard/rocco_spec.rb

58 lines
1.3 KiB
Ruby
Raw Normal View History

2011-06-18 19:33:21 +00:00
require 'spec_helper'
require 'guard/rocco'
require 'fileutils'
describe Guard::Rocco do
let(:doc_dir) { 'spec/doc' }
before do
FileUtils.rm_rf doc_dir
FileUtils.mkdir_p doc_dir
end
after do
FileUtils.rm_rf doc_dir
end
2011-11-15 16:23:01 +00:00
let(:guard) { Guard::Rocco.new([], options) }
2011-06-18 19:33:21 +00:00
let(:filename) { 'lib/guard/rocco.rb' }
2011-11-15 16:23:01 +00:00
let(:options) { { :dir => doc_dir } }
2011-06-18 19:33:21 +00:00
describe '#run_all' do
2011-11-15 16:23:01 +00:00
let(:options) { { :dir => doc_dir, :run_on => [ :all ] } }
2011-06-18 19:33:21 +00:00
before do
guard.stubs(:all_paths).returns([filename])
end
it 'should generate the docs' do
guard.run_all
File.file?(File.join(doc_dir, 'lib/guard/rocco.html')).should be_true
end
end
describe '#run_on_change' do
it 'should generate the doc' do
guard.run_on_change([filename])
File.file?(File.join(doc_dir, 'lib/guard/rocco.html')).should be_true
end
end
2011-11-13 13:16:09 +00:00
describe 'run options' do
it 'should allow array of symbols' do
guard = Guard::Rocco.new([], :run_on => [:start, :change])
2011-11-15 16:23:01 +00:00
guard.send(:run_for?, :start).should be_true
guard.send(:run_for?, :reload).should be_false
2011-11-13 13:16:09 +00:00
end
it 'should allow symbol' do
2011-11-15 16:23:01 +00:00
guard = Guard::Rocco.new([], :run_on => :start)
guard.send(:run_for?, :start).should be_true
guard.send(:run_for?, :reload).should be_false
2011-11-13 13:16:09 +00:00
end
end
2011-06-18 19:33:21 +00:00
end