Skip to content

Instantly share code, notes, and snippets.

View samueljoli's full-sized avatar
🔒
lalilulelo

Samuel Joli samueljoli

🔒
lalilulelo
View GitHub Profile
//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
# 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
// 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()
})
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
}
});
// 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;
const docSchema = SchemaDictionary.docType;
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);
const mockDoc = Felicity.example(schema);
console.log(mockDoc);
/*
{
id: ‘d254d580-c56e-43a8-8f3c-5db38d8061c3’,
name: {
first: ‘qgrbddy’,
last: ‘jdocnld’
}
}
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);
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.")