Move 6 / 22. From red to green in 146 seconds. Comments 0 comment(s). 7 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])
=
                  describe 'of 4', -> =                   describe 'of 4', ->
                    it 'should be [2, 2]', -> =                     it 'should be [2, 2]', ->
                      expect(primenumbers.prime(4)).toEqual [2, 2] =                       expect(primenumbers.prime(4)).toEqual [2, 2]
=
                      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]
=
=
                        ========== prime-numbers.coffee ========== =                         ========== prime-numbers.coffee ==========
=
                        prime = (number) -> =                         prime = (number) ->
                          if number < 4 =                           if number < 4
                            [number] =                             [number]
                          else =                           else
                            findPrime(number, 2, []) =                             findPrime(number, 2, [])
=
                          findPrime = (number, factor, foundPrimes) -> =                           findPrime = (number, factor, foundPrimes) ->
                            [2, 2] |                             if number == 1
|                               return foundPrimes
|                             else if number % factor == 0
                          exports.prime = prime |                               foundPrimes.push factor
|                               findPrime(number / factor, factor, foundPrimes)
|                             else
                          ========== specs.coffee ========== |                               findPrime(number, factor+1, foundPrimes)
|
                          describe "prime factors", -> |
                            describe "of 0", -> |                             exports.prime = prime
                              it "is 0", -> |
                                expect(primeFactors(0)).toEqual([0]) |
|                             ========== specs.coffee ==========
                                describe "of 1", -> |
                                  it "is 1", -> |                             describe "prime factors", ->
                                    expect(primeFactors(1)).toEqual([1]) |                               describe "of 0", ->
|                                 it "is 0", ->
                                    describe "of 2", -> |                                   expect(primeFactors(0)).toEqual([0])
                                      it "is 2", -> |
                                        expect(primeFactors(2)).toEqual([2]) |                                   describe "of 1", ->
|                                     it "is 1", ->
                                        describe "of 4", -> |                                       expect(primeFactors(1)).toEqual([1])
                                          it "are [2, 2]", -> |
                                            expect(primeFactors(4)).toEqual([2, 2]) |                                       describe "of 2", ->
|                                         it "is 2", ->
                                            describe "of 6", -> |                                           expect(primeFactors(2)).toEqual([2])
                                              it "are [2, 3]", -> |
                                                expect(primeFactors(6)).toEqual([2, 3]) |                                           describe "of 4", ->
|                                             it "are [2, 2]", ->
                                                describe "of 8", -> |                                               expect(primeFactors(4)).toEqual([2, 2])
                                                  it "are [2, 2, 2]", -> |
                                                    expect(primeFactors(8)).toEqual([2, 2, 2]) |                                               describe "of 6", ->
|                                                 it "are [2, 3]", ->
                                                    describe "of 10", -> |                                                   expect(primeFactors(6)).toEqual([2, 3])
                                                      it "are [2, 5]", -> |
                                                        expect(primeFactors(10)).toEqual([2, 5]) |                                                   describe "of 8", ->
|                                                     it "are [2, 2, 2]", ->
                                                        describe "of 37", -> |                                                       expect(primeFactors(8)).toEqual([2, 2, 2])
                                                          it "are [37]", -> |
                                                            expect(primeFactors(37)).toEqual([37]) |                                                       describe "of 10", ->
|                                                         it "are [2, 5]", ->
                                                          primeFactors = (number) -> |                                                           expect(primeFactors(10)).toEqual([2, 5])
                                                            if number < 4 |
                                                              [number] |                                                           describe "of 37", ->
                                                            else |                                                             it "are [37]", ->
                                                              findFactors(number, 2) |                                                               expect(primeFactors(37)).toEqual([37])
=
                                                            findFactors = (number, nextFactor) -> |                                                             primeFactors = (number) ->
                                                              if number == 1 |                                                               if number < 4
                                                                return [] |                                                                 [number]
<                                                               else
<                                                                 findFactors(number, 2)
=
                                                                if number % nextFactor == 0 |                                                               findFactors = (number, nextFactor) ->
                                                                  [nextFactor].concat findFactors(number / nextFactor, nextFactor) |                                                                 if number == 1
                                                                else |                                                                   return []
                                                                  findFactors(number, nextFactor + 1)
<                                                                   if number % nextFactor == 0
<                                                                     [nextFactor].concat findFactors(number / nextFactor, nextFactor)
<                                                                   else
<                                                                     findFactors(number, nextFactor + 1)
.....F

Failures:

  1) should be [2, 3]
   Message:
     Expected [ 2, 2 ] to equal [ 2, 3 ].
   Stacktrace:
     Error: Expected [ 2, 2 ] to equal [ 2, 3 ].
    at new <anonymous> (/home/andreas/opt/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:102:32)
    at [object Object].toEqual (/home/andreas/opt/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1171:29)
    at [object Object].<anonymous> (/home/andreas/academy/kataSpec.js:26:46)
    at [object Object].execute (/home/andreas/opt/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1001:15)
    at [object Object].next_ (/home/andreas/opt/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1790:31)
    at [object Object].start (/home/andreas/opt/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1743:8)
    at [object Object].execute (/home/andreas/opt/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:2070:14)
    at [object Object].next_ (/home/andreas/opt/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1790:31)
    at [object Object].start (/home/andreas/opt/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1743:8)
    at [object Object].execute (/home/andreas/opt/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:2215:14)

Finished in 0.007 seconds
6 tests, 6 assertions, 1 failure


......

Finished in 0.005 seconds
6 tests, 6 assertions, 0 failures