This file contains hidden or 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
| //javascript | |
| var myRegexFunctionMap = { | |
| "/qty: (\d+)/": function (obj, matches) { | |
| obj.quantity = matches[1]; | |
| }, | |
| "/size: (\d+)x(\d)/": function (obj, matches) { | |
| obj.width = matches[1]; | |
| obj.height = matches[2]; | |
| }, | |
| //etc |
This file contains hidden or 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
| # Download base layer (~1 min) | |
| FROM ubuntu:14.04 | |
| # Install required packages (~2 mins) | |
| RUN apt-get update -qy && apt-get install -y \ | |
| curl git libgmp-dev libpq-dev libqt5webkit5-dev nodejs \ | |
| qt5-default supervisor | |
| # Install RVM (~2 mins) | |
| RUN /bin/bash -l -c "curl -L get.rvm.io | bash -s stable --rails" | |
| # Copy over the current commit SHA of our application (~45 secs) | |
| ADD . /webapp/current |
This file contains hidden or 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
| // assuming we are already defining Hapi server routes | |
| const payloadSchema = Joi.object().keys({ | |
| id : Joi.string().guid().required(), | |
| name : Joi.string().min(3).required(), | |
| callRequested: Joi.boolean().optional(), | |
| phoneNumber : Joi.when(‘callRequested’, { | |
| is : true, | |
| then : Joi.string().min(10).required(), | |
| otherwise: Joi.string().allow(null).optional() | |
| }) |
This file contains hidden or 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
| const documentSchema = Joi.object().keys({/*property definitions here*/}); | |
| Joi.validate(document, documentSchema, function(err, value) { | |
| if (err) { | |
| throw new Error(‘Document failed validation’); | |
| } else { | |
| // write doc to PG | |
| } | |
| }); |
This file contains hidden or 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
| // In request handler | |
| const document = { | |
| id : null, | |
| name: {first: null, last: null} | |
| }; | |
| // later in request handler | |
| document.id = Uuid.v4(); | |
| document.name.first = computedValues.firstName; | |
| document.name.last = computedValues.lastName; |
This file contains hidden or 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
| const docSchema = SchemaDictionary.docType; |
This file contains hidden or 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
| const schema = Joi.object().keys({ | |
| id: Joi.string().guid().required(), | |
| name: Joi.object.keys({ | |
| first: Joi.string().required(), | |
| last: Joi.string().required() | |
| }).required() | |
| }); | |
| const Document = Felicity.entityFor(schema); |
This file contains hidden or 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
| const mockDoc = Felicity.example(schema); | |
| console.log(mockDoc); | |
| /* | |
| { | |
| id: ‘d254d580-c56e-43a8-8f3c-5db38d8061c3’, | |
| name: { | |
| first: ‘qgrbddy’, | |
| last: ‘jdocnld’ | |
| } | |
| } |
This file contains hidden or 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
| const Document = Felicity.entityFor(SchemaDictionary.docType); | |
| const documentInstance = new Document(); | |
| // later in request handler | |
| documentInstance.id = Uuid.v4(); | |
| documentInstance.name.first = computedValues.firstName; | |
| documentInstance.name.last = computedValues.lastName; | |
| documentInstance.validate(function(err, value) { | |
| if (err) { | |
| throw new Error(err); |
This file contains hidden or 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
| feature 'the Guest can RSVP' do | |
| scenario 'they enter their names in the RSVP form' do | |
| find('span.rsvp-link').click | |
| find_field('first-name').set('1') | |
| find_field('last-name').set('1') | |
| click_button('find-invite') | |
| find('.rsvp-button', match: :first).click | |
| find('.next-guest').click | |
| find('#submit-rsvp').click | |
| expect(page).to have_content("Thanks, we've received your RSVP.") |