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

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

parents 7d804740 c03416be
No related branches found
No related tags found
No related merge requests found
...@@ -25,7 +25,7 @@ resource 'Institutions' do ...@@ -25,7 +25,7 @@ resource 'Institutions' do
get '/v1/institutions/:id' do get '/v1/institutions/:id' do
let(:id) { institutions.first.id } let(:id) { institutions.first.id }
example 'Get a institution' do example 'Get an institution' do
do_request do_request
expect(path).to eq("/v1/institutions/#{id}") # `:id` is replaced with the value of `id` 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(response_body).to eq(Helper.serialize(Institution.find(id)))
......
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 FactoryGirl.define do
factory :institution do |m| factory :institution do
name { Faker::Name.name } name { Faker::Name.name }
description { Faker::Lorem.paragraph } description { Faker::Lorem.paragraph }
address { Faker::Address.street_address } address { Faker::Address.street_address }
......
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