Skip to content

A wrapper that tweaks LuaUnit for a more pleasant test writing experience with Fennel.

License

Notifications You must be signed in to change notification settings

gbaptista/fspec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fspec

A wrapper that tweaks LuaUnit for a more pleasant test writing experience with Fennel.

fspec results example

Installing

To install through fnx, add to your .fnx.fnl:

:fspec {:fennel/fnx {:git/github "gbaptista/fspec"}}

; Example:

{:name    "my-project"
 :version "0.0.1"

 :dependencies {
   :fspec {:fennel/fnx {:git/github "gbaptista/fspec"}}}}

And install:

fnx dep install

Usage

Create a some_test.fnl file:

(local t (require :fspec))

(t.eq "actual" "expected")

(t.is-number "1.2")

(t.run!)

Run with:

fnx some_test.fnl

Run All

To run all _test.fnl tests, create a test.fnl file with:

(local t (require :fspec))

(t.run-all! "./")

And run:

fnx test.fnl

To use a different pattern, like _spec, use:

(t.run-all! "./" "_spec")

Verbose Stack Trace

To get a complete stack trace, use the --verbose option:

fnx test.fnl --verbose

Assertions

Check the dsl.fnl file for a list of all assertions available.

LuaUnit vs fspec

With LuaUnit you would write a test in Fennel like this:

(local luaunit (require :luaunit))

(fn testSomething []
  (luaunit.assertEquals
    {:title "actual" :value 17.89 }
    
    {:title "expected" :value 12.0
     :items [
       "a" "b" "c" "d" "e"
       "f" "g" "h" "i" "j"]}))

(os.exit (luaunit.LuaUnit.run))

Which would result in: LuaUnit results example

With fspec you would write the same test as:

(local t (require :fspec))

(t.eq
  {:title "actual" :value 17.89 }
  
  {:title "expected" :value 12.0
   :items [
     "a" "b" "c" "d" "e"
     "f" "g" "h" "i" "j"]})

(t.run!)

Which would result in:

fspec results example

About

A wrapper that tweaks LuaUnit for a more pleasant test writing experience with Fennel.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published