Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # code
- def client_id
- Client.id_by_name record[:client]
- end
- # spec
- context '#client_id' do
- it 'Returns id of client with name that exists in database' do
- allow(Client).to receive(:id_by_name).and_return 14
- expect(record.client_id).to eq 14
- end
- it 'Returns nil if no client with given name in database' do
- allow(Client).to receive(:id_by_name).and_return nil
- expect(record.client_id).to be_nil
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement