/
run_this_async_spec.rb
48 lines (37 loc) · 1.07 KB
/
run_this_async_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
46
47
48
require 'spec_helper'
describe '#run_this' do
let(:job_id) { nil }
let(:arg) { 1 }
let(:arg2) { 2 }
let(:callee) { double }
let(:encoded_callee) { double }
before do
allow(RunThisAsync::Callee::Encoder).to receive(:call).
with(callee).and_return(encoded_callee)
end
context 'one method' do
it 'schedules runner job' do
expect(RunThisAsync::AsyncRunner).to receive(:perform_async).with(
job_id, encoded_callee, [:call], [[arg]]
)
callee.run_this.call(arg).async
end
end
context 'chained methods' do
it 'schedules runner job' do
expect(RunThisAsync::AsyncRunner).to receive(:perform_async).with(
job_id, encoded_callee, [:new, :call], [[arg, arg2], []]
)
callee.run_this.new(arg, arg2).call.async
end
end
context 'expected job id' do
let(:job_id) { 'a certain expected job id' }
it 'sets the job id' do
expect(RunThisAsync::AsyncRunner).to receive(:perform_async).with(
job_id, encoded_callee, [], []
)
callee.run_this(job_id).async
end
end
end