Move 19 / 22. From red to green in 105 seconds. Comments 0 comment(s). 1 modification(s). Kata Summary
========== AsyncSpec.coffee ========== = ========== AsyncSpec.coffee ==========
=
#============================================================================= = #=============================================================================
# Async spec, that will be time outed = # Async spec, that will be time outed
#============================================================================= = #=============================================================================
describe 'async', -> = describe 'async', ->
  it 'should be timed out', -> =   it 'should be timed out', ->
    waitsFor (-> false), 'MIRACLE', 500 =     waitsFor (-> false), 'MIRACLE', 500
=
=
=
  ========== CoffeeSpec.coffee ========== =   ========== CoffeeSpec.coffee ==========
=
  describe 'jasmine-node', -> =   describe 'jasmine-node', ->
=
    it 'should pass', -> =     it 'should pass', ->
      expect(1+2).toEqual(3) =       expect(1+2).toEqual(3)
=
=
    ========== GrammarHelper.coffee ========== =     ========== GrammarHelper.coffee ==========
=
    global.testClass = (description, specDefinitions) -> =     global.testClass = (description, specDefinitions) ->
      suite = jasmine.getEnv().describe('Class: ' + description, specDefinitions) =       suite = jasmine.getEnv().describe('Class: ' + description, specDefinitions)
      suite.tags = ['class'] =       suite.tags = ['class']
      suite.isIntermediate = true; =       suite.isIntermediate = true;
      suite =       suite
=
    global.feature = (description, specDefinitions) -> =     global.feature = (description, specDefinitions) ->
      suite = jasmine.getEnv().describe('Feature: ' + description, specDefinitions) =       suite = jasmine.getEnv().describe('Feature: ' + description, specDefinitions)
      suite.tags = ['feature'] =       suite.tags = ['feature']
      suite.isIntermediate = true; =       suite.isIntermediate = true;
      suite =       suite
=
    global.scenario = (desc, func) -> =     global.scenario = (desc, func) ->
      suite = jasmine.getEnv().describe('Scenario: ' + desc, func) =       suite = jasmine.getEnv().describe('Scenario: ' + desc, func)
      suite.tags = ['scenario'] =       suite.tags = ['scenario']
      suite.isIntermediate = true; =       suite.isIntermediate = true;
      suite =       suite
=
    global.should = (description, specDefinitions) -> =     global.should = (description, specDefinitions) ->
      suite = jasmine.getEnv().it('It should ' + description, specDefinitions) =       suite = jasmine.getEnv().it('It should ' + description, specDefinitions)
      suite.tags = ['should'] =       suite.tags = ['should']
      suite =       suite
=
=
    ========== HelperSpec.coffee ========== =     ========== HelperSpec.coffee ==========
=
=
    testClass 'HelperLoader', -> =     testClass 'HelperLoader', ->
      feature 'Loading order', -> =       feature 'Loading order', ->
        should 'load the helpers before the specs.', -> =         should 'load the helpers before the specs.', ->
          expect(true).toBeTruthy() =           expect(true).toBeTruthy()
          # will fail to parse the spec if the helper was not loaded first =           # will fail to parse the spec if the helper was not loaded first
=
=
        ========== dojoSpec.coffee ========== =         ========== dojoSpec.coffee ==========
=
        # This is a workaround to prevent jasmine-node from executing spec files in the .codersdojo directory =         # This is a workaround to prevent jasmine-node from executing spec files in the .codersdojo directory
        require '../kataSpec' =         require '../kataSpec'
=
=
=
        ========== kataSpec.coffee ========== =         ========== kataSpec.coffee ==========
=
        primenumbers = require './prime-numbers' =         primenumbers = require './prime-numbers'
=
        describe 'The Prime-numbers', -> =         describe 'The Prime-numbers', ->
          for n in [0..3] =           for n in [0..3]
            do (n) -> =             do (n) ->
              describe "of #{n}", -> =               describe "of #{n}", ->
                it "should be [#{n}]", -> =                 it "should be [#{n}]", ->
                  expect(primenumbers.prime(n)).toEqual([n]) =                   expect(primenumbers.prime(n)).toEqual([n])
=
                  for factors in [[2, 2], [2, 3]] =                   for factors in [[2, 2], [2, 3]]
                    do (factors) -> =                     do (factors) ->
                      number  = factors.fold (a, b) -> a * b |                       number  = factors.reduce (a, b) -> a * b
=
                      describe "of #{number}", -> =                       describe "of #{number}", ->
                        it "should be #{factors}", -> =                         it "should be #{factors}", ->
                          expect(primenumbers.prime(number)).toEqual factors =                           expect(primenumbers.prime(number)).toEqual factors
=
                          describe 'of 6', -> =                           describe 'of 6', ->
                            it 'should be [2, 3]', -> =                             it 'should be [2, 3]', ->
                              expect(primenumbers.prime(6)).toEqual [2, 3] =                               expect(primenumbers.prime(6)).toEqual [2, 3]
=
                              describe 'of 27', -> =                               describe 'of 27', ->
                                it 'should be [3, 3, 3]', -> =                                 it 'should be [3, 3, 3]', ->
                                  expect(primenumbers.prime(27)).toEqual [3, 3, 3] =                                   expect(primenumbers.prime(27)).toEqual [3, 3, 3]
=
=
                                ========== prime-numbers.coffee ========== =                                 ========== prime-numbers.coffee ==========
=
                                prime = (number) -> =                                 prime = (number) ->
                                  if number < 4 =                                   if number < 4
                                    [number] =                                     [number]
                                  else =                                   else
                                    collectPrimeFactors(number, 2, []) =                                     collectPrimeFactors(number, 2, [])
=
                                  collectPrimeFactors = (number, factor, foundPrimes) -> =                                   collectPrimeFactors = (number, factor, foundPrimes) ->
                                    if number == 1 =                                     if number == 1
                                      return foundPrimes =                                       return foundPrimes
                                    else if isPrimeFactorOf(factor, number) =                                     else if isPrimeFactorOf(factor, number)
                                      foundPrimes.push factor =                                       foundPrimes.push factor
                                      collectPrimeFactors(number / factor, factor, foundPrimes) =                                       collectPrimeFactors(number / factor, factor, foundPrimes)
                                    else =                                     else
                                      collectPrimeFactors(number, factor+1, foundPrimes) =                                       collectPrimeFactors(number, factor+1, foundPrimes)
=
                                    isPrimeFactorOf = (factor, number)-> =                                     isPrimeFactorOf = (factor, number)->
                                      number % factor == 0 =                                       number % factor == 0
=
=
                                    exports.prime = prime =                                     exports.prime = prime
=
=
                                    ========== specs.coffee ========== =                                     ========== specs.coffee ==========
=
                                    describe "prime factors", -> =                                     describe "prime factors", ->
                                      describe "of 0", -> =                                       describe "of 0", ->
                                        it "is 0", -> =                                         it "is 0", ->
                                          expect(primeFactors(0)).toEqual([0]) =                                           expect(primeFactors(0)).toEqual([0])
=
                                          describe "of 1", -> =                                           describe "of 1", ->
                                            it "is 1", -> =                                             it "is 1", ->
                                              expect(primeFactors(1)).toEqual([1]) =                                               expect(primeFactors(1)).toEqual([1])
=
                                              describe "of 2", -> =                                               describe "of 2", ->
                                                it "is 2", -> =                                                 it "is 2", ->
                                                  expect(primeFactors(2)).toEqual([2]) =                                                   expect(primeFactors(2)).toEqual([2])
=
                                                  describe "of 4", -> =                                                   describe "of 4", ->
                                                    it "are [2, 2]", -> =                                                     it "are [2, 2]", ->
                                                      expect(primeFactors(4)).toEqual([2, 2]) =                                                       expect(primeFactors(4)).toEqual([2, 2])
=
                                                      describe "of 6", -> =                                                       describe "of 6", ->
                                                        it "are [2, 3]", -> =                                                         it "are [2, 3]", ->
                                                          expect(primeFactors(6)).toEqual([2, 3]) =                                                           expect(primeFactors(6)).toEqual([2, 3])
=
                                                          describe "of 8", -> =                                                           describe "of 8", ->
                                                            it "are [2, 2, 2]", -> =                                                             it "are [2, 2, 2]", ->
                                                              expect(primeFactors(8)).toEqual([2, 2, 2]) =                                                               expect(primeFactors(8)).toEqual([2, 2, 2])
=
                                                              describe "of 10", -> =                                                               describe "of 10", ->
                                                                it "are [2, 5]", -> =                                                                 it "are [2, 5]", ->
                                                                  expect(primeFactors(10)).toEqual([2, 5]) =                                                                   expect(primeFactors(10)).toEqual([2, 5])
=
                                                                  describe "of 37", -> =                                                                   describe "of 37", ->
                                                                    it "are [37]", -> =                                                                     it "are [37]", ->
                                                                      expect(primeFactors(37)).toEqual([37]) =                                                                       expect(primeFactors(37)).toEqual([37])
=
                                                                    primeFactors = (number) -> =                                                                     primeFactors = (number) ->
                                                                      if number < 4 =                                                                       if number < 4
                                                                        [number] =                                                                         [number]
                                                                      else =                                                                       else
                                                                        findFactors(number, 2) =                                                                         findFactors(number, 2)
=
                                                                      findFactors = (number, nextFactor) -> =                                                                       findFactors = (number, nextFactor) ->
                                                                        if number == 1 =                                                                         if number == 1
                                                                          return [] =                                                                           return []
=
                                                                          if number % nextFactor == 0 =                                                                           if number % nextFactor == 0
                                                                            [nextFactor].concat findFactors(number / nextFactor, nextFactor) =                                                                             [nextFactor].concat findFactors(number / nextFactor, nextFactor)
                                                                          else =                                                                           else
                                                                            findFactors(number, nextFactor + 1) =                                                                             findFactors(number, nextFactor + 1)
....F

Failures:

  1) encountered a declaration exception
   Message:
     TypeError: Object 2,2 has no method 'fold'
   Stacktrace:
     TypeError: Object 2,2 has no method 'fold'
    at /home/andreas/academy/kataSpec.js:22:24
    at [object Object].<anonymous> (/home/andreas/academy/kataSpec.js:33:7)
    at [object Object].describe (/home/andreas/opt/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:791:21)
    at /home/andreas/opt/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:575:27
    at Object.<anonymous> (/home/andreas/academy/kataSpec.js:7:3)
    at Object.<anonymous> (/home/andreas/academy/kataSpec.js:47:4)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)

Finished in 0.009 seconds
5 tests, 5 assertions, 1 failure


........

Finished in 0.006 seconds
8 tests, 8 assertions, 0 failures