Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
jasmine enhancers
Slide 2
Slide 2 text
@searls
Slide 3
Slide 3 text
http://test-double.com
Slide 4
Slide 4 text
Global Day of CodeRetreat! Saturday 12/3, 8:30 am at EdgeCase http://is.gd/coderetreat
Slide 5
Slide 5 text
know RSpec?
Slide 6
Slide 6 text
describe "RSpec" do it "looks like Jasmine" do self.should be_familiar end end
Slide 7
Slide 7 text
describe(“Jasmine”, function(){ it(“looks like RSpec”, function(){ expect(this).toBeFamiliar(); }); }); It looks like you’re trying to write RSpec
Slide 8
Slide 8 text
now you know Jasmine!
Slide 9
Slide 9 text
a sandbox to play in http://is.gd/jasmine_crb
Slide 10
Slide 10 text
www.tryjasmine.com Some examples: http://is.gd/scnajasmine
Slide 11
Slide 11 text
No content
Slide 12
Slide 12 text
No content
Slide 13
Slide 13 text
No content
Slide 14
Slide 14 text
jasmine-headless-webkit http://johnbintz.github.com/jasmine-headless-webkit/
Slide 15
Slide 15 text
guard rocks
Slide 16
Slide 16 text
jasmine-given https://github.com/searls/jasmine-given
Slide 17
Slide 17 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”
Slide 18
Slide 18 text
When -> @config = createConfig() Then -> @config.url == "http://andy.vida" Then -> @config.name == "Matt Boston" Then -> @config.bestFriend == "Isaac Sanders" Then -> @config.bestBritishFriend == "Greg Malcolm"
Slide 19
Slide 19 text
describe "#createConfig", -> When -> @config = createConfig() Then( -> @config.url == "http://andy.vida") .Then( -> @config.name == "Matt Boston") .Then( -> @config.bestFriend == "Isaac Sanders") .Then( -> @config.bestBritishFriend == "Greg Malcolm")
Slide 20
Slide 20 text
jasmine-jquery https://github.com/velesin/jasmine-jquery
Slide 21
Slide 21 text
$button = $(‘.win’);
Winning
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 22
Slide 22 text
jasmine-fixture https://github.com/searls/jasmine-fixture
Slide 23
Slide 23 text
$foo = inject('foo')
$bar = $foo.inject('bar')
$input = $bar.inject(el: 'input', id: 'woot').val(42)
Slide 24
Slide 24 text
jasmine-stealth https://github.com/searls/jasmine-stealth
Slide 25
Slide 25 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 26
Slide 26 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 27
Slide 27 text
http://test-double.com