2011-06-17 10:32:50 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
require 'guard/rails-assets'
|
|
|
|
|
|
|
|
describe Guard::RailsAssets do
|
|
|
|
let(:options) { {} }
|
|
|
|
subject { Guard::RailsAssets.new(['watchers'], options) }
|
|
|
|
|
|
|
|
describe '#start' do
|
2011-06-17 10:49:50 +00:00
|
|
|
it_behaves_like 'guard command', :command => :start, :run => true
|
2011-06-17 10:32:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#reload' do
|
2011-06-17 10:49:50 +00:00
|
|
|
it_behaves_like 'guard command', :command => :reload, :run => false
|
2011-06-17 10:32:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#run_all' do
|
2011-07-08 03:31:20 +00:00
|
|
|
it_behaves_like 'guard command', :command => :run_all, :run => false
|
2011-06-17 10:32:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#run_on_change' do
|
|
|
|
it_behaves_like 'guard command', :command => :run_on_change, :run => true
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2011-06-17 10:49:50 +00:00
|
|
|
describe 'asset compilation using CLI' do
|
|
|
|
def stub_system_with result
|
2011-06-19 17:32:14 +00:00
|
|
|
subject.should_receive(:system).with("bundle exec rake assets:clean assets:precompile").and_return result
|
2011-06-17 10:49:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should notify on success' do
|
|
|
|
stub_system_with true
|
2011-06-19 17:32:14 +00:00
|
|
|
Guard::Notifier.should_receive(:notify).with('Assets compiled')
|
2011-06-17 10:49:50 +00:00
|
|
|
subject.compile_assets
|
|
|
|
end
|
2011-06-24 04:24:28 +00:00
|
|
|
|
2011-06-17 10:49:50 +00:00
|
|
|
it 'should notify on failure' do
|
|
|
|
stub_system_with false
|
2011-06-17 13:56:09 +00:00
|
|
|
subject.should_not_receive(:`) # don't obtain tree
|
2011-06-17 10:49:50 +00:00
|
|
|
Guard::Notifier.should_receive(:notify).with('see the details in the terminal', :title => "Can't compile assets", :image => :failed)
|
|
|
|
subject.compile_assets
|
|
|
|
end
|
2011-06-17 10:32:50 +00:00
|
|
|
end
|
|
|
|
end
|