diff --git a/spec/acceptance/contacts_spec.rb b/spec/acceptance/contacts_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..f4d3d737f6dc222c3cde21864f037c0b58abc55c --- /dev/null +++ b/spec/acceptance/contacts_spec.rb @@ -0,0 +1,69 @@ +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 diff --git a/spec/factories/contacts.rb b/spec/factories/contacts.rb new file mode 100644 index 0000000000000000000000000000000000000000..040d4ba854f6e5c50da4c588342b10d42e23ab22 --- /dev/null +++ b/spec/factories/contacts.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + factory :contact do |f| + f.name { Faker::Name.name } + f.email { Faker::Internet.email } + f.message { Faker::Lorem.sentence } + end +end