 
 
   describe 'Expectations should be nestable', ->
+    beforeEach ->
+      liar.expect
+        function_name: 'connect'
+        returns:
+          value: { status: 'open' }
+          on_value:
+            function_name: 'query'
+            returns:
+              value: '5 little pigs'
 
-    liar = createLiar [
-      function_name: 'connect'
-      returns:
-        value: { status: 'open' }
-        on_value: [
-          function_name: 'query'
-          returns:
-            value: '5 little pigs'
-        ]
-    ]
 
     it 'should be possible to call inner functions', ->
 

      connection.status.should.equal 'open'
      connection.query().should.equal '5 little pigs'

it 'should match to right lie if multiple per function', ->
  liar = createLiar [{
    function_name: 'add'
    arguments: [2, 3]
    returns:
      value: 5
  },{
    function_name: 'add'
    arguments: [5, 4]
    returns:
      value: 9
  }]
  liar.add(2,3).should.equal 5
  liar.add(5,4).should.equal 9




describe 'Syntax checking', ->

  it 'should validate that return has a value property', ->
    (->
      liar = createLiar [
        function_name: 'something'
        returns:
          values: 'somevalue' # <- spelled wrong, an "s" at the end!
      ]
      liar.something()

    ).should.throw 'returns object must have property "value" or "on_value"'

  it 'should validate function_name of root', ->
    (->
      liar = createLiar [
        function: 'do_stuff' # forgot _name
      ]
    ).should.throw 'expectation must have property "function_name"'

  it 'should validate that arguments is an array (root)', ->
    (->
      liar = createLiar [
        function_name: 'woop'
        arguments: 'hats' # forgot the array brackets
      ]
      liar.woop()
    ).should.throw 'arguments must be of type Array.'

  it 'should validate that function is string', ->
    (->
      myFunc = -> # just declare a random function
      liar = createLiar [
        function_name: myFunc
        returns: 9
      ]
    ).should.throw 'function_name must be a string.'

      liar.superFunction().should.equal liar

  describe 'When returns.self is false', ->
    beforeEach ->
      liar.expect
        function_name: 'superFunction'
        returns:
          self: false
