-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram_spec.rb
More file actions
31 lines (23 loc) · 779 Bytes
/
program_spec.rb
File metadata and controls
31 lines (23 loc) · 779 Bytes
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
require './base.rb'
require './child.rb'
require './program.rb'
describe Program do
it 'should only stub the base' do
allow_any_instance_of(Base).to receive(:foo) do |&block|
block.call
end
expect(STDOUT).to receive(:puts).with('base foo').never
expect(STDOUT).to receive(:puts).with('child foo').once
expect(STDOUT).to receive(:puts).with('running').once
Program.new.run
end
it 'should only stub the base in nested calls' do
allow_any_instance_of(Base).to receive(:foo) do |&block|
block.call
end
expect(STDOUT).to receive(:puts).with('base foo').never
expect(STDOUT).to receive(:puts).with('child foo').twice
expect(STDOUT).to receive(:puts).with('running nested').once
Program.new.run_nested
end
end