tea-time/presentation/04_expect.slides

92 lines
1.3 KiB
Plaintext
Raw Normal View History

2012-03-13 17:29:42 +00:00
!SLIDE
# `expect`
!SLIDE
# What should we get as an output?
!SLIDE even-larger
``` coffeescript
describe 'Cat', ->
describe '#meow', ->
it 'should meow correctly', ->
expect(cat.meow()).toEqual('meow')
```
!SLIDE
# Wait, we need a cat.
!SLIDE even-larger
``` coffeescript
describe 'Cat', ->
describe '#meow', ->
it 'should meow correctly', ->
cat = new Cat()
expect(cat.meow()).toEqual('meow')
```
!SLIDE even-larger
``` coffeescript
# code-under-test
2012-03-24 14:20:56 +00:00
class @Cat
2012-03-13 17:29:42 +00:00
meow: ->
```
2012-03-22 13:48:09 +00:00
!SLIDE larger
2012-03-13 17:29:42 +00:00
``` javascript
// safety wrapper to prevent global pollution
(function() {
this.Cat = (function() {
function Cat() {}
Cat.prototype.meow = function() {};
return Cat;
})();
})(this) // this is window in a browser
```
!SLIDE
# Run it!
!SLIDE even-larger
```
1 spec, 1 failure
Expected undefined to equal 'meow'.
```
!SLIDE
# Make it meow!
!SLIDE even-larger
``` coffeescript
2012-03-24 14:20:56 +00:00
class @Cat
2012-03-13 17:29:42 +00:00
meow: -> "meow"
```
!SLIDE even-larger
```
1 spec, 0 failures
```
!SLIDE
# Here's what you should have meow...
!SLIDE even-larger
``` coffeescript
# spec
describe 'Cat', ->
describe '#meow', ->
it 'should meow correctly', ->
expect(cat.meow()).toEqual('meow')
```
!SLIDE even-larger
``` coffeescript
# code-under-test
2012-03-24 14:20:56 +00:00
class @Cat
2012-03-13 17:29:42 +00:00
meow: -> "meow"
```