Skip to content
Snippets Groups Projects
Commit c03416be authored by Marcela Ribeiro de Oliveira's avatar Marcela Ribeiro de Oliveira
Browse files

index and show subjects tests

parent fba2dee9
No related branches found
No related tags found
No related merge requests found
require 'acceptance_helpers'
resource 'Subjects' do
header 'Accept', 'application/json'
header 'Content-Type', 'application/json'
before { 12.times { create(:subject) } }
let(:subjects) { Subject.all }
get '/v1/subjects' do
parameter :limit, 'Limit of subjects'
parameter :offset, 'Offset of subjects'
let(:limit) { 12 }
let(:offset) { 0 }
example_request 'Get a list of subjects' do
# active model serializer may render model associations in different order for collections (array of items), so we're verifing only returned ids
expect(JSON.parse(response_body).map { |o| o['id'] }.sort).to eq(Subject.limit(limit).offset(offset).pluck(:id).sort)
expect(status).to eq(200)
end
end
end
FactoryGirl.define do
factory :subject do
name { Faker::Name.name }
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment