Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated koans with some basic instructions and more clarify in what's…

… purposefully broken in each spec
  • Loading branch information...
commit a998d27e59aee5c7b2943f8aad97a58c37743e6f 1 parent b10cb71
Larry Myers authored
2  css/koansReporter.css
View
@@ -7,7 +7,7 @@ h2 {
}
#summary {
- font-size: 18px;
+ font-size: 16px;
}
.alert-message {
35 js/koans/aboutEvents.js
View
@@ -7,10 +7,10 @@ describe('About Backbone.Events', function() {
obj.unbind(); // remove all custom events before each spec is run.
});
- it('Can extend javascript objects to support custom events.', function() {
+ it('Any regular javascript object can be extended with custom event functionality.', function() {
var basicObject = {};
- // How would you give basicObject these functions?
+ // How would you get these Backbone.Events functions added to basicObject?
// Hint: http://documentcloud.github.com/backbone/#Events
expect(typeof basicObject.bind).toEqual('function');
@@ -18,7 +18,7 @@ describe('About Backbone.Events', function() {
expect(typeof basicObject.trigger).toEqual('function');
});
- it('Allows us to bind and trigger custom named events on an object.', function() {
+ it('Events allows us to bind and trigger custom named events on an object.', function() {
var callback = jasmine.createSpy('-Custom Event Callback-');
obj.bind('basic event', callback);
@@ -28,27 +28,32 @@ describe('About Backbone.Events', function() {
expect(callback).toHaveBeenCalled();
});
- it('Also passes along any arguments to the callback when an event is triggered.', function() {
- var passedArgs = [];
+ it('Triggered events pass along any arguments to the callback.', function() {
+ var callback = jasmine.createSpy('-Custom Event Callback-');
- obj.bind('some event', function() {
- for (var i = 0; i < arguments.length; i++) {
- passedArgs.push(arguments[i]);
- }
- });
+ obj.bind('some event', callback);
obj.trigger('some event');
- expect(passedArgs).toEqual(['arg1', 'arg2']);
+ expect(callback.mostRecentCall.args).toEqual(['arg1', 'arg2']);
});
- it('Can also bind the passed context to the event callback.', function() {
+ it('Bound events can also pass a specific context to the event callback.', function() {
var foo = { color: 'blue' };
var changeColor = function() {
this.color = 'red';
}
+ /***
+ * Does refering to 'this' from within an anonymous function seem foreign to you?
+ * No idea what 'context' refers to when talking about javascript?
+ * Here's a some reading that can help clarify things:
+ * http://javascriptweblog.wordpress.com/2010/08/30/understanding-javascripts-this/
+ *
+ * Now, back to the koans ...
+ ***/
+
// How would you get 'this.color' to refer to 'foo' in the changeColor function?
obj.bind('an event', changeColor);
@@ -58,16 +63,18 @@ describe('About Backbone.Events', function() {
expect(foo.color).toEqual('red');
});
- it("Uses 'all' as a special event name to capture all events bound to the object.", function() {
+ it("Evented objects can bind 'all' as a special event name to capture all triggered events on the object.", function() {
var callback = jasmine.createSpy('-Custom Event Callback-');
obj.bind('all', callback);
+ // How are you going to call obj.trigger to get both expectations passing?
+
expect(callback.callCount).toBe(1);
expect(callback.mostRecentCall.args[0]).toBe('custom event');
});
- it('Also can remove custom events from objects.', function() {
+ it('Evented objects can also have their named events removed.', function() {
var spy1 = jasmine.createSpy('-Spy 1-');
var spy2 = jasmine.createSpy('-Spy 2-');
var spy3 = jasmine.createSpy('-Spy 3-');
5 js/koans/aboutRouters.js
View
@@ -0,0 +1,5 @@
+describe('About Backbone.Router', function() {
+ it('Should be a stub.', function() {
+
+ });
+});
13 specrunner.html
View
@@ -20,10 +20,23 @@
<script type="text/javascript" src="js/koans/aboutCollections.js"></script>
<script type="text/javascript" src="js/koans/aboutViews.js"></script>
<script type="text/javascript" src="js/koans/aboutApps.js"></script>
+ <script type="text/javascript" src="js/koans/aboutRouters.js"></script>
</head>
<body>
<h1>Backbone Koans</h1>
+ <h2>Instructions</h2>
+
+ <ol>
+ <li>Open a new browser tab for the <a href="http://documentcloud.github.com/backbone/">Backbone.js Docs</a>
+ and <a href="js/todos.js">todos.js</a>. You'll need to refer to these while fixing the failing tests.
+ <li>Get each failing test passing without modifying the expect() statements or todos.js</li>
+ <li>Not familiar with <a href="http://pivotal.github.com/jasmine/">Jasmine</a>?
+ Take a moment to check out the <a href="https://github.com/pivotal/jasmine/wiki">documentation</a> first.</li>
+ </ol>
+
+ <h2>Current Progress</h2>
+
<ul id="summary" class="unstyled"></ul>
<div id="progress"></div>
Please sign in to comment.
Something went wrong with that request. Please try again.