/
reload_spec.rb
45 lines (38 loc) · 1.25 KB
/
reload_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require 'spec_helper'
describe 'Guard::Interactor::RELOAD' do
before do
Guard.stub(:reload)
Guard.stub(:setup_interactor)
Pry.output.stub(:puts)
stub_const 'Guard::Bar', Class.new(Guard::Guard)
end
let(:guard) { ::Guard.setup }
let(:foo_group) { guard.add_group(:foo) }
let(:bar_guard) { guard.add_guard(:bar, [], [], { :group => :foo }) }
describe '#perform' do
context 'without scope' do
it 'runs the :reload action' do
Guard.should_receive(:reload).with({ :groups => [], :plugins => [] })
Pry.run_command 'reload'
end
end
context 'with a valid Guard group scope' do
it 'runs the :reload action with the given scope' do
Guard.should_receive(:reload).with({ :groups => [foo_group], :plugins => [] })
Pry.run_command 'reload foo'
end
end
context 'with a valid Guard plugin scope' do
it 'runs the :reload action with the given scope' do
Guard.should_receive(:reload).with({ :plugins => [bar_guard], :groups => [] })
Pry.run_command 'reload bar'
end
end
context 'with an invalid scope' do
it 'does not run the action' do
Guard.should_not_receive(:reload)
Pry.run_command 'reload baz'
end
end
end
end