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
| var Animal = function(omnivore) { | |
| this.omnivore = omnivore; | |
| } | |
| var human = Animal(true); | |
| console.log("the human is an omnivore " + human.omnivore); | |
| //this will throw "TypeError: Cannot read property 'omnivore' of undefined" |
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
| var Animal = function(omnivore) { | |
| this.omnivore = omnivore; | |
| } | |
| var human = {}; | |
| Animal.apply(human, [true]); | |
| console.log("the human is an omnivore " + human.omnivore); | |
| //this will print "the human is an omnivore true" |
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
| var Animal = function(omnivore) { | |
| this.omnivore = omnivore; | |
| } | |
| var human = {}; | |
| Animal.call(human, true); | |
| console.log("the human is an omnivore " + human.omnivore); | |
| //this will print "the human is an omnivore true" |
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
| { | |
| "name": "unit_testing_javascript", | |
| "description": "npm files needed to unit test javascript in isolation", | |
| "version": "0.0.1", | |
| "dependencies": { | |
| "jasmine-node": "", | |
| "jsdom": "", | |
| "jasmine-jquery": "" | |
| } | |
| } |
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
| #!/bin/sh | |
| brew install node | |
| curl http://npmjs.org/install.sh | sh | |
| export NODE_PATH="$NODE_PATH:/usr/local/lib/node_modules" |
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
| describe ("first test suite", function(){ | |
| it ("2 should equal 2", function(){ | |
| expect("2").toBe("2"); | |
| }); | |
| it ("1 should not equal 2", function(){ | |
| expect("1").not.toBe("2"); | |
| }); | |
| }) |
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
| node_installed = `which node` | |
| if node_installed.empty? | |
| home_dir = "/home/someuserhere/" | |
| node_dir = "#{home_dir}Downloads/" | |
| node_download = "#{node_dir}joyent-node-v0.8.1-0-g2134aa3.zip" | |
| node_extracted_dir = "#{node_dir}joyent-node/" | |
| execute "rm -rf #{node_download}" | |
| execute "rm -rf #{node_extracted_dir}" |
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
| node_dir = "/home/someuserhere/Downloads/" | |
| node_download = "#{node_dir}joyent-node-v0.8.1-0-g2134aa3.zip" | |
| node_extracted_dir = "#{node_dir}joyent-node/" | |
| execute "rm -rf #{node_download}" | |
| execute "rm -rf #{node_extracted_dir}" | |
| execute "wget 'https://github.com/joyent/node/zipball/v0.8.1' -O #{node_download}" | |
| execute "unzip #{node_download} -d #{node_extracted_dir}" | |
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
| var phantom = require('phantom'); | |
| phantom.create(function(ph) { | |
| return ph.createPage(function(page) { | |
| return page.open("http://localhost:8090/runner.html", function(status) { | |
| return page.evaluate((function() { | |
| var results = $(document.body).find('.description')[0].text; | |
| var failures = $(document.body).find(".description:contains('failures')"); | |
| if (failures.size() > 0) return "All tests passed! %@".fmt(results); |
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
| var get = Ember.get; | |
| /** | |
| * @extends Ember.Mixin | |
| * | |
| * Implements common filter / sort / pagination behavior for array controllers | |
| * */ | |
| Ember.FilterSortSliceMixin = Ember.Mixin.create({ | |
| filterBy: '', |