presentation fixes for rubynation

This commit is contained in:
John Bintz 2012-03-22 09:48:09 -04:00
parent 70c4264416
commit 713f81bc44
10 changed files with 49 additions and 71 deletions

View File

@ -52,13 +52,13 @@ end
onmouseout="this.src='normal.gif'" />
```
!SLIDE larger
!SLIDE
``` html
<script type="text/javascript">
function showMyCoolTitle(title, length) {
if (length == null) { length = 0; }
if (length < title.length) {
if (length <= title.length) {
document.title = title.substr(0, length);
length++;
@ -66,7 +66,9 @@ function showMyCoolTitle(title, length) {
}
}
window.onload = function() { showMyCoolTitle("My cool website! Whoaaaaa!"); }
window.onload = function() {
showMyCoolTitle("My cool website! Whoaaaaa!");
}
</script>
```

View File

@ -2,7 +2,7 @@
# Follow along!
!SLIDE
# [johnbintz.github.com/tea-time](http://johnbintz.github.com/tea-time/)
## [johnbintz.github.com/tea-time](http://johnbintz.github.com/tea-time/)
!SLIDE
# No need to install anything right now

View File

@ -22,7 +22,7 @@ describe 'Cat', ->
!SLIDE image-80-percent
<img src="assets/cat-meow.jpg" />
!SLIDE even-larger
!SLIDE larger
``` coffeescript
describe 'Cat', ->
describe '#meow', ->

View File

@ -33,7 +33,7 @@ class this.Cat
meow: ->
```
!SLIDE even-larger
!SLIDE larger
``` javascript
// safety wrapper to prevent global pollution
(function() {

View File

@ -15,10 +15,12 @@
describe 'Cat', ->
describe '#meow', ->
describe 'hungry', ->
# Cat#meow expectation for when the cat is hungry
# Cat#meow expectation for when
# the cat is hungry
describe 'going to the vet', ->
# Cat#meow expectation for when the cat knows it's vet time
# Cat#meow expectation for when
# the cat knows it's vet time
```
!SLIDE larger
@ -28,14 +30,16 @@ describe 'Cat', ->
describe 'hungry', ->
it 'should be a mournful meow', ->
cat = new Cat()
cat.state = -> Cat.HUNGRY # ...just like cat.stubs(:state)
cat.state = -> Cat.HUNGRY
# ...just like cat.stubs(:state)
expect(cat.meow()).toEqual("meeeyaow")
describe 'going to the vet', ->
it 'should be an evil meow', ->
cat = new Cat()
cat.state = -> Cat.VET_PSYCHIC # ...just like the one above
cat.state = -> Cat.VET_PSYCHIC
# ...just like the one above
expect(cat.meow()).toEqual("raowwww")
```
@ -72,7 +76,7 @@ before do
@instance_variable = "yes"
end
it "should be in the same context as the before block" do
it "is in same context as before block" do
@instance_variable.should == "yes"
end
```

View File

@ -5,7 +5,8 @@
``` ruby
cat.meow.should == "meow"
cat.should be_a_kind_of(Cat)
cat.should_not be_hungry #=> cat.hungry?.should == false
cat.should_not be_hungry
# => cat.hungry?.should == false
```
!SLIDE even-larger

View File

@ -36,7 +36,7 @@ describe 'John', ->
!SLIDE image-80-percent
<img src="assets/beer-cat.jpg" />
!SLIDE even-larger
!SLIDE larger
``` gherkin
Feature: Cat Behaviors
Scenario: Hungry cats meow a particular way
@ -64,7 +64,7 @@ class this.Cat
Cat.HUNGRY
```
!SLIDE even-larger
!SLIDE larger
``` coffeescript
describe 'Cat', ->
describe '#meow', ->
@ -93,8 +93,9 @@ class this.Cat
!SLIDE larger
``` coffeescript
cat.foodLevel = 15 # do we care about food level in this test?
# all we care about is that the cat is hungry
cat.foodLevel = 15
# do we care about food level in this test?
# all we care about is that the cat is hungry
```
!SLIDE larger
@ -104,8 +105,9 @@ describe 'Cat', ->
describe 'hungry', ->
it 'should be a mournful meow', ->
cat = new Cat()
cat.state = -> Cat.HUNGRY # <= we don't care how state works,
# we just want a hungry cat
cat.state = -> Cat.HUNGRY
# ^^^ we don't care how state works,
# we just want a hungry cat
expect(cat.meow()).toEqual("meeeyaow")
```
@ -154,7 +156,7 @@ class this.Cat
this.modifyForGround(speech)
```
!SLIDE larger
!SLIDE
``` coffeescript
describe 'Cat#vocalProcessor', ->
speech = "speech"
@ -185,23 +187,23 @@ spyOn(@cat, 'modifyForAirborne')
!SLIDE
# Two basic ways to make sure a spy is called
!SLIDE even-larger
# `toHaveBeenCalledWith()`
## Called least once with the given parameters
!SLIDE
## `toHaveBeenCalledWith(args...)`
### Called least once with the given parameters
``` coffeescript
expect(@cat.modifyForAirborne).toHaveBeenCalledWith(speech)
```
!SLIDE even-larger
# `toHaveBeenCalled()`
# Just called, no parameter check
!SLIDE
## `toHaveBeenCalled()`
### Just called, no parameter check
``` coffeescript
expect(@cat.modifyForAirborne).toHaveBeenCalled()
```
!SLIDE even-larger
!SLIDE larger
# Instance Mocks/Spies in JavaScript
## Use `spyOn`/`toHaveBeenCalled` matchers
@ -218,7 +220,7 @@ expect(cat.state).toHaveBeenCalled()
!SLIDE
# `spyOn` works great with class-level stubs and mocks, too
!SLIDE even-larger
!SLIDE
``` coffeescript
class this.Cat
@generateFurColor: (base) ->
@ -229,13 +231,13 @@ class this.Cat
follicle.regrow(Cat.generateFurColor(this.baseColor))
```
!SLIDE even-larger
!SLIDE larger
``` coffeescript
Cat.generateFurColor = ->
"whoops i nuked this method for every other test"
```
!SLIDE larger
!SLIDE
``` coffeescript
describe 'Cat#regrowFur', ->
color = 'color'
@ -257,7 +259,7 @@ describe 'Cat#regrowFur', ->
expect(@follicle.regrow).toHaveBeenCalledWith(color)
```
!SLIDE even-larger
!SLIDE larger
# Class Stubs in JavaScript
## Use `spyOn` to generate stubs so that the original code is replaced after the test
@ -327,7 +329,7 @@ describe 'Cat#fetch', ->
!SLIDE
# Sometimes you just need a big blob of unit tests
!SLIDE even-larger
!SLIDE
``` coffeescript
# fast and focused!
@ -341,7 +343,7 @@ describe 'Cat#respondsTo', ->
expect(@cat.respondsTo(request)).toBeTruthy()
```
!SLIDE even-larger
!SLIDE larger
``` gherkin
# slow and synergistic!

View File

@ -2,7 +2,7 @@
# Using it in your project
!SLIDE
# [github.com/pivotal/jasmine-gem](http://github.com/pivotal/jasmine-gem)
## [github.com/pivotal/jasmine-gem](http://github.com/pivotal/jasmine-gem)
!SLIDE
# Starts a Rack server for running Jasmine against your code

View File

@ -7,13 +7,13 @@
!SLIDE
# Mocking and stubbing `$.fn` calls
!SLIDE larger
!SLIDE
``` coffeescript
this.containerWaiter = ->
$('#container').addClass('wait').append('<div class="waiting" />')
```
!SLIDE even-larger
!SLIDE
``` coffeescript
$.fn.makeWait = ->
$(this).addClass('wait').append('<div class="waiting" />')
@ -29,7 +29,7 @@ this.containerWaiter = ->
!SLIDE
# `jquery-jasmine`
!SLIDE even-larger
!SLIDE larger
``` coffeescript
describe 'container', ->
beforeEach ->
@ -148,38 +148,7 @@ _.mixin(CatLike)
_.catify("john") # => "meow meow john"
```
!SLIDE even-larger
``` coffeescript
CatLike =
catify: (name) -> "meow meow #{name}"
class Cat
hiss: -> "hiss"
# like Ruby include, add code to instances
for method, code of CatLike
Cat.prototype[method] = code
cat = new Cat()
cat.catify("john") # => "meow meow #{name}"
```
!SLIDE even-larger
``` coffeescript
CatLike =
catify: (name) -> "meow meow #{name}"
class Cat
hiss: -> "hiss"
# like Ruby extend, add code to class
for method, code of CatLike
Cat[method] = code
Cat.catify("john") # => "meow meow john"
```
!SLIDE even-larger
!SLIDE larger
``` coffeescript
describe '_.catify', ->
it 'should catify', ->
@ -189,7 +158,7 @@ describe '_.catify', ->
!SLIDE
# Eliminate the Underscore.js dependency
!SLIDE even-larger
!SLIDE
``` coffeescript
describe 'CatLike', ->
beforeEach ->

View File

@ -35,10 +35,10 @@ runs()
```
!SLIDE
# [Jasmine documentation](http://pivotal.github.com/jasmine/)
## [Jasmine documentation](http://pivotal.github.com/jasmine/)
!SLIDE
# [johnbintz.github.com/tea-time](http://johnbintz.github.com/tea-time/)
## [johnbintz.github.com/tea-time](http://johnbintz.github.com/tea-time/)
!SLIDE
# Any questions?