moonscript/spec
2016-09-25 17:52:05 -07:00
..
error_inputs error rewriting spec 2013-06-08 00:33:02 -07:00
inputs newlines can be used to separte function argument declarations 2016-09-25 17:52:05 -07:00
outputs newlines can be used to separte function argument declarations 2016-09-25 17:52:05 -07:00
class_spec.moon more spec 2015-12-06 12:03:19 -08:00
cmd_spec.moon parse spec 2016-04-16 23:58:36 -07:00
comprehension_spec.moon spec fixes for greater versions of lua 2015-12-06 18:09:04 -08:00
coverage_output_handler.moon add coverage handler spec 2016-09-25 11:25:38 -07:00
destructure_spec.moon destructure spec 2013-06-22 23:16:21 -07:00
error_rewriting_spec.moon update all specs to make sure they run with dev code 2015-09-26 19:31:01 -07:00
helpers.moon make error message from loader more useful 2016-04-13 19:47:37 -07:00
import_spec.moon import spec 2013-06-29 08:15:36 -07:00
lang_spec.moon make helper to make sure right moonscript code is tested, add to lang spec 2015-09-26 19:07:04 -07:00
loops_spec.moon continue spec 2013-06-30 21:47:45 -07:00
moon_spec.moon update all specs to make sure they run with dev code 2015-09-26 19:31:01 -07:00
moonscript_spec.moon update all specs to make sure they run with dev code 2015-09-26 19:31:01 -07:00
README.md update spec guide 2015-09-26 20:05:52 -07:00
transform_spec.moon add some specs for name extract 2015-09-30 01:06:22 -07:00

MoonScript spec guide

Because MoonScript is written in MoonScript, and MoonScript specs are written in MoonScript, you need to be aware of which copy of MoonScript is actually executing the specs.

A system installed version of MoonScript is recommended to run the specs (and for development). This means that you'll typically have two versions of MoonScript available in the load path:

  • The system version
  • The version in the current directory

A system install is recommended because you'll always want a functioning version of MoonScript to compile with in case you break your development version.

When developing you want to make ensure the tests are executing your changes in the current directory, and not testing the system install.

Code running in Busted will have the system install take precedence over the loaded version. That means that if you require "moonscript.base" for a test, you won't get the local copy.

The with_dev spec helper will ensure that any require calls within the spec that ask for MoonScript modules. with_dev calls a setup and teardown that replaces _G.require with a custom version.

You'll use it like this:

import with_dev from require "spec.helpers"
describe "moonscript.base", ->
  with_dev!

  it "should load code", ->
    -- the local version is loaded
    moonscript = require "moonscript"
    moonscript.load "print 12"

with_dev's require function will load the .lua files in the local directory, not the moon ones. You're responsible for compiling them first before running the tests.

You might do

$ make compile_system; busted

make compile_system is a makefile task included in the repo that will build MoonScript in the current directory with the version installed to the system