Created
October 31, 2015 15:03
-
-
Save AugustoPedraza/42d325263dd7888ecfcf to your computer and use it in GitHub Desktop.
WEDIDIT- Rails Engineer Interview : Mini-coding exercise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Given the following User Story: | |
## As a registered User, | |
## I want to send a technical request to the sys admin, | |
## So that they are aware I have a problem. | |
## Acceptance criteria | |
## * Email sent to ENV['ADMIN_EMAIL'] | |
## Provide a "spec outline" which clearly shows what you will be testing, illustrated by file locations and | |
## statement hierarchy without actually writing any [implementation] code, for example: | |
## [...] | |
## ------------------------------------------------------------------------------------------------------------------------------------------------ | |
# spec/controllers/technical_requests_controller_spec.rb | |
describe TechnicalResquestsController, type: :controller do | |
describe 'POST /technical_requests' do | |
context 'when the user is authenticated' do | |
context 'when the params are not valid' do | |
it 'renders the form partial with the found errors' | |
end | |
context 'when the params are valid' do | |
context 'when the mailer send the email' do | |
it 'creates a new technical request for the logged user' | |
it 'renders the success view' | |
end | |
context 'when the mailer does not send the email' do | |
it 'does not create any technical request' | |
it 'renders the form partial with the found error' | |
end | |
end | |
end | |
context 'when the user is not authenticated' do | |
it 'redirects to /users/sign_in' | |
end | |
end | |
end | |
# spec/models/technical_request_spec.rb | |
describe TechnicalResquest, type: :model do | |
describe "# Validations" do | |
# test validations | |
end | |
end | |
# spec/mailers/technical_requests_mailer_spec.rb | |
describe TechnicalResquestsMailer, type: :mailer do | |
describe ':: Class methods' do | |
describe '.notify_new_request' do | |
context 'when the ADM is a valid email' do | |
#Test the email containts the right subject, from and to addresses | |
end | |
context 'when the ADM is not a valid email' do | |
it 'raises an ArgumentError' | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment