Your SlideShare is downloading. ×
0
How do I test my Sproutcore Application?               Greg Moeck
@gregmoeck
Quick Poll
Question   1
Full TimeSproutcore?
Full TimeJavaScript?
Other?
Question   2
PracticeTDD/BDD?
PracticeTest Last  UnitTesting?
NoAutomated  Tests?
Question   3
Practice TDD/BDDIn JS / SC?
What We Want InOur Tests
EnsureApplication Behavior
All Objects   Work Together
All Objects   WorkIndividually
All Objects Work    Together  Acceptance/Integration Tests
All Objects Work   Individually  Unit Tests
“     Unit Tests Tell You That    You Built The System Right.     Acceptance / Integration    Tests Tell You That You’ve  ...
Integration   Tests
EnsuresValue ForThe User
Use TheSystem As The User  Would
Scenario(Searching For An Item, function() { Given(an auction item that is available for sale, function() {  var itemTitle...
Scenario(Searching For An Item, function() { Given(an auction item that is available for sale, function() {  var itemTitle...
Scenario(Searching For An Item, function() { Given(an auction item that is available for sale, function() {  var itemTitle...
Scenario(Searching For An Item, function() { Given(an auction item that is available for sale, function() {  var itemTitle...
Scenario(Searching For An Item, function() { Given(an auction item that is available for sale, function() {  var itemTitle...
Scenario(Searching For An Item, function() { Given(an auction item that is available for sale, function() {  var itemTitle...
Scenario(Searching For An Item, function() { Given(an auction item that is available for sale, function() {  var itemTitle...
Scenario(Searching For An Item, function() { Given(an auction item that is available for sale, function() {  var itemTitle...
UnitTests
EnsuresValue Of TheArchitecture
Use Object   Like ACollaborator  Would
Isolate  TheObject
Example:Testing A  View
TestThroughView API
TotalFlow
Example
sc-init todos --template
install jasmine-sproutcorehttps://github.com/gmoeck/jasmine-             sproutcore
install simulohttps://github.com/gmoeck/simulo
describe(Scenario: Adding a todo, function() {  Given(I have loaded the todo application, function() {    afterEach(functi...
describe(Scenario: Adding a todo, function() {  Given(I have loaded the todo application, function() {    afterEach(functi...
describe(Scenario: Adding a todo, function() {  Given(I have loaded the todo application, function() {    afterEach(functi...
describe(Scenario: Adding a todo, function() {  Given(I have loaded the todo application, function() {    afterEach(functi...
describe(Scenario: Adding a todo, function() {  Given(I have loaded the todo application, function() {    afterEach(functi...
describe(Scenario: Adding a todo, function() {  Given(I have loaded the todo application, function() {    afterEach(functi...
describe(Scenario: Adding a todo, function() {  Given(I have loaded the todo application, function() {    afterEach(functi...
describe(Scenario: Adding a todo, function() {  Given(I have loaded the todo application, function() {    afterEach(functi...
describe(Scenario: Adding a todo, function() {  Given(I have loaded the todo application, function() {    afterEach(functi...
resources/templates/todos.handlebars<h1>Todos</h1>{{#view Todos.CreateTodoView}}  <input id="new-todo" type="text" placeho...
Error
Error
views/create_todo_view.jsTodos.CreateTodoView = SC.TemplateView.extend({});
resources/templates/todos.handlebars<h1>Todos</h1>{{#view Todos.CreateTodoView}}  <input id="new-todo" type="text" placeho...
views/todo_list_view.jsTodos.TodoListView = SC.TemplateCollectionView.extend({});
tests/unit/views/create_todo_view_spec.js describe(Todos.CreateTodoView, function() {  describe(#insertNewline, function()...
tests/unit/views/create_todo_view_spec.js describe(Todos.CreateTodoView, function() {  describe(#insertNewline, function()...
tests/unit/views/create_todo_view_spec.js describe(Todos.CreateTodoView, function() {  describe(#insertNewline, function()...
tests/unit/views/create_todo_view_spec.js describe(Todos.CreateTodoView, function() {  describe(#insertNewline, function()...
tests/unit/views/create_todo_view_spec.js describe(Todos.CreateTodoView, function() {  describe(#insertNewline, function()...
tests/unit/views/create_todo_view_spec.js describe(Todos.CreateTodoView, function() {  describe(#insertNewline, function()...
tests/unit/views/create_todo_view_spec.js describe(Todos.CreateTodoView, function() {  describe(#insertNewline, function()...
Todos.todoListController.createTodo
controllers/todo_list_controller.jsTodos.todoListController = SC.ArrayController.create({  createTodo: function(title) {  ...
views/create_todo_view.jsTodos.CreateTodoView = SC.TemplateView.extend(SC.TextFieldSupport, {  insertNewline: function() {...
views/create_todo_view.jsTodos.CreateTodoView = SC.TemplateView.extend(SC.TextFieldSupport, {  insertNewline: function() {...
Should be different, but we already definedTodos.todoListController.
tests/unit/controllers/todo_list_controller_spec.jsdescribe(Todos.todoListController, function() { describe(#createTodo, f...
tests/unit/controllers/todo_list_controller_spec.jsdescribe(Todos.todoListController, function() { describe(#createTodo, f...
tests/unit/controllers/todo_list_controller_spec.jsdescribe(Todos.todoListController, function() { describe(#createTodo, f...
tests/unit/controllers/todo_list_controller_spec.jsdescribe(Todos.todoListController, function() { describe(#createTodo, f...
tests/unit/controllers/todo_list_controller_spec.jsdescribe(Todos.todoListController, function() { describe(#createTodo, f...
tests/unit/controllers/todo_list_controller_spec.jsdescribe(Todos.todoListController, function() { describe(#createTodo, f...
Todos.Todo.create
models/todo.jsTodos.Todo = SC.Object.extend({});
controllers/todo_list_controller.jsTodos.todoListController = SC.ArrayController.create({  createTodo: function(title) {  ...
tests/unit/controllers/todo_list_controller_spec.jsdescribe(Todos.todoListController, function() { describe(#createTodo, f...
controllers/todo_list_controller.jsTodos.todoListController = SC.ArrayController.create({ content: [],  createTodo: functi...
controllers/todo_list_controller.jsTodos.todoListController = SC.ArrayController.create({ content: [],  createTodo: functi...
Questions?gmoeck@gmail.com   @gregmoeck
Testing Your Sproutcore Presentation
Testing Your Sproutcore Presentation
Testing Your Sproutcore Presentation
Testing Your Sproutcore Presentation
Testing Your Sproutcore Presentation
Testing Your Sproutcore Presentation
Testing Your Sproutcore Presentation
Testing Your Sproutcore Presentation
Testing Your Sproutcore Presentation
Testing Your Sproutcore Presentation
Testing Your Sproutcore Presentation
Testing Your Sproutcore Presentation
Testing Your Sproutcore Presentation
Testing Your Sproutcore Presentation
Testing Your Sproutcore Presentation
Testing Your Sproutcore Presentation
Testing Your Sproutcore Presentation
Testing Your Sproutcore Presentation
Testing Your Sproutcore Presentation
Testing Your Sproutcore Presentation
Testing Your Sproutcore Presentation
Testing Your Sproutcore Presentation
Testing Your Sproutcore Presentation
Testing Your Sproutcore Presentation
Testing Your Sproutcore Presentation
Upcoming SlideShare
Loading in...5
×

Testing Your Sproutcore Presentation

1,512

Published on

How to test your Sproutcore application using BDD.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,512
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
29
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript of "Testing Your Sproutcore Presentation"

    1. 1. How do I test my Sproutcore Application? Greg Moeck
    2. 2. @gregmoeck
    3. 3. Quick Poll
    4. 4. Question 1
    5. 5. Full TimeSproutcore?
    6. 6. Full TimeJavaScript?
    7. 7. Other?
    8. 8. Question 2
    9. 9. PracticeTDD/BDD?
    10. 10. PracticeTest Last UnitTesting?
    11. 11. NoAutomated Tests?
    12. 12. Question 3
    13. 13. Practice TDD/BDDIn JS / SC?
    14. 14. What We Want InOur Tests
    15. 15. EnsureApplication Behavior
    16. 16. All Objects Work Together
    17. 17. All Objects WorkIndividually
    18. 18. All Objects Work Together Acceptance/Integration Tests
    19. 19. All Objects Work Individually Unit Tests
    20. 20. “ Unit Tests Tell You That You Built The System Right. Acceptance / Integration Tests Tell You That You’ve Built The Right System Gojko Adzic, Specification by Example
    21. 21. Integration Tests
    22. 22. EnsuresValue ForThe User
    23. 23. Use TheSystem As The User Would
    24. 24. Scenario(Searching For An Item, function() { Given(an auction item that is available for sale, function() { var itemTitle = item; beforeEach(function() { Fictum.addResource(Item, {title: itemTitle}); }); When(I search for that auction item, function() { beforeEach(function() { Simulo.fillIn(#mainSearchWidget input[type="text"], itemTitle); Simulo.clickOn(#mainSearchWidget .submit-search); }); Then(I should see the auction item within the search results, function(page) { page.within(.search-results, function(page) { expect(page).toHaveContent(itemTitle); }); }); }); }); });});
    25. 25. Scenario(Searching For An Item, function() { Given(an auction item that is available for sale, function() { var itemTitle = item; beforeEach(function() { Fictum.addResource(Item, {title: itemTitle}); }); When(I search for that auction item, function() { beforeEach(function() { Simulo.fillIn(#mainSearchWidget input[type="text"], itemTitle); Simulo.clickOn(#mainSearchWidget .submit-search); }); Then(I should see the auction item within the search results, function(page) { page.within(.search-results, function(page) { expect(page).toHaveContent(itemTitle); }); }); }); }); });});
    26. 26. Scenario(Searching For An Item, function() { Given(an auction item that is available for sale, function() { var itemTitle = item; beforeEach(function() { Fictum.addResource(Item, {title: itemTitle}); }); When(I search for that auction item, function() { beforeEach(function() { Simulo.fillIn(#mainSearchWidget input[type="text"], itemTitle); Simulo.clickOn(#mainSearchWidget .submit-search); }); Then(I should see the auction item within the search results, function(page) { page.within(.search-results, function(page) { expect(page).toHaveContent(itemTitle); }); }); }); }); });});
    27. 27. Scenario(Searching For An Item, function() { Given(an auction item that is available for sale, function() { var itemTitle = item; beforeEach(function() { Fictum.addResource(Item, {title: itemTitle}); }); When(I search for that auction item, function() { beforeEach(function() { Simulo.fillIn(#mainSearchWidget input[type="text"], itemTitle); Simulo.clickOn(#mainSearchWidget .submit-search); }); Then(I should see the auction item within the search results, function(page) { page.within(.search-results, function(page) { expect(page).toHaveContent(itemTitle); }); }); }); }); });});
    28. 28. Scenario(Searching For An Item, function() { Given(an auction item that is available for sale, function() { var itemTitle = item; beforeEach(function() { Fictum.addResource(Item, {title: itemTitle}); }); When(I search for that auction item, function() { beforeEach(function() { Simulo.fillIn(#mainSearchWidget input[type="text"], itemTitle); Simulo.clickOn(#mainSearchWidget .submit-search); }); Then(I should see the auction item within the search results, function(page) { page.within(.search-results, function(page) { expect(page).toHaveContent(itemTitle); }); }); }); }); });});
    29. 29. Scenario(Searching For An Item, function() { Given(an auction item that is available for sale, function() { var itemTitle = item; beforeEach(function() { Fictum.addResource(Item, {title: itemTitle}); }); When(I search for that auction item, function() { beforeEach(function() { Simulo.fillIn(#mainSearchWidget input[type="text"], itemTitle); Simulo.clickOn(#mainSearchWidget .submit-search); }); Then(I should see the auction item within the search results, function(page) { page.within(.search-results, function(page) { expect(page).toHaveContent(itemTitle); }); }); }); }); });});
    30. 30. Scenario(Searching For An Item, function() { Given(an auction item that is available for sale, function() { var itemTitle = item; beforeEach(function() { Fictum.addResource(Item, {title: itemTitle}); }); When(I search for that auction item, function() { beforeEach(function() { Simulo.fillIn(#mainSearchWidget input[type="text"], itemTitle); Simulo.clickOn(#mainSearchWidget .submit-search); }); Then(I should see the auction item within the search results, function(page) { page.within(.search-results, function(page) { expect(page).toHaveContent(itemTitle); }); }); }); }); });});
    31. 31. Scenario(Searching For An Item, function() { Given(an auction item that is available for sale, function() { var itemTitle = item; beforeEach(function() { Fictum.addResource(Item, {title: itemTitle}); }); When(I search for that auction item, function() { beforeEach(function() { Simulo.fillIn(#mainSearchWidget input[type="text"], itemTitle); Simulo.clickOn(#mainSearchWidget .submit-search); }); Then(I should see the auction item within the search results, function(page) { page.within(.search-results, function(page) { expect(page).toHaveContent(itemTitle); }); }); }); }); });});
    32. 32. UnitTests
    33. 33. EnsuresValue Of TheArchitecture
    34. 34. Use Object Like ACollaborator Would
    35. 35. Isolate TheObject
    36. 36. Example:Testing A View
    37. 37. TestThroughView API
    38. 38. TotalFlow
    39. 39. Example
    40. 40. sc-init todos --template
    41. 41. install jasmine-sproutcorehttps://github.com/gmoeck/jasmine- sproutcore
    42. 42. install simulohttps://github.com/gmoeck/simulo
    43. 43. describe(Scenario: Adding a todo, function() { Given(I have loaded the todo application, function() { afterEach(function() { Todos.mainPane.remove(); }); When(I add a new todo item, function() { var description; beforeEach(function() { description = Do Something; Simulo.fillIn(#new-todo, description).pressEnter(); }); Then(I should see the item in the list of available items, function(page) { page.within(#incomplete-todos, function(page) { expect(page).toHaveContent(description); }); }); }); });});
    44. 44. describe(Scenario: Adding a todo, function() { Given(I have loaded the todo application, function() { afterEach(function() { Todos.mainPane.remove(); }); When(I add a new todo item, function() { var description; beforeEach(function() { description = Do Something; Simulo.fillIn(#new-todo, description).pressEnter(); }); Then(I should see the item in the list of available items, function(page) { page.within(#incomplete-todos, function(page) { expect(page).toHaveContent(description); }); }); }); });});
    45. 45. describe(Scenario: Adding a todo, function() { Given(I have loaded the todo application, function() { afterEach(function() { Todos.mainPane.remove(); }); When(I add a new todo item, function() { var description; beforeEach(function() { description = Do Something; Simulo.fillIn(#new-todo, description).pressEnter(); }); Then(I should see the item in the list of available items, function(page) { page.within(#incomplete-todos, function(page) { expect(page).toHaveContent(description); }); }); }); });});
    46. 46. describe(Scenario: Adding a todo, function() { Given(I have loaded the todo application, function() { afterEach(function() { Todos.mainPane.remove(); }); When(I add a new todo item, function() { var description; beforeEach(function() { description = Do Something; Simulo.fillIn(#new-todo, description).pressEnter(); }); Then(I should see the item in the list of available items, function(page) { page.within(#incomplete-todos, function(page) { expect(page).toHaveContent(description); }); }); }); });});
    47. 47. describe(Scenario: Adding a todo, function() { Given(I have loaded the todo application, function() { afterEach(function() { Todos.mainPane.remove(); }); When(I add a new todo item, function() { var description; beforeEach(function() { description = Do Something; Simulo.fillIn(#new-todo, description).pressEnter(); }); Then(I should see the item in the list of available items, function(page) { page.within(#incomplete-todos, function(page) { expect(page).toHaveContent(description); }); }); }); });});
    48. 48. describe(Scenario: Adding a todo, function() { Given(I have loaded the todo application, function() { afterEach(function() { Todos.mainPane.remove(); }); When(I add a new todo item, function() { var description; beforeEach(function() { description = Do Something; Simulo.fillIn(#new-todo, description).pressEnter(); }); Then(I should see the item in the list of available items, function(page) { page.within(#incomplete-todos, function(page) { expect(page).toHaveContent(description); }); }); }); });});
    49. 49. describe(Scenario: Adding a todo, function() { Given(I have loaded the todo application, function() { afterEach(function() { Todos.mainPane.remove(); }); When(I add a new todo item, function() { var description; beforeEach(function() { description = Do Something; Simulo.fillIn(#new-todo, description).pressEnter(); }); Then(I should see the item in the list of available items, function(page) { page.within(#incomplete-todos, function(page) { expect(page).toHaveContent(description); }); }); }); });});
    50. 50. describe(Scenario: Adding a todo, function() { Given(I have loaded the todo application, function() { afterEach(function() { Todos.mainPane.remove(); }); When(I add a new todo item, function() { var description; beforeEach(function() { description = Do Something; Simulo.fillIn(#new-todo, description).pressEnter(); }); Then(I should see the item in the list of available items, function(page) { page.within(#incomplete-todos, function(page) { expect(page).toHaveContent(description); }); }); }); });});
    51. 51. describe(Scenario: Adding a todo, function() { Given(I have loaded the todo application, function() { afterEach(function() { Todos.mainPane.remove(); }); When(I add a new todo item, function() { var description; beforeEach(function() { description = Do Something; Simulo.fillIn(#new-todo, description).pressEnter(); }); Then(I should see the item in the list of available items, function(page) { page.within(#incomplete-todos, function(page) { expect(page).toHaveContent(description); }); }); }); });});
    52. 52. resources/templates/todos.handlebars<h1>Todos</h1>{{#view Todos.CreateTodoView}} <input id="new-todo" type="text" placeholder="What needs to be done?" >{{/view}}
    53. 53. Error
    54. 54. Error
    55. 55. views/create_todo_view.jsTodos.CreateTodoView = SC.TemplateView.extend({});
    56. 56. resources/templates/todos.handlebars<h1>Todos</h1>{{#view Todos.CreateTodoView}} <input id="new-todo" type="text" placeholder="What needs to be done?" >{{/view}}{{#collection Todos.TodoListView id="incomplete-todos"}} {{content.title}}{{/collection}}
    57. 57. views/todo_list_view.jsTodos.TodoListView = SC.TemplateCollectionView.extend({});
    58. 58. tests/unit/views/create_todo_view_spec.js describe(Todos.CreateTodoView, function() { describe(#insertNewline, function() { var createTodoSpy, value; beforeEach(function() { value = Do Something; view = Todos.CreateTodoView.create({value: value}); createTodoSpy = spyOn(Todos.todoListController, createTodo); view.insertNewline(); }); it(delegates to create a new todo with its current value, function() { expect(createTodoSpy).toHaveBeenCalledWith(value); }); });
    59. 59. tests/unit/views/create_todo_view_spec.js describe(Todos.CreateTodoView, function() { describe(#insertNewline, function() { var createTodoSpy, value; beforeEach(function() { value = Do Something; view = Todos.CreateTodoView.create({value: value}); createTodoSpy = spyOn(Todos.todoListController, createTodo); view.insertNewline(); }); it(delegates to create a new todo with its current value, function() { expect(createTodoSpy).toHaveBeenCalledWith(value); }); });
    60. 60. tests/unit/views/create_todo_view_spec.js describe(Todos.CreateTodoView, function() { describe(#insertNewline, function() { var createTodoSpy, value; beforeEach(function() { value = Do Something; view = Todos.CreateTodoView.create({value: value}); createTodoSpy = spyOn(Todos.todoListController, createTodo); view.insertNewline(); }); it(delegates to create a new todo with its current value, function() { expect(createTodoSpy).toHaveBeenCalledWith(value); }); });
    61. 61. tests/unit/views/create_todo_view_spec.js describe(Todos.CreateTodoView, function() { describe(#insertNewline, function() { var createTodoSpy, value; beforeEach(function() { value = Do Something; view = Todos.CreateTodoView.create({value: value}); createTodoSpy = spyOn(Todos.todoListController, createTodo); view.insertNewline(); }); it(delegates to create a new todo with its current value, function() { expect(createTodoSpy).toHaveBeenCalledWith(value); }); });
    62. 62. tests/unit/views/create_todo_view_spec.js describe(Todos.CreateTodoView, function() { describe(#insertNewline, function() { var createTodoSpy, value; beforeEach(function() { value = Do Something; view = Todos.CreateTodoView.create({value: value}); createTodoSpy = spyOn(Todos.todoListController, createTodo); view.insertNewline(); }); it(delegates to create a new todo with its current value, function() { expect(createTodoSpy).toHaveBeenCalledWith(value); }); });
    63. 63. tests/unit/views/create_todo_view_spec.js describe(Todos.CreateTodoView, function() { describe(#insertNewline, function() { var createTodoSpy, value; beforeEach(function() { value = Do Something; view = Todos.CreateTodoView.create({value: value}); createTodoSpy = spyOn(Todos.todoListController, createTodo); view.insertNewline(); }); it(delegates to create a new todo with its current value, function() { expect(createTodoSpy).toHaveBeenCalledWith(value); }); });
    64. 64. tests/unit/views/create_todo_view_spec.js describe(Todos.CreateTodoView, function() { describe(#insertNewline, function() { var createTodoSpy, value; beforeEach(function() { value = Do Something; view = Todos.CreateTodoView.create({value: value}); createTodoSpy = spyOn(Todos.todoListController, createTodo); view.insertNewline(); }); it(delegates to create a new todo with its current value, function() { expect(createTodoSpy).toHaveBeenCalledWith(value); }); });
    65. 65. Todos.todoListController.createTodo
    66. 66. controllers/todo_list_controller.jsTodos.todoListController = SC.ArrayController.create({ createTodo: function(title) { }});
    67. 67. views/create_todo_view.jsTodos.CreateTodoView = SC.TemplateView.extend(SC.TextFieldSupport, { insertNewline: function() { }});
    68. 68. views/create_todo_view.jsTodos.CreateTodoView = SC.TemplateView.extend(SC.TextFieldSupport, { insertNewline: function() { Todos.todoListController.createTodo(this.get(value)); }});
    69. 69. Should be different, but we already definedTodos.todoListController.
    70. 70. tests/unit/controllers/todo_list_controller_spec.jsdescribe(Todos.todoListController, function() { describe(#createTodo, function() { var createTodoSpy, title; beforeEach(function() { title = title; createTodoSpy = spyOn(Todos.Todo, create); Todos.todoListController.createTodo(title); }); it(creates a todo with the passed in title, function() { expect(createTodoSpy).toHaveBeenCalledWith({title: title}); }); });});
    71. 71. tests/unit/controllers/todo_list_controller_spec.jsdescribe(Todos.todoListController, function() { describe(#createTodo, function() { var createTodoSpy, title; beforeEach(function() { title = title; createTodoSpy = spyOn(Todos.Todo, create); Todos.todoListController.createTodo(title); }); it(creates a todo with the passed in title, function() { expect(createTodoSpy).toHaveBeenCalledWith({title: title}); }); });});
    72. 72. tests/unit/controllers/todo_list_controller_spec.jsdescribe(Todos.todoListController, function() { describe(#createTodo, function() { var createTodoSpy, title; beforeEach(function() { title = title; createTodoSpy = spyOn(Todos.Todo, create); Todos.todoListController.createTodo(title); }); it(creates a todo with the passed in title, function() { expect(createTodoSpy).toHaveBeenCalledWith({title: title}); }); });});
    73. 73. tests/unit/controllers/todo_list_controller_spec.jsdescribe(Todos.todoListController, function() { describe(#createTodo, function() { var createTodoSpy, title; beforeEach(function() { title = title; createTodoSpy = spyOn(Todos.Todo, create); Todos.todoListController.createTodo(title); }); it(creates a todo with the passed in title, function() { expect(createTodoSpy).toHaveBeenCalledWith({title: title}); }); });});
    74. 74. tests/unit/controllers/todo_list_controller_spec.jsdescribe(Todos.todoListController, function() { describe(#createTodo, function() { var createTodoSpy, title; beforeEach(function() { title = title; createTodoSpy = spyOn(Todos.Todo, create); Todos.todoListController.createTodo(title); }); it(creates a todo with the passed in title, function() { expect(createTodoSpy).toHaveBeenCalledWith({title: title}); }); });});
    75. 75. tests/unit/controllers/todo_list_controller_spec.jsdescribe(Todos.todoListController, function() { describe(#createTodo, function() { var createTodoSpy, title; beforeEach(function() { title = title; createTodoSpy = spyOn(Todos.Todo, create); Todos.todoListController.createTodo(title); }); it(creates a todo with the passed in title, function() { expect(createTodoSpy).toHaveBeenCalledWith({title: title}); }); });});
    76. 76. Todos.Todo.create
    77. 77. models/todo.jsTodos.Todo = SC.Object.extend({});
    78. 78. controllers/todo_list_controller.jsTodos.todoListController = SC.ArrayController.create({ createTodo: function(title) { Todos.Todo.create({title: title}); }});
    79. 79. tests/unit/controllers/todo_list_controller_spec.jsdescribe(Todos.todoListController, function() { describe(#createTodo, function() { var createTodoSpy, title, todo; beforeEach(function() { title = title; todo = {title: title}; createTodoSpy = spyOn(Todos.Todo, create).andReturn(todo); Todos.todoListController.createTodo(title); }); ... it(adds that todo to its content, function() { expect(Todos.todoListController.get(content)).toContain(todo); }); });});
    80. 80. controllers/todo_list_controller.jsTodos.todoListController = SC.ArrayController.create({ content: [], createTodo: function(title) { Todos.Todo.create({title: title}); }});
    81. 81. controllers/todo_list_controller.jsTodos.todoListController = SC.ArrayController.create({ content: [], createTodo: function(title) { var todo = Todos.Todo.create({title: title}); this.pushObject(todo); }});
    82. 82. Questions?gmoeck@gmail.com @gregmoeck
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×