Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.28 KB | None | 0 0
  1.   describe 'GET /api/announcements' do
  2.     let(:url) { '/api/announcements/' }
  3.  
  4.     before do
  5.       create_list(:announcement, 2, user: author)
  6.       get url, headers: author_header
  7.     end
  8.  
  9.     it 'returns announcements' do
  10.       expect(json).not_to be_empty
  11.       expect(json.first.keys).to match_array(expected_keys)
  12.       expect(json.size).to eq(3)
  13.  
  14.       json.each do |item|
  15.         expect(item['user_id']).to eq(author.id)
  16.       end
  17.     end
  18.  
  19.     it 'returns status code 200' do
  20.       expect(response).to have_http_status(200)
  21.     end
  22.  
  23.     it_should_behave_like 'authenticable' do
  24.       before { get url }
  25.     end
  26.   end
  27.  
  28.   describe 'GET /api/announcements/active' do
  29.     let(:url) { '/api/announcements/active' }
  30.  
  31.     before do
  32.       create_list(:announcement, 2, user: author)
  33.       get url, headers: author_header
  34.     end
  35.  
  36.     it 'returns announcements' do
  37.       expect(json).not_to be_empty
  38.       expect(json.first.keys).to match_array(expected_keys)
  39.       expect(json.size).to eq(3)
  40.  
  41.       json.each do |item|
  42.         expect(item['status']).to eq('active')
  43.       end
  44.     end
  45.  
  46.     it 'returns status code 200' do
  47.       expect(response).to have_http_status(200)
  48.     end
  49.  
  50.     it_should_behave_like 'authenticable' do
  51.       before { get url }
  52.     end
  53.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement