blob: e53aa50dd33d8871d36b21da385b5d1ba2d8ed34 (
plain)
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
|
# frozen_string_literal: true
require 'spec_helper'
describe UserFinder do
describe '#execute' do
context 'when the user exists' do
it 'returns the user' do
user = create(:user)
found = described_class.new(id: user.id).execute
expect(found).to eq(user)
end
end
context 'when the user does not exist' do
it 'returns nil' do
found = described_class.new(id: 1).execute
expect(found).to be_nil
end
end
end
describe '#execute!' do
context 'when the user exists' do
it 'returns the user' do
user = create(:user)
found = described_class.new(id: user.id).execute!
expect(found).to eq(user)
end
end
context 'when the user does not exist' do
it 'raises ActiveRecord::RecordNotFound' do
finder = described_class.new(id: 1)
expect { finder.execute! }.to raise_error(ActiveRecord::RecordNotFound)
end
end
end
end
|