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

add contacts test

parent 6dbf7427
No related branches found
No related tags found
No related merge requests found
require 'acceptance_helpers'
resource 'Contacts' do
before { 12.times { create(:contact) } }
let(:contacts) { Contact.all }
get '/v1/contacts' do
example_request 'Getting all contacts' do
expect(status).to eq(200)
end
end
get '/v1/contacts/:id' do
let(:id) { contacts.first.id }
example_request 'Getting a contact' do
expect(status).to eq(200)
end
end
post '/v1/contacts' do
parameter :name, 'The name of the contact', scope: :contact
parameter :link, 'The email of the contact', scope: :contact
parameter :description, 'The message of the contact', scope: :contact
let(:id) { contacts.first.id }
let(:name) { Faker::Name.name }
let(:email) { Faker::Internet.email }
let(:message) { Faker::Lorem.sentence }
let(:raw_post) { params.to_json }
example_request 'Create contacts' do
expect(status).to eq(201)
end
end
put '/v1/contacts/:id' do
parameter :name, 'The name of the contact', scope: :contact
parameter :link, 'The email of the contact', scope: :contact
parameter :description, 'The message of the contact', scope: :contact
let(:id) { contacts.first.id }
let(:name) { Faker::Name.name }
let(:email) { Faker::Internet.email }
let(:message) { Faker::Lorem.sentence }
let(:raw_post) { params.to_json }
example_request 'Updating contacts' do
expect(status).to eq(200)
end
end
delete '/v1/contacts/:id' do
let(:id) { contacts.first.id }
example_request 'Destroy a contact' do
expect(status).to eq(200)
end
end
end
FactoryGirl.define do
factory :contact do |f|
f.name { Faker::Name.name }
f.email { Faker::Internet.email }
f.message { Faker::Lorem.sentence }
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