-
Notifications
You must be signed in to change notification settings - Fork 14
added all working files to lab-ron to turn in on canvas. #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
|  Lab 01: Modular Patterns and Testing | ||
| === | ||
|
|
||
| ##To Submit this Assignment | ||
| * fork this repository | ||
| * write all of your code in a directory named `lab-` + `<your name>` **e.g.** `lab-duncan` | ||
| * push to your repository | ||
| * submit a pull request to this repository | ||
| * submit a link to your PR in canvas | ||
| * write a question and observation on canvas | ||
|
|
||
| ## Resources | ||
| * [Node assert docs](https://nodejs.org/dist/latest-v4.x/docs/api/assert.html) | ||
| * [Mocha docs](http://mochajs.org/#getting-started) | ||
|
|
||
| ##Description: | ||
| This assignment will have you create a simple Javascript object that will be exported using the Node modular pattern we went over in class. | ||
|
|
||
| Your object should have a function named 'greet' that takes a name as a parameter and returns the string 'hello ' + name | ||
|
|
||
| You should have at least one test that verifies the output of the function. | ||
|
|
||
| Your code should pass the **.eslintrc** included in this repository. | ||
|
|
||
| Your submission should be a link to your pull request. | ||
|
|
||
| ##Bonus: | ||
| For an extra point, create a command line utility that will be run using node greet.js 'some name' and will pass the input contained in that argument to the greet function and output the result to the screen. | ||
|
|
||
| For a second bonus point, write a test that makes sure that the arguments are being processed. | ||
|
|
||
| ##Rubric: | ||
| * Proper Styling: 2pts | ||
| * Proper Submission: 2pts | ||
| * mocha/assert Test: 3pts | ||
| * Use of Modular Pattern/design of greet object/function: 3pts | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| 'use strict'; | ||
|
|
||
| const greet = require('../lib/greet.js'); | ||
| const assert = require('assert'); | ||
|
|
||
|
|
||
| describe('testing greet module', function(){ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Rubiksron best practice is to include an additional describe block, inside of this one, that includes the method name - your outer describe block should reference the module that you are testing. For example: |
||
| it('should return Ron', function(){ | ||
| var result = greet('Ron'); | ||
| assert.equal(result, 'hello Ron', 'expected "hello Ron"'); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| 'use strict'; | ||
|
|
||
| const gulp = require('gulp'); | ||
| const eslint = require('gulp-eslint'); | ||
| const mocha = require('gulp-mocha'); | ||
|
|
||
| gulp.task('test', function(){ | ||
| gulp.src('./test/*-test.js', {read: false}) | ||
| .pipe(mocha({reporter: 'nyan'})); | ||
| }); | ||
|
|
||
| gulp.task('lint', function(){ | ||
| return gulp.src(['**/*.js','!node_modules/**']) | ||
| .pipe(eslint()) | ||
| .pipe(eslint.format()) | ||
| .pipe(eslint.failAfterError()); | ||
| }); | ||
|
|
||
| gulp.task('dev', function(){ | ||
| gulp.watch(['**/*.js','!node_modules/**'], ['lint', 'test']); | ||
| }); | ||
|
|
||
| gulp.task('default', ['dev']); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| 'use strict'; | ||
|
|
||
| module.exports = function(name) { | ||
| if (!name) throw new Error('expected name'); | ||
| return `hello ${name}`; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Rubiksron great use of string interpolation here! |
||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| { | ||
| "name": "lab-ron-dunphy", | ||
| "version": "1.0.0", | ||
| "description": " Lab 01: Modular Patterns and Testing ===", | ||
| "main": "app.js", | ||
| "directories": { | ||
| "test": "test" | ||
| }, | ||
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1" | ||
| }, | ||
| "keywords": [], | ||
| "author": "", | ||
| "license": "ISC", | ||
| "devDependencies": { | ||
| "gulp": "^3.9.1", | ||
| "gulp-eslint": "^3.0.1", | ||
| "gulp-mocha": "^3.0.1", | ||
| "mocha": "^3.0.2" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| 'use strict'; | ||
|
|
||
| const greet = require('../lib/greet'); | ||
| const assert = require('assert'); | ||
|
|
||
| describe('testing module greet', function(){ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Rubiksron Same goes here, with regards to your single describe block. Feel free to reference my comment above for additional info. |
||
| it('should return hello Ron', function(){ | ||
| let result = greet('Ron'); | ||
| assert.ok(result === 'hello Ron', 'was not hello Ron'); | ||
| }); | ||
|
|
||
| it('should throw a missing a name error', function(){ | ||
| assert.throws(function(){ | ||
| greet(); | ||
| }, 'should have thrown that err'); | ||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Rubiksron no need to include this README in your PR