Skip to content

Instantly share code, notes, and snippets.

@juliocesar
Forked from suranyami/fails.coffee
Last active August 29, 2015 13:58

Revisions

  1. juliocesar revised this gist Apr 4, 2014. 1 changed file with 6 additions and 11 deletions.
    17 changes: 6 additions & 11 deletions fails.coffee
    Original file line number Diff line number Diff line change
    @@ -1,24 +1,19 @@
    describe "Asynchronous specs", ->
    funcRunInBackground = ->
    value = 1
    return
    wrapFuncRunInBackground = (done) ->

    wrapFuncRunInBackground = (done) ->
    # setup for simmulating the async operation, a function run in the background
    setTimeout (->
    setTimeout ->
    funcRunInBackground()
    done()
    return
    ), 3000
    return
    , 3000

    value = 0

    beforeEach (done) ->
    wrapFuncRunInBackground done
    console.log "wrap function returns immediately but value = 1 is set 3 seconds later. value is still " + value
    return

    it "should support async execution of test preparation", ->
    expect(value).toBeGreaterThan 0
    return

    return
    expect(value).toBeGreaterThan 0
  2. @suranyami suranyami created this gist Apr 4, 2014.
    24 changes: 24 additions & 0 deletions fails.coffee
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    describe "Asynchronous specs", ->
    funcRunInBackground = ->
    value = 1
    return
    wrapFuncRunInBackground = (done) ->

    # setup for simmulating the async operation, a function run in the background
    setTimeout (->
    funcRunInBackground()
    done()
    return
    ), 3000
    return
    value = 0
    beforeEach (done) ->
    wrapFuncRunInBackground done
    console.log "wrap function returns immediately but value = 1 is set 3 seconds later. value is still " + value
    return

    it "should support async execution of test preparation", ->
    expect(value).toBeGreaterThan 0
    return

    return
    25 changes: 25 additions & 0 deletions passes.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    describe("Asynchronous specs", function() {
    var value = 0;

    function funcRunInBackground() {
    value = 1;
    };

    function wrapFuncRunInBackground(done) {
    // setup for simmulating the async operation, a function run in the background
    setTimeout(function() {
    funcRunInBackground();
    done();
    }, 3000);
    }

    beforeEach(function(done) {
    wrapFuncRunInBackground(done);
    console.log("wrap function returns immediately but value = 1 is set 3 seconds later. value is still " + value);
    });


    it("should support async execution of test preparation", function() {
    expect(value).toBeGreaterThan(0);
    });
    });