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
function add(arg1, arg2) { | |
return arg1 + arg2; | |
} | |
function subtract(arg1, arg2) { | |
return arg1 - arg2; | |
} | |
function multiply(arg1, arg2) { | |
return arg1 * arg2; |
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
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
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
{ | |
"type": "upemail", | |
"fired_at": "<time>", | |
"data": { | |
"new_id": "a0dcb064ff", | |
"new_email": "<TEST_NEW_EMAIL>", | |
"old_email": "<TEST_OLD_EMAIL>", | |
"list_id": "123456" | |
} | |
} |
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
Handlebars.registerPartial('getButton', | |
"<button class='{{className}}' data-book-id={{id}}>{{text}}</button>" | |
); |
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
Handlebars.registerHelper('formatName', function (name) { | |
return 'Mr. ' + name; | |
}); |
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
data = [ | |
{ | |
"id": 1, | |
"name": "Javascript", | |
"price": 80, | |
"author": "Author-1" | |
}, | |
{ | |
"id": 2, | |
"name": "Ruby", |
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
$.get('/books', function (data) { | |
booksListHtml = HandlebarsTemplates['book_list']({ | |
books: data | |
}); | |
$('#book-list').html(booksListHtml); | |
}); |
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
/* | |
* Ruby's String#center, String#rjust, String#ljust | |
* | |
* https://jsfiddle.net/6v0bpffm/ | |
*/ | |
function ljust( string, width, padding ) { | |
padding = padding || " "; | |
padding = padding.substr( 0, 1 ); | |
if ( string.length < width ) |