Skip to content
Snippets Groups Projects
Commit 12ee68b4 authored by Giovanne Marcelo's avatar Giovanne Marcelo
Browse files

Merge branch 'rspec' of gitlab.c3sl.ufpr.br:portalmec/portalmec into rspec

parents 2fde7460 c70ffcee
No related branches found
No related tags found
No related merge requests found
require 'acceptance_helpers'
resource 'Institutions' do
header 'Accept', 'application/json'
header 'Content-Type', 'application/json'
before { 12.times { create(:institution) } }
let(:institutions) { Institution.all }
get '/v1/institutions' do
parameter :limit, 'Limit of institutions'
parameter :offset, 'Offset of institutions'
let(:limit) { 12 }
let(:offset) { 0 }
example_request 'Get a list of institutions' 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(Institution.limit(limit).offset(offset).pluck(:id).sort)
expect(status).to eq(200)
end
end
get '/v1/institutions/:id' do
let(:id) { institutions.first.id }
example 'Get a institution' do
do_request
expect(path).to eq("/v1/institutions/#{id}") # `:id` is replaced with the value of `id`
expect(response_body).to eq(Helper.serialize(Institution.find(id)))
expect(status).to eq(200)
end
end
end
FactoryGirl.define do
factory :institution do |m|
name { Faker::Name.name }
description { Faker::Lorem.paragraph }
address { Faker::Address.street_address }
city { Faker::Address.city }
country { Faker::Address.country }
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