Skip to content

Latest commit

 

History

History
40 lines (30 loc) · 1.25 KB

valid-code.spec.coffee.md

File metadata and controls

40 lines (30 loc) · 1.25 KB

Test Pattern Code is Valid

RULE: The code inside the test pattern block should be valid. While the examples below are valid code, they will not pass lint validation.

The convention I use when writting literate CoffeeScript is that code colorized as CoffeeScript is the actual code used to implement this rule, while example code does not have syntax highlighting.

Examples

    ```CoffeeScript
    x = () -> return 1234 + 4567
    ```
    ```JavaScript
    var x = function () { return 1234 + 4567 }
    ```

This rule uses the isCodeValid and getCode functions from rule util.

    'use strict'
    util = require('../lib/rule.util')
    getCode = (lang) ->
        util.getCode "valid-code/#{lang}"

Define rule acceptance tests.

    describe 'the code block', ->
        it 'should contain valid code', ->
            #validate based on language
            block = getCode 'javascript'
            expect(util.isCodeValid(block)).toBe yes

            block = getCode 'coffeescript'
            expect(util.isCodeValid(block)).toBe yes