Upgrade to Pro — share decks privately, control downloads, hide ads and more …

jasmine enhancers

jasmine enhancers

A summary of a bunch of my favorite Jasmine tools.

Interested in training? Contact us at http://test-double.com

Justin Searls

November 21, 2011
Tweet

More Decks by Justin Searls

Other Decks in Programming

Transcript

  1. jasmine
    enhancers

    View full-size slide

  2. http://test-double.com

    View full-size slide

  3. Global Day of
    CodeRetreat!
    Saturday 12/3, 8:30 am
    at EdgeCase
    http://is.gd/coderetreat

    View full-size slide

  4. describe "RSpec" do
    it "looks like Jasmine" do
    self.should be_familiar
    end
    end

    View full-size slide

  5. describe(“Jasmine”, function(){
    it(“looks like RSpec”, function(){
    expect(this).toBeFamiliar();
    });
    });
    It looks like you’re
    trying to write RSpec

    View full-size slide

  6. now you know Jasmine!

    View full-size slide

  7. a sandbox to play in
    http://is.gd/jasmine_crb

    View full-size slide

  8. www.tryjasmine.com
    Some examples: http://is.gd/scnajasmine

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  11. 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”

    View full-size slide

  12. When -> @config = createConfig()
    Then -> @config.url == "http://andy.vida"
    Then -> @config.name == "Matt Boston"
    Then -> @config.bestFriend == "Isaac Sanders"
    Then -> @config.bestBritishFriend == "Greg Malcolm"

    View full-size slide

  13. 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")

    View full-size slide

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

    View full-size slide

  15. $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")

    View full-size slide

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

    View full-size slide

  17. $foo = inject('foo')

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

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  20. 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]

    View full-size slide

  21. http://test-double.com

    View full-size slide