Advertisement
S-Mage

Untitled

Feb 21st, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.46 KB | None | 0 0
  1. # code
  2.     def client_id
  3.       Client.id_by_name record[:client]
  4.     end
  5.  
  6. # spec
  7.   context '#client_id' do
  8.     it 'Returns id of client with name that exists in database' do
  9.       allow(Client).to receive(:id_by_name).and_return 14
  10.       expect(record.client_id).to eq 14
  11.     end
  12.     it 'Returns nil if no client with given name in database' do
  13.       allow(Client).to receive(:id_by_name).and_return nil
  14.       expect(record.client_id).to be_nil
  15.     end
  16.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement