Slide 1

Slide 1 text

I'm afraid! of JavaScript

Slide 2

Slide 2 text

Ahoy! new friend

Slide 3

Slide 3 text

@searls

Slide 4

Slide 4 text

http://test-double.com

Slide 5

Slide 5 text

every developer FEAR shares a secret

Slide 6

Slide 6 text

...my code sucks? WHAT IF

Slide 7

Slide 7 text

AND WE COPE POORLY

Slide 8

Slide 8 text

stupid things we do: we pair less often we share less often we change less often

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

say it with me: “My Code Sucks”

Slide 11

Slide 11 text

say it with me: “My Code Sucks” sometimes

Slide 12

Slide 12 text

say it with me: “My Code Sucks” maybe

Slide 13

Slide 13 text

say it with me: “My Code Sucks” if you say so

Slide 14

Slide 14 text

SO FIGHT THE FEAR

Slide 15

Slide 15 text

and fail PROUDLY

Slide 16

Slide 16 text

as we talk! about JavaScript

Slide 17

Slide 17 text

STAGE 1

Slide 18

Slide 18 text

model STAGE 2

Slide 19

Slide 19 text

model view STAGE 2

Slide 20

Slide 20 text

model view dumping ground STAGE 2

Slide 21

Slide 21 text

STAGE 3

Slide 22

Slide 22 text

STAGE 3

Slide 23

Slide 23 text

STAGE 3

Slide 24

Slide 24 text

STAGE 3

Slide 25

Slide 25 text

STAGE 3

Slide 26

Slide 26 text

YOUR PAIR

Slide 27

Slide 27 text

YOUR PAIR GRABS A CARD

Slide 28

Slide 28 text

Slide 29

Slide 29 text

so you say, “let’s use JavaScript!”

Slide 30

Slide 30 text

but your pair’s all like

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

she says, “Start with the simplest thing that could possibly work!”

Slide 33

Slide 33 text

!== simplest

Slide 34

Slide 34 text

!== simplest easiest

Slide 35

Slide 35 text

!== simplest

Slide 36

Slide 36 text

!== simplest most familiar

Slide 37

Slide 37 text

!== simplest

Slide 38

Slide 38 text

!== simplest calling a server to sort an array & render HTML for you

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

so simple!‚

Slide 44

Slide 44 text

WHAT GOOD ARE YOUR SERVERS?

Slide 45

Slide 45 text

security persisting data analytics model behavior HTML templating routing users proxying UI events things servers are great at

Slide 46

Slide 46 text

security persisting data analytics proxying things servers are great at

Slide 47

Slide 47 text

model behavior HTML templating routing users UI events but it’s simpler when the client handles

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

DON’T PANIC

Slide 50

Slide 50 text

YOU’VE GOT THIS

Slide 51

Slide 51 text

model behavior HTML templating routing users UI events

Slide 52

Slide 52 text

model behavior HTML templating routing users UI events

Slide 53

Slide 53 text

jasmine

Slide 54

Slide 54 text

describe()

Slide 55

Slide 55 text

it()

Slide 56

Slide 56 text

expect().toBe()

Slide 57

Slide 57 text

expect().not.toBe()

Slide 58

Slide 58 text

beforeEach()

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

run it yourself! http://is.gd/logic1 describe('CallList', function() { });

Slide 63

Slide 63 text

run it yourself! http://is.gd/logic1 describe('CallList', function() { describe("#moveUp", function() { }); });

Slide 64

Slide 64 text

run it yourself! http://is.gd/logic1 describe('CallList', function() { describe("#moveUp", function() { context("moving up C", function() { }); }); });

Slide 65

Slide 65 text

run it yourself! http://is.gd/logic1 describe('CallList', function() { describe("#moveUp", function() { context("moving up C", function() { it("places it above B", function() { }); }); }); });

Slide 66

Slide 66 text

run it yourself! http://is.gd/logic1 describe('CallList', function() { var subject; beforeEach(function() { subject = new CallList({items: ['A','B','C']}); }); describe("#moveUp", function() { context("moving up C", function() { it("places it above B", function() { }); }); }); });

Slide 67

Slide 67 text

run it yourself! http://is.gd/logic1 describe('CallList', function() { var subject; beforeEach(function() { subject = new CallList({items: ['A','B','C']}); }); describe("#moveUp", function() { context("moving up C", function() { beforeEach(function() { subject.moveUp('C'); }); it("places it above B", function() { }); }); }); });

Slide 68

Slide 68 text

run it yourself! http://is.gd/logic1 describe('CallList', function() { var subject; beforeEach(function() { subject = new CallList({items: ['A','B','C']}); }); describe("#moveUp", function() { context("moving up C", function() { beforeEach(function() { subject.moveUp('C'); }); it("places it above B", function() { expect(subject.get('items')).toEqual(['A','C','B']); }); }); }); });

Slide 69

Slide 69 text

run it yourself! http://is.gd/logic1

Slide 70

Slide 70 text

run it yourself! http://is.gd/logic1 window.CallList = Backbone.Model.extend({ });

Slide 71

Slide 71 text

run it yourself! http://is.gd/logic1 window.CallList = Backbone.Model.extend({ moveUp: function(item) { } });

Slide 72

Slide 72 text

run it yourself! http://is.gd/logic1 window.CallList = Backbone.Model.extend({ moveUp: function(item) { this.set({items: ['A','C','B']}); } });

Slide 73

Slide 73 text

run it yourself! http://is.gd/logic1

Slide 74

Slide 74 text

run it yourself! http://is.gd/logic2 describe('CallList', function() { var subject; beforeEach(function() { subject = new CallList({items: ['A','B','C']}); }); describe("#moveUp", function() { context("moving up C", function() {...}); context("moving up B", function() { }); }); });

Slide 75

Slide 75 text

run it yourself! http://is.gd/logic2 describe('CallList', function() { var subject; beforeEach(function() { subject = new CallList({items: ['A','B','C']}); }); describe("#moveUp", function() { context("moving up C", function() {...}); context("moving up B", function() { it("places B above A", function() { }); }); }); });

Slide 76

Slide 76 text

run it yourself! http://is.gd/logic2 describe('CallList', function() { var subject; beforeEach(function() { subject = new CallList({items: ['A','B','C']}); }); describe("#moveUp", function() { context("moving up C", function() {...}); context("moving up B", function() { beforeEach(function() { subject.moveUp('B'); }); it("places B above A", function() { }); }); }); });

Slide 77

Slide 77 text

run it yourself! http://is.gd/logic2 describe('CallList', function() { var subject; beforeEach(function() { subject = new CallList({items: ['A','B','C']}); }); describe("#moveUp", function() { context("moving up C", function() {...}); context("moving up B", function() { beforeEach(function() { subject.moveUp('B'); }); it("places B above A", function() { expect(subject.get('items')).toEqual(['B','A','C']); }); }); }); });

Slide 78

Slide 78 text

run it yourself! http://is.gd/logic2

Slide 79

Slide 79 text

run it yourself! http://is.gd/logic2 window.CallList = Backbone.Model.extend({ moveUp: function(item) { var items = this.get('items'); } });

Slide 80

Slide 80 text

run it yourself! http://is.gd/logic2 window.CallList = Backbone.Model.extend({ moveUp: function(item) { var items = this.get('items'); var index = _(items).indexOf(item) - 1; } });

Slide 81

Slide 81 text

run it yourself! http://is.gd/logic2 window.CallList = Backbone.Model.extend({ moveUp: function(item) { var items = this.get('items'); var index = _(items).indexOf(item) - 1; items.splice(index,2,item,items[index]); } });

Slide 82

Slide 82 text

run it yourself! http://is.gd/logic2

Slide 83

Slide 83 text

run it yourself! http://is.gd/logic3 describe('CallList', function() { var subject; beforeEach(function() { subject = new CallList({items: ['A','B','C']}); }); describe("#moveUp", function() { context("moving up C", function() {...}); context("moving up B", function() {...}); context("moving up A", function() { }); }); });

Slide 84

Slide 84 text

run it yourself! http://is.gd/logic3 describe('CallList', function() { var subject; beforeEach(function() { subject = new CallList({items: ['A','B','C']}); }); describe("#moveUp", function() { context("moving up C", function() {...}); context("moving up B", function() {...}); context("moving up A", function() { it("leaves the items as they were", function() { }); }); }); });

Slide 85

Slide 85 text

run it yourself! http://is.gd/logic3 describe('CallList', function() { var subject; beforeEach(function() { subject = new CallList({items: ['A','B','C']}); }); describe("#moveUp", function() { context("moving up C", function() {...}); context("moving up B", function() {...}); context("moving up A", function() { beforeEach(function() { subject.moveUp('A'); }); it("leaves the items as they were", function() { }); }); }); });

Slide 86

Slide 86 text

run it yourself! http://is.gd/logic3 describe('CallList', function() { var subject; beforeEach(function() { subject = new CallList({items: ['A','B','C']}); }); describe("#moveUp", function() { context("moving up C", function() {...}); context("moving up B", function() {...}); context("moving up A", function() { beforeEach(function() { subject.moveUp('A'); }); it("leaves the items as they were", function() { expect(subject.get('items')).toEqual(['A','B','C']); }); }); }); });

Slide 87

Slide 87 text

run it yourself! http://is.gd/logic3

Slide 88

Slide 88 text

run it yourself! http://is.gd/logic3

Slide 89

Slide 89 text

run it yourself! http://is.gd/logic3 window.CallList = Backbone.Model.extend({ moveUp: function(item) { var items = this.get('items'); var index = _(items).indexOf(item) - 1; items.splice(index,2,item,items[index]); } });

Slide 90

Slide 90 text

run it yourself! http://is.gd/logic3 window.CallList = Backbone.Model.extend({ moveUp: function(item) { var items = this.get('items'); var index = _(items).indexOf(item) - 1; if(index >= 0) { items.splice(index,2,item,items[index]); } } });

Slide 91

Slide 91 text

run it yourself! http://is.gd/logic3

Slide 92

Slide 92 text

model behavior HTML templating routing users UI events

Slide 93

Slide 93 text

model behavior HTML templating routing users UI events

Slide 94

Slide 94 text

backbone

Slide 95

Slide 95 text

view model 00 00

Slide 96

Slide 96 text

view model 00 00 UI Event Occurs! “click .move-up”

Slide 97

Slide 97 text

view model 00 00 this.model.moveUp(‘C’)

Slide 98

Slide 98 text

view model 00 00 this.set({ items:[‘A’,’C’,’B’] });

Slide 99

Slide 99 text

view model 00 00 Model Event Fired! “change:items”

Slide 100

Slide 100 text

view model 00 00 change:items bound! this.render()

Slide 101

Slide 101 text

view model 00 00

Slide 102

Slide 102 text

view model 00 00 01

Slide 103

Slide 103 text

and now you know backbone!

Slide 104

Slide 104 text

run it yourself! http://is.gd/view1 describe "CallListView", ->

Slide 105

Slide 105 text

HOLD THE ☎

Slide 106

Slide 106 text

CoffeeScript

Slide 107

Slide 107 text

function(){}

Slide 108

Slide 108 text

No content

Slide 109

Slide 109 text

->

Slide 110

Slide 110 text

() {} ;

Slide 111

Slide 111 text

No content

Slide 112

Slide 112 text

optional

Slide 113

Slide 113 text

this.foo

Slide 114

Slide 114 text

No content

Slide 115

Slide 115 text

@foo

Slide 116

Slide 116 text

employee.group.department.company.yuck

Slide 117

Slide 117 text

employee.group.department.company.yuck TypeError: 'undefined' is not an object

Slide 118

Slide 118 text

employee.group.department.company.yuck

Slide 119

Slide 119 text

?. enter the existential operator

Slide 120

Slide 120 text

employee?.group?.department?.company?.yuck

Slide 121

Slide 121 text

employee?.group?.department?.company?.yuck now, merely “undefined”

Slide 122

Slide 122 text

employee?.group?.department?.company?.yuck now, merely “undefined” It’s Demeter-tastic!

Slide 123

Slide 123 text

run it yourself! http://is.gd/view1 describe "CallListView", -> describe "events", ->

Slide 124

Slide 124 text

run it yourself! http://is.gd/view1 describe "CallListView", -> describe "events", -> it "binds to up-arrow clicks", ->

Slide 125

Slide 125 text

run it yourself! http://is.gd/view1 describe "CallListView", -> beforeEach -> @subject = new CallListView describe "events", -> it "binds to up-arrow clicks", -> expect(@subject.events).toEqual "click .up-arrow": 'moveUp'

Slide 126

Slide 126 text

run it yourself! http://is.gd/view1

Slide 127

Slide 127 text

run it yourself! http://is.gd/view1 class CallListView extends Backbone.View

Slide 128

Slide 128 text

run it yourself! http://is.gd/view1 class CallListView extends Backbone.View events: "click .up-arrow": "moveUp"

Slide 129

Slide 129 text

run it yourself! http://is.gd/view1

Slide 130

Slide 130 text

run it yourself! http://is.gd/view1

Slide 131

Slide 131 text

run it yourself! http://is.gd/view1 class CallListView extends Backbone.View events: "click .up-arrow": "moveUp" moveUp: ->

Slide 132

Slide 132 text

run it yourself! http://is.gd/view1

Slide 133

Slide 133 text

jasmine spies

Slide 134

Slide 134 text

spyOn(object,‘method’)

Slide 135

Slide 135 text

spyOn(object,‘method’) jasmine.createSpy(‘method’)

Slide 136

Slide 136 text

spyOn(object,‘method’) jasmine.createSpy(‘method’) jasmine.createSpyObj(‘Name’,[‘method1’,‘method2’])

Slide 137

Slide 137 text

stubbing

Slide 138

Slide 138 text

spyOn(panda,‘isHappy’)

Slide 139

Slide 139 text

spyOn(panda,‘isHappy’) panda.isHappy.andReturn(true)

Slide 140

Slide 140 text

spyOn(panda,‘isHappy’) panda.isHappy.andReturn(true) panda.isHappy()

Slide 141

Slide 141 text

spyOn(panda,‘isHappy’) panda.isHappy.andReturn(true) panda.isHappy() returns true

Slide 142

Slide 142 text

verifying

Slide 143

Slide 143 text

spyOn(panda,‘feed’)

Slide 144

Slide 144 text

spyOn(panda,‘feed’) panda.feed()

Slide 145

Slide 145 text

spyOn(panda,‘feed’) expect(panda.feed).toHaveBeenCalled() panda.feed()

Slide 146

Slide 146 text

run it yourself! http://is.gd/view2 describe "CallListView", -> beforeEach -> @subject = new CallListView describe "events", -> it "binds to up-arrow clicks", -> expect(@subject.events).toEqual "click .up-arrow": 'moveUp' describe "#moveUp", -> it "tells the model to move up the arrow's text", ->

Slide 147

Slide 147 text

run it yourself! http://is.gd/view2 describe "CallListView", -> beforeEach -> @model = jasmine.createSpyObj('CallList',['bind','moveUp']) @subject = new CallListView model: @model describe "events", -> it "binds to up-arrow clicks", -> expect(@subject.events).toEqual "click .up-arrow": 'moveUp' describe "#moveUp", -> it "tells the model to move up the arrow's text", ->

Slide 148

Slide 148 text

run it yourself! http://is.gd/view2 describe "CallListView", -> beforeEach -> @model = jasmine.createSpyObj('CallList',['bind','moveUp']) @subject = new CallListView model: @model describe "events", -> it "binds to up-arrow clicks", -> expect(@subject.events).toEqual "click .up-arrow": 'moveUp' describe "#moveUp", -> beforeEach -> $upArrow = $(@subject.el).inject('up-arrow').text('C') it "tells the model to move up the arrow's text", ->

Slide 149

Slide 149 text

run it yourself! http://is.gd/view2 describe "CallListView", -> beforeEach -> @model = jasmine.createSpyObj('CallList',['bind','moveUp']) @subject = new CallListView model: @model describe "events", -> it "binds to up-arrow clicks", -> expect(@subject.events).toEqual "click .up-arrow": 'moveUp' describe "#moveUp", -> beforeEach -> $upArrow = $(@subject.el).inject('up-arrow').text('C') it "tells the model to move up the arrow's text", -> jasmine-fixture https://github.com/searls/jasmine-fixture

Slide 150

Slide 150 text

run it yourself! http://is.gd/view2 describe "CallListView", -> beforeEach -> @model = jasmine.createSpyObj('CallList',['bind','moveUp']) @subject = new CallListView model: @model describe "events", -> it "binds to up-arrow clicks", -> expect(@subject.events).toEqual "click .up-arrow": 'moveUp' describe "#moveUp", -> beforeEach -> $upArrow = $(@subject.el).inject('up-arrow').text('C') @subject.moveUp target: $upArrow[0] it "tells the model to move up the arrow's text", ->

Slide 151

Slide 151 text

run it yourself! http://is.gd/view2 describe "CallListView", -> beforeEach -> @model = jasmine.createSpyObj('CallList',['bind','moveUp']) @subject = new CallListView model: @model describe "events", -> it "binds to up-arrow clicks", -> expect(@subject.events).toEqual "click .up-arrow": 'moveUp' describe "#moveUp", -> beforeEach -> $upArrow = $(@subject.el).inject('up-arrow').text('C') @subject.moveUp target: $upArrow[0] it "tells the model to move up the arrow's text", -> expect(@model.moveUp).toHaveBeenCalledWith 'C'

Slide 152

Slide 152 text

run it yourself! http://is.gd/view2

Slide 153

Slide 153 text

run it yourself! http://is.gd/view2 class CallListView extends Backbone.View events: "click .up-arrow": "moveUp" moveUp: (e) -> @model.moveUp $(e.target).text()

Slide 154

Slide 154 text

run it yourself! http://is.gd/view2

Slide 155

Slide 155 text

HTML templating model behavior routing users UI events

Slide 156

Slide 156 text

HTML templating model behavior routing users UI events

Slide 157

Slide 157 text

run it yourself! http://is.gd/template1 describe "CallListView", -> beforeEach -> @model = jasmine.createSpyObj('CallList',['bind','moveUp']) @subject = new CallListView model: @model describe "events", -> ... describe "#moveUp", -> ... describe "#render", -> it "renders the template with the model's JSON", ->

Slide 158

Slide 158 text

run it yourself! http://is.gd/template1 describe "CallListView", -> beforeEach -> @model = jasmine.createSpyObj('CallList',['bind','moveUp']) @subject = new CallListView model: @model describe "events", -> ... describe "#moveUp", -> ... describe "#render", -> it "renders the template with the model's JSON", -> expect($(@subject.el)).toHaveHtml('HTML for bar')

Slide 159

Slide 159 text

run it yourself! http://is.gd/template1 describe "CallListView", -> beforeEach -> @model = jasmine.createSpyObj('CallList',['bind','moveUp']) @subject = new CallListView model: @model describe "events", -> ... describe "#moveUp", -> ... describe "#render", -> it "renders the template with the model's JSON", -> expect($(@subject.el)).toHaveHtml('HTML for bar') jasmine-jquery https://github.com/velesin/jasmine-jquery

Slide 160

Slide 160 text

run it yourself! http://is.gd/template1 describe "CallListView", -> beforeEach -> @model = jasmine.createSpyObj('CallList',['bind','moveUp']) @subject = new CallListView model: @model describe "events", -> ... describe "#moveUp", -> ... describe "#render", -> beforeEach -> @subject.render() it "renders the template with the model's JSON", -> expect($(@subject.el)).toHaveHtml('HTML for bar')

Slide 161

Slide 161 text

run it yourself! http://is.gd/template1 describe "CallListView", -> beforeEach -> @model = jasmine.createSpyObj('CallList',['bind','moveUp','toJSON']) @subject = new CallListView model: @model describe "events", -> ... describe "#moveUp", -> ... describe "#render", -> beforeEach -> @model.toJSON.andReturn foo: "bar" @subject.render() it "renders the template with the model's JSON", -> expect($(@subject.el)).toHaveHtml('HTML for bar')

Slide 162

Slide 162 text

run it yourself! http://is.gd/template1 describe "CallListView", -> beforeEach -> $template = inject('') $template.html('HTML for <%= foo %>') @model = jasmine.createSpyObj('CallList',['bind','moveUp','toJSON']) @subject = new CallListView model: @model describe "events", -> ... describe "#moveUp", -> ... describe "#render", -> beforeEach -> @model.toJSON.andReturn foo: "bar" @subject.render() it "renders the template with the model's JSON", -> expect($(@subject.el)).toHaveHtml('HTML for bar')

Slide 163

Slide 163 text

run it yourself! http://is.gd/template1

Slide 164

Slide 164 text

run it yourself! http://is.gd/template1 class CallListView extends Backbone.View events: "click .up-arrow": "moveUp" initialize: -> @template = _.template($('#call-list-template').html()) moveUp: (e) -> @model.moveUp $(e.target).text()

Slide 165

Slide 165 text

run it yourself! http://is.gd/template1 class CallListView extends Backbone.View events: "click .up-arrow": "moveUp" initialize: -> @template = _.template($('#call-list-template').html()) moveUp: (e) -> @model.moveUp $(e.target).text() render: -> $(@el).html(@template(@model.toJSON()))

Slide 166

Slide 166 text

run it yourself! http://is.gd/template1

Slide 167

Slide 167 text

routing users HTML templating model behavior UI events

Slide 168

Slide 168 text

routing users HTML templating model behavior UI events

Slide 169

Slide 169 text

router

Slide 170

Slide 170 text

class AppRouter extends Backbone.Router routes: “call-list”: “callList” callList: -> new CallListView(model: new CallList).render()

Slide 171

Slide 171 text

$ -> window.router = new AppRouter(); Backbone.history.start();

Slide 172

Slide 172 text

$ -> window.router = new AppRouter(); Backbone.history.start(); http://yourapp.dev/#call-list

Slide 173

Slide 173 text

$ -> window.router = new AppRouter(); Backbone.history.start(); http://yourapp.dev/#call-list router.navigate('call-list',true)

Slide 174

Slide 174 text

phew.

Slide 175

Slide 175 text

jasmine enhancers

Slide 176

Slide 176 text

jasmine-given https://github.com/searls/jasmine-given

Slide 177

Slide 177 text

beforeEach -> @subject = new Button() @result = @subject.press() it “goes ‘ohhh yeah’” expect(@result).toBe(‘ohhh yeah’)

Slide 178

Slide 178 text

beforeEach -> @subject = new Button() @result = @subject.press() it “goes ‘ohhh yeah’” expect(@result).toBe(‘ohhh yeah’) Given

Slide 179

Slide 179 text

beforeEach -> @subject = new Button() @result = @subject.press() it “goes ‘ohhh yeah’” expect(@result).toBe(‘ohhh yeah’) Given When

Slide 180

Slide 180 text

beforeEach -> @subject = new Button() @result = @subject.press() it “goes ‘ohhh yeah’” expect(@result).toBe(‘ohhh yeah’) Given When Then

Slide 181

Slide 181 text

beforeEach -> @subject = new Button() @result = @subject.press() it “goes ‘ohhh yeah’” expect(@result).toBe(‘ohhh yeah’) Given -> @subject = new Button() Given When Then

Slide 182

Slide 182 text

beforeEach -> @subject = new Button() @result = @subject.press() it “goes ‘ohhh yeah’” expect(@result).toBe(‘ohhh yeah’) Given -> @subject = new Button() When -> @result = @subject.press() Given When Then

Slide 183

Slide 183 text

beforeEach -> @subject = new Button() @result = @subject.press() it “goes ‘ohhh yeah’” expect(@result).toBe(‘ohhh yeah’) Given -> @subject = new Button() When -> @result = @subject.press() Then -> @result == “ohhh yeah” Given When Then

Slide 184

Slide 184 text

No content

Slide 185

Slide 185 text

When -> @config = createConfig()

Slide 186

Slide 186 text

When -> @config = createConfig() Then -> @config.url == "http://moore.chris"

Slide 187

Slide 187 text

When -> @config = createConfig() Then -> @config.url == "http://moore.chris" Then -> @config.name == "Peter Kananen"

Slide 188

Slide 188 text

When -> @config = createConfig() Then -> @config.url == "http://moore.chris" Then -> @config.name == "Peter Kananen" Then -> @config.bestMochaFriend == "Josh Owens"

Slide 189

Slide 189 text

When -> @config = createConfig() Then -> @config.url == "http://moore.chris" Then -> @config.name == "Peter Kananen" Then -> @config.bestMochaFriend == "Josh Owens" Then -> @config.bestDnDFriend == "James Smith"

Slide 190

Slide 190 text

When -> @config = createConfig() Then -> @config.url == "http://moore.chris" Then -> @config.name == "Peter Kananen" Then -> @config.bestMochaFriend == "Josh Owens" Then -> @config.bestDnDFriend == "James Smith"

Slide 191

Slide 191 text

When -> @config = createConfig() Then( -> @config.url == "http://moore.chris") .Then( -> @config.name == "Peter Kananen") .Then( -> @config.bestMochaFriend == "Josh Owens") .Then( -> @ config.bestDnDFriend == "James Smith")

Slide 192

Slide 192 text

When -> @config = createConfig() Then( -> @config.url == "http://moore.chris") .Then( -> @config.name == "Peter Kananen") .Then( -> @config.bestMochaFriend == "Josh Owens") .Then( -> @ config.bestDnDFriend == "James Smith")

Slide 193

Slide 193 text

jasmine-jquery https://github.com/velesin/jasmine-jquery

Slide 194

Slide 194 text

$button = $(‘.win’);

Slide 195

Slide 195 text

$button = $(‘.win’);

Slide 196

Slide 196 text

$button = $(‘.win’); expect($button).toExist()

Slide 197

Slide 197 text

$button = $(‘.win’); expect($button).toExist() expect($button).toHaveAttr("id","yay")

Slide 198

Slide 198 text

$button = $(‘.win’); expect($button).toExist() expect($button).toHaveAttr("id","yay") expect($button).toHaveId("yay")

Slide 199

Slide 199 text

$button = $(‘.win’); expect($button).toBe('span.hidden') expect($button).toExist() expect($button).toHaveAttr("id","yay") expect($button).toHaveId("yay")

Slide 200

Slide 200 text

$button = $(‘.win’); expect($button).toBe('span.hidden') expect($button).toExist() expect($button).toHaveAttr("id","yay") expect($button).toHaveText("Winning") expect($button).toHaveId("yay")

Slide 201

Slide 201 text

$button = $(‘.win’); expect($button).toBe('span.hidden') expect($button).toExist() expect($button).toHaveAttr("id","yay") expect($button).toHaveText("Winning") expect($button).toHaveId("yay") expect($button).toHaveClass("hidden")

Slide 202

Slide 202 text

jasmine-fixture https://github.com/searls/jasmine-fixture

Slide 203

Slide 203 text

No content

Slide 204

Slide 204 text

$foo = inject('foo')

Slide 205

Slide 205 text

$foo = inject('foo')

Slide 206

Slide 206 text

$foo = inject('foo')
$bar = $foo.inject('bar')

Slide 207

Slide 207 text

$foo = inject('foo')
$bar = $foo.inject('bar')

Slide 208

Slide 208 text

$foo = inject('foo')
$bar = $foo.inject('bar')
$input = $bar.inject(el: 'input', id: 'woot').val(42)

Slide 209

Slide 209 text

$foo = inject('foo')
$bar = $foo.inject('bar')
$input = $bar.inject(el: 'input', id: 'woot').val(42)

Slide 210

Slide 210 text

jasmine-stealth https://github.com/searls/jasmine-stealth

Slide 211

Slide 211 text

spyOn(model,'get')

Slide 212

Slide 212 text

spyOn(model,'get') model.get.andReturn('123-456-7890')

Slide 213

Slide 213 text

spyOn(model,'get') model.get.andReturn('123-456-7890') model.get.andReturn('[email protected]')

Slide 214

Slide 214 text

spyOn(model,'get') model.get.andReturn('123-456-7890') model.get.andReturn('[email protected]') model.get('email') #=> [email protected]

Slide 215

Slide 215 text

spyOn(model,'get') model.get.andReturn('123-456-7890') model.get.andReturn('[email protected]') model.get('phone') #=> [email protected] model.get('email') #=> [email protected]

Slide 216

Slide 216 text

spyOn(model,'get')

Slide 217

Slide 217 text

spyOn(model,'get') model.get.when('phone').thenReturn('123-456-7890')

Slide 218

Slide 218 text

spyOn(model,'get') model.get.when('phone').thenReturn('123-456-7890') model.get.when('email').thenReturn('[email protected]')

Slide 219

Slide 219 text

spyOn(model,'get') model.get.when('phone').thenReturn('123-456-7890') model.get.when('email').thenReturn('[email protected]') model.get('phone') #=> 123-456-7890

Slide 220

Slide 220 text

spyOn(model,'get') model.get.when('phone').thenReturn('123-456-7890') model.get.when('email').thenReturn('[email protected]') model.get('phone') #=> 123-456-7890 model.get('email') #=> [email protected]

Slide 221

Slide 221 text

jasmine-headless-webkit http://johnbintz.github.com/jasmine-headless-webkit/

Slide 222

Slide 222 text

command-line runner

Slide 223

Slide 223 text

No content

Slide 224

Slide 224 text

No content

Slide 225

Slide 225 text

guard rocks

Slide 226

Slide 226 text

github.com/searls +I’ll help!

Slide 227

Slide 227 text

@searls +I’ll help!

Slide 228

Slide 228 text

[email protected] +I’ll help!

Slide 229

Slide 229 text

•g l e e * for the color scheme •clafouti for the despair statue •SteveFE for the pouting girl •ifollowtherabbit for another color scheme •mokra for the jaw-dropped baby •Epicality for the third color scheme credits