lookout 2.3.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/README +351 -181
 - data/Rakefile +20 -5
 - data/lib/lookout-3.0.rb +138 -0
 - data/lib/lookout-3.0/actual.rb +30 -0
 - data/lib/lookout-3.0/actual/method.rb +31 -0
 - data/lib/lookout-3.0/actual/not.rb +13 -0
 - data/lib/lookout-3.0/actual/not/method.rb +10 -0
 - data/lib/lookout-3.0/aphonic.rb +44 -0
 - data/lib/lookout-3.0/diff.rb +29 -0
 - data/lib/{lookout → lookout-3.0}/diff/algorithms.rb +1 -1
 - data/lib/lookout-3.0/diff/algorithms/difflib.rb +62 -0
 - data/lib/lookout-3.0/diff/algorithms/difflib/position.rb +63 -0
 - data/lib/{lookout/diff/algorithms/difflib/position/to.rb → lookout-3.0/diff/algorithms/difflib/position/new.rb} +8 -17
 - data/lib/lookout-3.0/diff/formats.rb +5 -0
 - data/lib/lookout-3.0/diff/formats/inline.rb +43 -0
 - data/lib/lookout-3.0/diff/formats/set.rb +48 -0
 - data/lib/lookout-3.0/diff/formats/unified.rb +56 -0
 - data/lib/lookout-3.0/diff/group.rb +57 -0
 - data/lib/lookout-3.0/diff/groups.rb +47 -0
 - data/lib/lookout-3.0/diff/match.rb +31 -0
 - data/lib/lookout-3.0/diff/operation.rb +41 -0
 - data/lib/lookout-3.0/diff/operations.rb +35 -0
 - data/lib/lookout-3.0/diff/operations/copy.rb +25 -0
 - data/lib/lookout-3.0/diff/operations/delete.rb +5 -0
 - data/lib/lookout-3.0/diff/operations/insert.rb +5 -0
 - data/lib/lookout-3.0/diff/operations/replace.rb +6 -0
 - data/lib/lookout-3.0/diff/slice.rb +97 -0
 - data/lib/lookout-3.0/difference.rb +10 -0
 - data/lib/lookout-3.0/difference/array.rb +22 -0
 - data/lib/lookout-3.0/difference/exception.rb +40 -0
 - data/lib/lookout-3.0/difference/hash.rb +31 -0
 - data/lib/lookout-3.0/difference/lookout.rb +5 -0
 - data/lib/lookout-3.0/difference/lookout/actual.rb +6 -0
 - data/lib/lookout-3.0/difference/lookout/actual/method.rb +13 -0
 - data/lib/lookout-3.0/difference/lookout/actual/not.rb +6 -0
 - data/lib/lookout-3.0/difference/lookout/actual/not/method.rb +9 -0
 - data/lib/lookout-3.0/difference/lookout/output.rb +8 -0
 - data/lib/lookout-3.0/difference/lookout/reception.rb +21 -0
 - data/lib/lookout-3.0/difference/lookout/warning.rb +9 -0
 - data/lib/lookout-3.0/difference/module.rb +12 -0
 - data/lib/lookout-3.0/difference/object.rb +73 -0
 - data/lib/lookout-3.0/difference/range.rb +12 -0
 - data/lib/lookout-3.0/difference/regexp.rb +12 -0
 - data/lib/lookout-3.0/difference/string.rb +21 -0
 - data/lib/lookout-3.0/difference/symbol.rb +21 -0
 - data/lib/lookout-3.0/encode.rb +20 -0
 - data/lib/lookout-3.0/exception.rb +79 -0
 - data/lib/lookout-3.0/exception/backtrace.rb +65 -0
 - data/lib/lookout-3.0/exception/unknown.rb +25 -0
 - data/lib/lookout-3.0/expect.rb +32 -0
 - data/lib/lookout-3.0/expect/classes.rb +6 -0
 - data/lib/lookout-3.0/expect/classes/exception.rb +27 -0
 - data/lib/lookout-3.0/expect/exception.rb +30 -0
 - data/lib/lookout-3.0/expect/object.rb +54 -0
 - data/lib/lookout-3.0/expect/object/context.rb +149 -0
 - data/lib/lookout-3.0/expectations.rb +69 -0
 - data/lib/lookout-3.0/expectations/context.rb +52 -0
 - data/lib/lookout-3.0/expected.rb +10 -0
 - data/lib/lookout-3.0/expected/array.rb +16 -0
 - data/lib/lookout-3.0/expected/classes.rb +5 -0
 - data/lib/lookout-3.0/expected/classes/exception.rb +14 -0
 - data/lib/lookout-3.0/expected/exception.rb +46 -0
 - data/lib/lookout-3.0/expected/falseclass.rb +9 -0
 - data/lib/lookout-3.0/expected/hash.rb +14 -0
 - data/lib/lookout-3.0/expected/lookout.rb +5 -0
 - data/lib/lookout-3.0/expected/lookout/actual.rb +5 -0
 - data/lib/lookout-3.0/expected/lookout/actual/method.rb +13 -0
 - data/lib/lookout-3.0/expected/lookout/actual/not.rb +6 -0
 - data/lib/lookout-3.0/expected/lookout/actual/not/method.rb +13 -0
 - data/lib/lookout-3.0/expected/lookout/output.rb +26 -0
 - data/lib/lookout-3.0/expected/lookout/reception.rb +24 -0
 - data/lib/lookout-3.0/expected/lookout/warning.rb +29 -0
 - data/lib/lookout-3.0/expected/module.rb +12 -0
 - data/lib/lookout-3.0/expected/object.rb +30 -0
 - data/lib/lookout-3.0/expected/range.rb +12 -0
 - data/lib/lookout-3.0/expected/regexp.rb +12 -0
 - data/lib/lookout-3.0/expected/string.rb +11 -0
 - data/lib/lookout-3.0/expected/symbol.rb +21 -0
 - data/lib/lookout-3.0/expected/trueclass.rb +9 -0
 - data/lib/lookout-3.0/inspect.rb +45 -0
 - data/lib/lookout-3.0/interfaces.rb +5 -0
 - data/lib/lookout-3.0/interfaces/commandline.rb +109 -0
 - data/lib/lookout-3.0/literal.rb +18 -0
 - data/lib/lookout-3.0/mock.rb +24 -0
 - data/lib/lookout-3.0/object.rb +6 -0
 - data/lib/lookout-3.0/object/not.rb +16 -0
 - data/lib/lookout-3.0/object/not/receive.rb +18 -0
 - data/lib/lookout-3.0/object/to.rb +12 -0
 - data/lib/lookout-3.0/object/to/receive.rb +18 -0
 - data/lib/lookout-3.0/output.rb +20 -0
 - data/lib/lookout-3.0/plugins.rb +7 -0
 - data/lib/lookout-3.0/reception.rb +128 -0
 - data/lib/lookout-3.0/reception/arguments.rb +20 -0
 - data/lib/lookout-3.0/reception/arguments/any.rb +16 -0
 - data/lib/lookout-3.0/reception/arguments/error.rb +5 -0
 - data/lib/lookout-3.0/reception/arguments/list.rb +17 -0
 - data/lib/lookout-3.0/reception/arguments/none.rb +6 -0
 - data/lib/lookout-3.0/reception/error.rb +24 -0
 - data/lib/lookout-3.0/result.rb +16 -0
 - data/lib/lookout-3.0/results.rb +5 -0
 - data/lib/lookout-3.0/results/error.rb +18 -0
 - data/lib/lookout-3.0/results/failure.rb +15 -0
 - data/lib/lookout-3.0/results/success.rb +7 -0
 - data/lib/lookout-3.0/stub.rb +55 -0
 - data/lib/lookout-3.0/version.rb +133 -0
 - data/lib/lookout-3.0/warning.rb +40 -0
 - data/test/unit/examples.rb +208 -83
 - data/test/unit/{lookout.rb → lookout-3.0.rb} +0 -0
 - data/test/unit/lookout-3.0/actual.rb +13 -0
 - data/test/unit/lookout-3.0/actual/method.rb +31 -0
 - data/test/unit/lookout-3.0/actual/not.rb +15 -0
 - data/test/unit/lookout-3.0/actual/not/method.rb +7 -0
 - data/test/unit/lookout-3.0/aphonic.rb +31 -0
 - data/test/unit/{lookout → lookout-3.0}/diff.rb +0 -0
 - data/test/unit/{lookout/diff/group.rb → lookout-3.0/diff/algorithms.rb} +0 -0
 - data/test/unit/lookout-3.0/diff/algorithms/difflib.rb +56 -0
 - data/test/unit/lookout-3.0/diff/algorithms/difflib/position.rb +92 -0
 - data/test/unit/{lookout/diff/algorithms/difflib/position/to.rb → lookout-3.0/diff/algorithms/difflib/position/new.rb} +1 -2
 - data/test/unit/{lookout/results.rb → lookout-3.0/diff/formats.rb} +0 -0
 - data/test/unit/{lookout → lookout-3.0}/diff/formats/inline.rb +0 -0
 - data/test/unit/lookout-3.0/diff/formats/set.rb +26 -0
 - data/test/unit/{lookout → lookout-3.0}/diff/formats/unified.rb +0 -0
 - data/test/unit/{lookout/results/error.rb → lookout-3.0/diff/group.rb} +0 -0
 - data/test/unit/lookout-3.0/diff/groups.rb +102 -0
 - data/test/unit/{lookout → lookout-3.0}/diff/match.rb +0 -0
 - data/test/unit/lookout-3.0/diff/operation.rb +17 -0
 - data/test/unit/lookout-3.0/diff/operations.rb +22 -0
 - data/test/unit/lookout-3.0/diff/operations/copy.rb +50 -0
 - data/test/unit/lookout-3.0/diff/operations/delete.rb +45 -0
 - data/test/unit/lookout-3.0/diff/operations/insert.rb +45 -0
 - data/test/unit/lookout-3.0/diff/operations/replace.rb +45 -0
 - data/test/unit/lookout-3.0/diff/slice.rb +56 -0
 - data/test/unit/{lookout/results/failures/behavior.rb → lookout-3.0/difference.rb} +0 -0
 - data/test/unit/lookout-3.0/difference/array.rb +32 -0
 - data/test/unit/lookout-3.0/difference/exception.rb +69 -0
 - data/test/unit/lookout-3.0/difference/hash.rb +30 -0
 - data/test/unit/{lookout/results/failures/state.rb → lookout-3.0/difference/lookout.rb} +0 -0
 - data/test/unit/{lookout/results/fulfilled.rb → lookout-3.0/difference/lookout/actual.rb} +0 -0
 - data/test/unit/lookout-3.0/difference/lookout/actual/method.rb +7 -0
 - data/test/unit/{lookout/runners/console.rb → lookout-3.0/difference/lookout/actual/not.rb} +0 -0
 - data/test/unit/lookout-3.0/difference/lookout/actual/not/method.rb +7 -0
 - data/test/unit/lookout-3.0/difference/lookout/output.rb +11 -0
 - data/test/unit/lookout-3.0/difference/lookout/reception.rb +11 -0
 - data/test/unit/lookout-3.0/difference/lookout/warning.rb +11 -0
 - data/test/unit/lookout-3.0/difference/module.rb +11 -0
 - data/test/unit/lookout-3.0/difference/object.rb +31 -0
 - data/test/unit/lookout-3.0/difference/range.rb +11 -0
 - data/test/unit/lookout-3.0/difference/regexp.rb +11 -0
 - data/test/unit/lookout-3.0/difference/string.rb +29 -0
 - data/test/unit/lookout-3.0/difference/symbol.rb +11 -0
 - data/test/unit/lookout-3.0/encode.rb +28 -0
 - data/test/unit/lookout-3.0/exception.rb +107 -0
 - data/test/unit/lookout-3.0/exception/backtrace.rb +75 -0
 - data/test/unit/lookout-3.0/exception/unknown.rb +23 -0
 - data/test/unit/lookout-3.0/expect.rb +15 -0
 - data/test/unit/{lookout/ui/console.rb → lookout-3.0/expect/classes.rb} +0 -0
 - data/test/unit/lookout-3.0/expect/classes/exception.rb +41 -0
 - data/test/unit/lookout-3.0/expect/exception.rb +63 -0
 - data/test/unit/lookout-3.0/expect/object.rb +55 -0
 - data/test/unit/lookout-3.0/expect/object/context.rb +120 -0
 - data/test/unit/lookout-3.0/expectations.rb +55 -0
 - data/test/unit/lookout-3.0/expectations/context.rb +44 -0
 - data/test/unit/lookout-3.0/expected.rb +4 -0
 - data/test/unit/lookout-3.0/expected/array.rb +19 -0
 - data/test/unit/lookout-3.0/expected/classes.rb +4 -0
 - data/test/unit/lookout-3.0/expected/classes/exception.rb +7 -0
 - data/test/unit/lookout-3.0/expected/exception.rb +24 -0
 - data/test/unit/lookout-3.0/expected/falseclass.rb +23 -0
 - data/test/unit/lookout-3.0/expected/hash.rb +23 -0
 - data/test/unit/lookout-3.0/expected/lookout.rb +4 -0
 - data/test/unit/lookout-3.0/expected/lookout/actual.rb +4 -0
 - data/test/unit/lookout-3.0/expected/lookout/actual/method.rb +11 -0
 - data/test/unit/lookout-3.0/expected/lookout/actual/not.rb +4 -0
 - data/test/unit/lookout-3.0/expected/lookout/actual/not/method.rb +11 -0
 - data/test/unit/lookout-3.0/expected/lookout/output.rb +27 -0
 - data/test/unit/lookout-3.0/expected/lookout/reception.rb +25 -0
 - data/test/unit/lookout-3.0/expected/lookout/warning.rb +48 -0
 - data/test/unit/lookout-3.0/expected/module.rb +23 -0
 - data/test/unit/lookout-3.0/expected/object.rb +24 -0
 - data/test/unit/lookout-3.0/expected/range.rb +19 -0
 - data/test/unit/lookout-3.0/expected/regexp.rb +19 -0
 - data/test/unit/lookout-3.0/expected/string.rb +44 -0
 - data/test/unit/lookout-3.0/expected/symbol.rb +35 -0
 - data/test/unit/lookout-3.0/expected/trueclass.rb +23 -0
 - data/test/unit/lookout-3.0/inspect.rb +39 -0
 - data/test/unit/lookout-3.0/interfaces.rb +4 -0
 - data/test/unit/lookout-3.0/interfaces/commandline.rb +4 -0
 - data/test/unit/lookout-3.0/literal.rb +15 -0
 - data/test/unit/lookout-3.0/mock.rb +22 -0
 - data/test/unit/lookout-3.0/object.rb +4 -0
 - data/test/unit/lookout-3.0/object/not.rb +7 -0
 - data/test/unit/lookout-3.0/object/not/receive.rb +9 -0
 - data/test/unit/lookout-3.0/object/to.rb +7 -0
 - data/test/unit/lookout-3.0/object/to/receive.rb +9 -0
 - data/test/unit/lookout-3.0/output.rb +31 -0
 - data/test/unit/lookout-3.0/plugins.rb +4 -0
 - data/test/unit/lookout-3.0/reception.rb +86 -0
 - data/test/unit/lookout-3.0/reception/arguments.rb +23 -0
 - data/test/unit/lookout-3.0/reception/arguments/any.rb +15 -0
 - data/test/unit/lookout-3.0/reception/arguments/error.rb +4 -0
 - data/test/unit/lookout-3.0/reception/arguments/list.rb +19 -0
 - data/test/unit/lookout-3.0/reception/arguments/none.rb +15 -0
 - data/test/unit/lookout-3.0/reception/error.rb +4 -0
 - data/test/unit/lookout-3.0/result.rb +27 -0
 - data/test/unit/lookout-3.0/results.rb +4 -0
 - data/test/unit/lookout-3.0/results/error.rb +37 -0
 - data/test/unit/lookout-3.0/results/failure.rb +21 -0
 - data/test/unit/lookout-3.0/results/success.rb +4 -0
 - data/test/unit/lookout-3.0/stub.rb +53 -0
 - data/test/unit/lookout-3.0/version.rb +4 -0
 - data/test/unit/lookout-3.0/warning.rb +47 -0
 - metadata +1159 -456
 - data/lib/lookout.rb +0 -30
 - data/lib/lookout/aphonic.rb +0 -40
 - data/lib/lookout/diff.rb +0 -10
 - data/lib/lookout/diff/algorithms/difflib.rb +0 -38
 - data/lib/lookout/diff/algorithms/difflib/position.rb +0 -92
 - data/lib/lookout/diff/formats.rb +0 -7
 - data/lib/lookout/diff/formats/hash.rb +0 -53
 - data/lib/lookout/diff/formats/inline.rb +0 -39
 - data/lib/lookout/diff/formats/unified.rb +0 -57
 - data/lib/lookout/diff/group.rb +0 -61
 - data/lib/lookout/diff/groups.rb +0 -34
 - data/lib/lookout/diff/match.rb +0 -36
 - data/lib/lookout/diff/operation.rb +0 -33
 - data/lib/lookout/diff/operations.rb +0 -36
 - data/lib/lookout/diff/operations/delete.rb +0 -9
 - data/lib/lookout/diff/operations/equal.rb +0 -27
 - data/lib/lookout/diff/operations/insert.rb +0 -9
 - data/lib/lookout/diff/operations/replace.rb +0 -9
 - data/lib/lookout/diff/range.rb +0 -91
 - data/lib/lookout/equalities.rb +0 -13
 - data/lib/lookout/equalities/array.rb +0 -22
 - data/lib/lookout/equalities/boolean.rb +0 -9
 - data/lib/lookout/equalities/hash.rb +0 -25
 - data/lib/lookout/equalities/include.rb +0 -9
 - data/lib/lookout/equalities/object.rb +0 -24
 - data/lib/lookout/equalities/output.rb +0 -19
 - data/lib/lookout/equalities/standarderror.rb +0 -32
 - data/lib/lookout/equalities/string.rb +0 -19
 - data/lib/lookout/equalities/warning.rb +0 -16
 - data/lib/lookout/equality.rb +0 -36
 - data/lib/lookout/expectation.rb +0 -69
 - data/lib/lookout/expectations.rb +0 -49
 - data/lib/lookout/expectations/behavior.rb +0 -20
 - data/lib/lookout/expectations/line.rb +0 -29
 - data/lib/lookout/expectations/state.rb +0 -31
 - data/lib/lookout/expectations/state/warning.rb +0 -26
 - data/lib/lookout/mock.rb +0 -20
 - data/lib/lookout/mock/method.rb +0 -70
 - data/lib/lookout/mock/method/arguments.rb +0 -33
 - data/lib/lookout/mock/method/arguments/any.rb +0 -11
 - data/lib/lookout/mock/method/arguments/anything.rb +0 -11
 - data/lib/lookout/mock/method/arguments/list.rb +0 -15
 - data/lib/lookout/mock/method/arguments/none.rb +0 -11
 - data/lib/lookout/mock/method/arguments/one.rb +0 -11
 - data/lib/lookout/mock/method/calls.rb +0 -11
 - data/lib/lookout/mock/method/calls/class.rb +0 -21
 - data/lib/lookout/mock/method/calls/exactly.rb +0 -28
 - data/lib/lookout/mock/method/calls/instance.rb +0 -25
 - data/lib/lookout/mock/method/calls/lower.rb +0 -22
 - data/lib/lookout/mock/method/calls/upper.rb +0 -22
 - data/lib/lookout/mock/methods.rb +0 -12
 - data/lib/lookout/mock/object.rb +0 -12
 - data/lib/lookout/object.rb +0 -11
 - data/lib/lookout/output.rb +0 -21
 - data/lib/lookout/rake/tasks.rb +0 -36
 - data/lib/lookout/rake/tasks/gem.rb +0 -49
 - data/lib/lookout/rake/tasks/tags.rb +0 -16
 - data/lib/lookout/rake/tasks/test.rb +0 -46
 - data/lib/lookout/rake/tasks/test/loader.rb +0 -22
 - data/lib/lookout/recorder.rb +0 -45
 - data/lib/lookout/recorder/not.rb +0 -11
 - data/lib/lookout/recorder/tape.rb +0 -21
 - data/lib/lookout/recorders.rb +0 -6
 - data/lib/lookout/recorders/reception.rb +0 -47
 - data/lib/lookout/recorders/state.rb +0 -35
 - data/lib/lookout/result.rb +0 -13
 - data/lib/lookout/results.rb +0 -25
 - data/lib/lookout/results/error.rb +0 -18
 - data/lib/lookout/results/error/exception.rb +0 -34
 - data/lib/lookout/results/error/exception/backtrace.rb +0 -50
 - data/lib/lookout/results/failure.rb +0 -16
 - data/lib/lookout/results/failures.rb +0 -6
 - data/lib/lookout/results/failures/behavior.rb +0 -5
 - data/lib/lookout/results/failures/state.rb +0 -5
 - data/lib/lookout/results/fulfilled.rb +0 -5
 - data/lib/lookout/results/unsuccessful.rb +0 -31
 - data/lib/lookout/runners.rb +0 -6
 - data/lib/lookout/runners/console.rb +0 -49
 - data/lib/lookout/runners/trackers.rb +0 -5
 - data/lib/lookout/runners/trackers/failure.rb +0 -14
 - data/lib/lookout/stub.rb +0 -18
 - data/lib/lookout/stub/method.rb +0 -105
 - data/lib/lookout/stub/methods.rb +0 -18
 - data/lib/lookout/stub/object.rb +0 -11
 - data/lib/lookout/ui.rb +0 -7
 - data/lib/lookout/ui/console.rb +0 -19
 - data/lib/lookout/ui/silent.rb +0 -9
 - data/lib/lookout/version.rb +0 -5
 - data/lib/lookout/warning.rb +0 -7
 - data/lib/lookout/xml.rb +0 -17
 - data/test/unit/lookout/diff/algorithms/difflib.rb +0 -56
 - data/test/unit/lookout/diff/algorithms/difflib/position.rb +0 -92
 - data/test/unit/lookout/diff/groups.rb +0 -102
 - data/test/unit/lookout/diff/operations.rb +0 -22
 - data/test/unit/lookout/diff/operations/delete.rb +0 -45
 - data/test/unit/lookout/diff/operations/equal.rb +0 -45
 - data/test/unit/lookout/diff/operations/insert.rb +0 -45
 - data/test/unit/lookout/diff/operations/replace.rb +0 -45
 - data/test/unit/lookout/diff/range.rb +0 -50
 - data/test/unit/lookout/equality.rb +0 -113
 - data/test/unit/lookout/expectation.rb +0 -47
 - data/test/unit/lookout/expectations.rb +0 -36
 - data/test/unit/lookout/expectations/behavior.rb +0 -35
 - data/test/unit/lookout/expectations/line.rb +0 -29
 - data/test/unit/lookout/expectations/state.rb +0 -29
 - data/test/unit/lookout/mock/method.rb +0 -143
 - data/test/unit/lookout/mock/method/arguments.rb +0 -57
 - data/test/unit/lookout/mock/method/arguments/any.rb +0 -11
 - data/test/unit/lookout/recorder.rb +0 -11
 - data/test/unit/lookout/results/error/exception/backtrace.rb +0 -20
 - data/test/unit/lookout/results/unsuccessful.rb +0 -9
 - data/test/unit/lookout/runners/trackers/failure.rb +0 -30
 - data/test/unit/lookout/stub/method.rb +0 -48
 - data/test/unit/lookout/stub/methods.rb +0 -19
 - data/test/unit/lookout/xml.rb +0 -55
 
| 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Arguments that should be passed to a method reception expectation.  Sets
         
     | 
| 
      
 4 
     | 
    
         
            +
            # things up based on what kind of arguments were passed to it and may then be
         
     | 
| 
      
 5 
     | 
    
         
            +
            # used to {List#=~ verify} that arguments that don’t {Lookout::Difference
         
     | 
| 
      
 6 
     | 
    
         
            +
            # differ} from them are subsequently passed to the method.
         
     | 
| 
      
 7 
     | 
    
         
            +
            module Lookout::Reception::Arguments
         
     | 
| 
      
 8 
     | 
    
         
            +
              class << self
         
     | 
| 
      
 9 
     | 
    
         
            +
                # @param [Object, …] args
         
     | 
| 
      
 10 
     | 
    
         
            +
                # @return [Any, List, None] {Any} if ARGS is #empty?, {Any} or {None} if
         
     | 
| 
      
 11 
     | 
    
         
            +
                #   ARGS contain either, or a {List} wrapping ARGS
         
     | 
| 
      
 12 
     | 
    
         
            +
                def for(*args)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  if args.empty? then Any.new
         
     | 
| 
      
 14 
     | 
    
         
            +
                  elsif any = args.find{ |e| Any === e } then any
         
     | 
| 
      
 15 
     | 
    
         
            +
                  elsif none = args.find{ |e| None === e } then none
         
     | 
| 
      
 16 
     | 
    
         
            +
                  else List.new(*args)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,16 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Arguments matcher matching any arguments.
         
     | 
| 
      
 4 
     | 
    
         
            +
            class Lookout::Reception::Arguments::Any
         
     | 
| 
      
 5 
     | 
    
         
            +
              # @param [Array<Object>] other
         
     | 
| 
      
 6 
     | 
    
         
            +
              # @return [true]
         
     | 
| 
      
 7 
     | 
    
         
            +
              def =~(other) true end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              # @return True if the receiver’s class `#==` that of OTHER
         
     | 
| 
      
 10 
     | 
    
         
            +
              def ==(other) self.class == other.class end
         
     | 
| 
      
 11 
     | 
    
         
            +
              alias eql? ==
         
     | 
| 
      
 12 
     | 
    
         
            +
              def hash; self.class.hash end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              # @return The receiver as a String argument list
         
     | 
| 
      
 15 
     | 
    
         
            +
              def to_s; '*args, &block' end
         
     | 
| 
      
 16 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Arguments matcher matching a list of arguments.  It uses
         
     | 
| 
      
 4 
     | 
    
         
            +
            # {Lookout::Difference} to do the actual work.
         
     | 
| 
      
 5 
     | 
    
         
            +
            class Lookout::Reception::Arguments::List
         
     | 
| 
      
 6 
     | 
    
         
            +
              # Expects ARGS.
         
     | 
| 
      
 7 
     | 
    
         
            +
              # @param [Object, …] args
         
     | 
| 
      
 8 
     | 
    
         
            +
              Value(:'*args')
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              # @param [Array<Object>] other
         
     | 
| 
      
 11 
     | 
    
         
            +
              # @return True if there are no {Expected::Object#difference
         
     | 
| 
      
 12 
     | 
    
         
            +
              #   differences} between the expected arguments and OTHER
         
     | 
| 
      
 13 
     | 
    
         
            +
              def =~(other) not args.to_lookout_expected.difference(other) end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              # @return The receiver as a String argument list
         
     | 
| 
      
 16 
     | 
    
         
            +
              def to_s; Lookout::Inspect.args(*args) end
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,24 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Error raised when a method is received too many times.
         
     | 
| 
      
 4 
     | 
    
         
            +
            class Lookout::Reception::Error < StandardError
         
     | 
| 
      
 5 
     | 
    
         
            +
              class << self
         
     | 
| 
      
 6 
     | 
    
         
            +
                # @param [Reception] reception
         
     | 
| 
      
 7 
     | 
    
         
            +
                # @param [Integer] calls
         
     | 
| 
      
 8 
     | 
    
         
            +
                # @return [Error] A new error with a suitable error message for the
         
     | 
| 
      
 9 
     | 
    
         
            +
                #   RECEPTION of a method, where CALLS is outside the RANGE of expected
         
     | 
| 
      
 10 
     | 
    
         
            +
                #   calls.
         
     | 
| 
      
 11 
     | 
    
         
            +
                def from(reception, calls, range)
         
     | 
| 
      
 12 
     | 
    
         
            +
                  new('%s: unexpected number of invocations (%d for %s)' %
         
     | 
| 
      
 13 
     | 
    
         
            +
                      [reception,
         
     | 
| 
      
 14 
     | 
    
         
            +
                       calls,
         
     | 
| 
      
 15 
     | 
    
         
            +
                       if range.begin == range.end
         
     | 
| 
      
 16 
     | 
    
         
            +
                         range.begin
         
     | 
| 
      
 17 
     | 
    
         
            +
                       elsif range.end == 1.0/0
         
     | 
| 
      
 18 
     | 
    
         
            +
                         '%d..' % range.begin
         
     | 
| 
      
 19 
     | 
    
         
            +
                       else
         
     | 
| 
      
 20 
     | 
    
         
            +
                         range
         
     | 
| 
      
 21 
     | 
    
         
            +
                       end])
         
     | 
| 
      
 22 
     | 
    
         
            +
                end
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,16 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Base module for {Results}.
         
     | 
| 
      
 4 
     | 
    
         
            +
            module Lookout::Result
         
     | 
| 
      
 5 
     | 
    
         
            +
              # Initializes the result pertaining to the expect block defined on LINE in
         
     | 
| 
      
 6 
     | 
    
         
            +
              # the expanded path to FILE.
         
     | 
| 
      
 7 
     | 
    
         
            +
              # @param [String] file The expanded path of the file containing the expect
         
     | 
| 
      
 8 
     | 
    
         
            +
              #   block that this result pertains to
         
     | 
| 
      
 9 
     | 
    
         
            +
              # @param [Integer] line The line in FILE on which the expectation that this
         
     | 
| 
      
 10 
     | 
    
         
            +
              #   result pertains to is defined
         
     | 
| 
      
 11 
     | 
    
         
            +
              Value(:file, :line, :comparable => true)
         
     | 
| 
      
 12 
     | 
    
         
            +
              public :file, :line
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              # @return A String formatted according to the GNU standard for error messages
         
     | 
| 
      
 15 
     | 
    
         
            +
              def to_s; '%s:%d' % [file, line] end
         
     | 
| 
      
 16 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # An error result used when the evalution of an {Expect expect block} failed.
         
     | 
| 
      
 4 
     | 
    
         
            +
            class Lookout::Results::Error
         
     | 
| 
      
 5 
     | 
    
         
            +
              include Lookout::Result
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              # (see Result#initialize)
         
     | 
| 
      
 8 
     | 
    
         
            +
              # An additional MESSAGE may also be associated with the result, which was
         
     | 
| 
      
 9 
     | 
    
         
            +
              # caused by EXCEPTION.
         
     | 
| 
      
 10 
     | 
    
         
            +
              # @param (see Result#initialize)
         
     | 
| 
      
 11 
     | 
    
         
            +
              # @param [String, nil] message Any additional message associated with this
         
     | 
| 
      
 12 
     | 
    
         
            +
              #   error
         
     | 
| 
      
 13 
     | 
    
         
            +
              # @param [Exception] exception The raised exception
         
     | 
| 
      
 14 
     | 
    
         
            +
              Value(:file, :line, :message, :exception, :comparable => [:file, :line])
         
     | 
| 
      
 15 
     | 
    
         
            +
              public :message, :exception
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              def to_s; [super, message, exception.format].compact.join(': ') end
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # A failed result used when the actual result of an expect block exhibits
         
     | 
| 
      
 4 
     | 
    
         
            +
            # differences from the expected value.
         
     | 
| 
      
 5 
     | 
    
         
            +
            class Lookout::Results::Failure
         
     | 
| 
      
 6 
     | 
    
         
            +
              include Lookout::Result
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              # (see Result#initialize)
         
     | 
| 
      
 9 
     | 
    
         
            +
              # The DIFFERENCE report between the actual result and the expected value
         
     | 
| 
      
 10 
     | 
    
         
            +
              # will be used to display this information to the user.
         
     | 
| 
      
 11 
     | 
    
         
            +
              # @param [Difference::Object] difference
         
     | 
| 
      
 12 
     | 
    
         
            +
              Value(:file, :line, :difference, :comparable => [:file, :line])
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              def to_s; [super, difference].join(': ') end
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,55 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Object that only responds to a given set of methods and returns itself
         
     | 
| 
      
 4 
     | 
    
         
            +
            # whenever it receives a method call it doesn’t know anything about.
         
     | 
| 
      
 5 
     | 
    
         
            +
            class Lookout::Stub
         
     | 
| 
      
 6 
     | 
    
         
            +
              class << self
         
     | 
| 
      
 7 
     | 
    
         
            +
                # Defines METHOD on an objects META object to VALUE.  If _value_ is a Proc
         
     | 
| 
      
 8 
     | 
    
         
            +
                # it’ll be used as a method definition with rules that depend on if whether
         
     | 
| 
      
 9 
     | 
    
         
            +
                # it’s a lambda or not.  Otherwise, the method definition will be set up to
         
     | 
| 
      
 10 
     | 
    
         
            +
                # return VALUE.
         
     | 
| 
      
 11 
     | 
    
         
            +
                # @param [Object] meta
         
     | 
| 
      
 12 
     | 
    
         
            +
                # @param [Symbol] method
         
     | 
| 
      
 13 
     | 
    
         
            +
                # @param [Object] value
         
     | 
| 
      
 14 
     | 
    
         
            +
                def define(meta, method, value)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  meta.instance_eval{
         
     | 
| 
      
 16 
     | 
    
         
            +
                    case value
         
     | 
| 
      
 17 
     | 
    
         
            +
                    when Proc
         
     | 
| 
      
 18 
     | 
    
         
            +
                      if (value.lambda? rescue false)
         
     | 
| 
      
 19 
     | 
    
         
            +
                        define_method method, value
         
     | 
| 
      
 20 
     | 
    
         
            +
                      else
         
     | 
| 
      
 21 
     | 
    
         
            +
                        define_method method do |*args, &block|
         
     | 
| 
      
 22 
     | 
    
         
            +
                          value.call(*args, &block)
         
     | 
| 
      
 23 
     | 
    
         
            +
                        end
         
     | 
| 
      
 24 
     | 
    
         
            +
                      end
         
     | 
| 
      
 25 
     | 
    
         
            +
                    else
         
     | 
| 
      
 26 
     | 
    
         
            +
                      define_method method do |*|
         
     | 
| 
      
 27 
     | 
    
         
            +
                        value
         
     | 
| 
      
 28 
     | 
    
         
            +
                      end
         
     | 
| 
      
 29 
     | 
    
         
            +
                    end
         
     | 
| 
      
 30 
     | 
    
         
            +
                  }
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              # Maps each method name key in METHODS to its value definition.  If the value
         
     | 
| 
      
 35 
     | 
    
         
            +
              # of the key is a Proc it’ll be used as the method definition.  Otherwise,
         
     | 
| 
      
 36 
     | 
    
         
            +
              # the method definition will be set up to return VALUE.
         
     | 
| 
      
 37 
     | 
    
         
            +
              # @param [Hash<Symbol,Object>] methods
         
     | 
| 
      
 38 
     | 
    
         
            +
              def initialize(methods = {})
         
     | 
| 
      
 39 
     | 
    
         
            +
                (class << self; self; end).module_eval do
         
     | 
| 
      
 40 
     | 
    
         
            +
                  methods.each do |name, value|
         
     | 
| 
      
 41 
     | 
    
         
            +
                    Lookout::Stub.define self, name, value
         
     | 
| 
      
 42 
     | 
    
         
            +
                  end
         
     | 
| 
      
 43 
     | 
    
         
            +
                end unless methods.empty?
         
     | 
| 
      
 44 
     | 
    
         
            +
              end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
              def inspect; 'stub' end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
              private
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
              # Ignores any method calls that it doesn’t know anything about.
         
     | 
| 
      
 51 
     | 
    
         
            +
              # @param [Symbol] method
         
     | 
| 
      
 52 
     | 
    
         
            +
              # @param [Object, …] args
         
     | 
| 
      
 53 
     | 
    
         
            +
              # @return [self]
         
     | 
| 
      
 54 
     | 
    
         
            +
              def method_missing(method, *args) self end
         
     | 
| 
      
 55 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,133 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'inventory-1.0'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            module Lookout
         
     | 
| 
      
 6 
     | 
    
         
            +
              Version = Inventory.new(3, 0, 0){
         
     | 
| 
      
 7 
     | 
    
         
            +
                def dependencies
         
     | 
| 
      
 8 
     | 
    
         
            +
                  super + Inventory::Dependencies.new{
         
     | 
| 
      
 9 
     | 
    
         
            +
                    development 'inventory-rake', 1, 4, 0
         
     | 
| 
      
 10 
     | 
    
         
            +
                    development 'inventory-rake-tasks-yard', 1, 3, 0
         
     | 
| 
      
 11 
     | 
    
         
            +
                    development 'lookout-rake', 3, 0, 0
         
     | 
| 
      
 12 
     | 
    
         
            +
                    development 'yard', 0, 8, 0
         
     | 
| 
      
 13 
     | 
    
         
            +
                    development 'yard-heuristics', 1, 1, 0
         
     | 
| 
      
 14 
     | 
    
         
            +
                    development 'yard-value', 1, 2, 0
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                    runtime 'value', 1, 1, 0
         
     | 
| 
      
 17 
     | 
    
         
            +
                  }
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                def requires
         
     | 
| 
      
 21 
     | 
    
         
            +
                  %w[stringio]
         
     | 
| 
      
 22 
     | 
    
         
            +
                end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                def package_libs
         
     | 
| 
      
 25 
     | 
    
         
            +
                  %w[object.rb
         
     | 
| 
      
 26 
     | 
    
         
            +
                     aphonic.rb
         
     | 
| 
      
 27 
     | 
    
         
            +
                     actual.rb
         
     | 
| 
      
 28 
     | 
    
         
            +
                     actual/method.rb
         
     | 
| 
      
 29 
     | 
    
         
            +
                     actual/not.rb
         
     | 
| 
      
 30 
     | 
    
         
            +
                     actual/not/method.rb
         
     | 
| 
      
 31 
     | 
    
         
            +
                     diff.rb
         
     | 
| 
      
 32 
     | 
    
         
            +
                     diff/slice.rb
         
     | 
| 
      
 33 
     | 
    
         
            +
                     diff/algorithms.rb
         
     | 
| 
      
 34 
     | 
    
         
            +
                     diff/algorithms/difflib.rb
         
     | 
| 
      
 35 
     | 
    
         
            +
                     diff/algorithms/difflib/position.rb
         
     | 
| 
      
 36 
     | 
    
         
            +
                     diff/algorithms/difflib/position/new.rb
         
     | 
| 
      
 37 
     | 
    
         
            +
                     diff/formats.rb
         
     | 
| 
      
 38 
     | 
    
         
            +
                     diff/formats/inline.rb
         
     | 
| 
      
 39 
     | 
    
         
            +
                     diff/formats/set.rb
         
     | 
| 
      
 40 
     | 
    
         
            +
                     diff/formats/unified.rb
         
     | 
| 
      
 41 
     | 
    
         
            +
                     diff/group.rb
         
     | 
| 
      
 42 
     | 
    
         
            +
                     diff/groups.rb
         
     | 
| 
      
 43 
     | 
    
         
            +
                     diff/match.rb
         
     | 
| 
      
 44 
     | 
    
         
            +
                     diff/operation.rb
         
     | 
| 
      
 45 
     | 
    
         
            +
                     diff/operations.rb
         
     | 
| 
      
 46 
     | 
    
         
            +
                     diff/operations/delete.rb
         
     | 
| 
      
 47 
     | 
    
         
            +
                     diff/operations/copy.rb
         
     | 
| 
      
 48 
     | 
    
         
            +
                     diff/operations/insert.rb
         
     | 
| 
      
 49 
     | 
    
         
            +
                     diff/operations/replace.rb
         
     | 
| 
      
 50 
     | 
    
         
            +
                     difference.rb
         
     | 
| 
      
 51 
     | 
    
         
            +
                     difference/object.rb
         
     | 
| 
      
 52 
     | 
    
         
            +
                     difference/array.rb
         
     | 
| 
      
 53 
     | 
    
         
            +
                     difference/exception.rb
         
     | 
| 
      
 54 
     | 
    
         
            +
                     difference/hash.rb
         
     | 
| 
      
 55 
     | 
    
         
            +
                     difference/range.rb
         
     | 
| 
      
 56 
     | 
    
         
            +
                     difference/lookout.rb
         
     | 
| 
      
 57 
     | 
    
         
            +
                     difference/lookout/actual.rb
         
     | 
| 
      
 58 
     | 
    
         
            +
                     difference/lookout/actual/method.rb
         
     | 
| 
      
 59 
     | 
    
         
            +
                     difference/lookout/actual/not.rb
         
     | 
| 
      
 60 
     | 
    
         
            +
                     difference/lookout/actual/not/method.rb
         
     | 
| 
      
 61 
     | 
    
         
            +
                     difference/lookout/output.rb
         
     | 
| 
      
 62 
     | 
    
         
            +
                     difference/lookout/reception.rb
         
     | 
| 
      
 63 
     | 
    
         
            +
                     difference/lookout/warning.rb
         
     | 
| 
      
 64 
     | 
    
         
            +
                     difference/module.rb
         
     | 
| 
      
 65 
     | 
    
         
            +
                     difference/regexp.rb
         
     | 
| 
      
 66 
     | 
    
         
            +
                     difference/string.rb
         
     | 
| 
      
 67 
     | 
    
         
            +
                     difference/symbol.rb
         
     | 
| 
      
 68 
     | 
    
         
            +
                     encode.rb
         
     | 
| 
      
 69 
     | 
    
         
            +
                     exception.rb
         
     | 
| 
      
 70 
     | 
    
         
            +
                     exception/backtrace.rb
         
     | 
| 
      
 71 
     | 
    
         
            +
                     exception/unknown.rb
         
     | 
| 
      
 72 
     | 
    
         
            +
                     expect.rb
         
     | 
| 
      
 73 
     | 
    
         
            +
                     expect/object.rb
         
     | 
| 
      
 74 
     | 
    
         
            +
                     expect/object/context.rb
         
     | 
| 
      
 75 
     | 
    
         
            +
                     expect/classes.rb
         
     | 
| 
      
 76 
     | 
    
         
            +
                     expect/classes/exception.rb
         
     | 
| 
      
 77 
     | 
    
         
            +
                     expect/exception.rb
         
     | 
| 
      
 78 
     | 
    
         
            +
                     expected.rb
         
     | 
| 
      
 79 
     | 
    
         
            +
                     expected/object.rb
         
     | 
| 
      
 80 
     | 
    
         
            +
                     expected/array.rb
         
     | 
| 
      
 81 
     | 
    
         
            +
                     expected/classes.rb
         
     | 
| 
      
 82 
     | 
    
         
            +
                     expected/classes/exception.rb
         
     | 
| 
      
 83 
     | 
    
         
            +
                     expected/exception.rb
         
     | 
| 
      
 84 
     | 
    
         
            +
                     expected/falseclass.rb
         
     | 
| 
      
 85 
     | 
    
         
            +
                     expected/hash.rb
         
     | 
| 
      
 86 
     | 
    
         
            +
                     expected/lookout.rb
         
     | 
| 
      
 87 
     | 
    
         
            +
                     expected/lookout/actual.rb
         
     | 
| 
      
 88 
     | 
    
         
            +
                     expected/lookout/actual/method.rb
         
     | 
| 
      
 89 
     | 
    
         
            +
                     expected/lookout/actual/not.rb
         
     | 
| 
      
 90 
     | 
    
         
            +
                     expected/lookout/actual/not/method.rb
         
     | 
| 
      
 91 
     | 
    
         
            +
                     expected/lookout/output.rb
         
     | 
| 
      
 92 
     | 
    
         
            +
                     expected/lookout/reception.rb
         
     | 
| 
      
 93 
     | 
    
         
            +
                     expected/lookout/warning.rb
         
     | 
| 
      
 94 
     | 
    
         
            +
                     expected/module.rb
         
     | 
| 
      
 95 
     | 
    
         
            +
                     expected/range.rb
         
     | 
| 
      
 96 
     | 
    
         
            +
                     expected/regexp.rb
         
     | 
| 
      
 97 
     | 
    
         
            +
                     expected/string.rb
         
     | 
| 
      
 98 
     | 
    
         
            +
                     expected/symbol.rb
         
     | 
| 
      
 99 
     | 
    
         
            +
                     expected/trueclass.rb
         
     | 
| 
      
 100 
     | 
    
         
            +
                     expectations.rb
         
     | 
| 
      
 101 
     | 
    
         
            +
                     expectations/context.rb
         
     | 
| 
      
 102 
     | 
    
         
            +
                     inspect.rb
         
     | 
| 
      
 103 
     | 
    
         
            +
                     interfaces.rb
         
     | 
| 
      
 104 
     | 
    
         
            +
                     interfaces/commandline.rb
         
     | 
| 
      
 105 
     | 
    
         
            +
                     literal.rb
         
     | 
| 
      
 106 
     | 
    
         
            +
                     stub.rb
         
     | 
| 
      
 107 
     | 
    
         
            +
                     mock.rb
         
     | 
| 
      
 108 
     | 
    
         
            +
                     output.rb
         
     | 
| 
      
 109 
     | 
    
         
            +
                     plugins.rb
         
     | 
| 
      
 110 
     | 
    
         
            +
                     reception.rb
         
     | 
| 
      
 111 
     | 
    
         
            +
                     reception/arguments.rb
         
     | 
| 
      
 112 
     | 
    
         
            +
                     reception/arguments/any.rb
         
     | 
| 
      
 113 
     | 
    
         
            +
                     reception/arguments/error.rb
         
     | 
| 
      
 114 
     | 
    
         
            +
                     reception/arguments/list.rb
         
     | 
| 
      
 115 
     | 
    
         
            +
                     reception/arguments/none.rb
         
     | 
| 
      
 116 
     | 
    
         
            +
                     reception/error.rb
         
     | 
| 
      
 117 
     | 
    
         
            +
                     object/not.rb
         
     | 
| 
      
 118 
     | 
    
         
            +
                     object/not/receive.rb
         
     | 
| 
      
 119 
     | 
    
         
            +
                     object/to.rb
         
     | 
| 
      
 120 
     | 
    
         
            +
                     object/to/receive.rb
         
     | 
| 
      
 121 
     | 
    
         
            +
                     result.rb
         
     | 
| 
      
 122 
     | 
    
         
            +
                     results.rb
         
     | 
| 
      
 123 
     | 
    
         
            +
                     results/error.rb
         
     | 
| 
      
 124 
     | 
    
         
            +
                     results/failure.rb
         
     | 
| 
      
 125 
     | 
    
         
            +
                     results/success.rb
         
     | 
| 
      
 126 
     | 
    
         
            +
                     warning.rb]
         
     | 
| 
      
 127 
     | 
    
         
            +
                end
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
                def additional_unit_tests
         
     | 
| 
      
 130 
     | 
    
         
            +
                  %w[examples.rb]
         
     | 
| 
      
 131 
     | 
    
         
            +
                end
         
     | 
| 
      
 132 
     | 
    
         
            +
              }
         
     | 
| 
      
 133 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,40 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Warning expectation proxy.  Used to expect warning outputs during the
         
     | 
| 
      
 4 
     | 
    
         
            +
            # execution of the {Lookout::Expect expect block}.  Warnings are matched by
         
     | 
| 
      
 5 
     | 
    
         
            +
            # ignoring any trailing newlines and by removing any file/line warning
         
     | 
| 
      
 6 
     | 
    
         
            +
            # prefixes.  This is done as Ruby internally uses two different functions to
         
     | 
| 
      
 7 
     | 
    
         
            +
            # generate warnings (rb_warn() and rb_warning()).
         
     | 
| 
      
 8 
     | 
    
         
            +
            class Lookout::Warning < Lookout::Output
         
     | 
| 
      
 9 
     | 
    
         
            +
              # Proxies the EXPECTED warning output.
         
     | 
| 
      
 10 
     | 
    
         
            +
              # @param (see Output#initialize)
         
     | 
| 
      
 11 
     | 
    
         
            +
              def initialize(expected) super expected.chomp end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              # @return True if the receiver `#==` OTHER or if their classes and normalized
         
     | 
| 
      
 14 
     | 
    
         
            +
              #   expected output `#==` each other
         
     | 
| 
      
 15 
     | 
    
         
            +
              def ===(other)
         
     | 
| 
      
 16 
     | 
    
         
            +
                self == other or
         
     | 
| 
      
 17 
     | 
    
         
            +
                  (self.class == other.class and normalized == other.normalized)
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              def inspect; 'warning(%p)' % expected end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              # @return [Enumerable<String>] An Enumerable over the formatted operations
         
     | 
| 
      
 23 
     | 
    
         
            +
              #   that would have to be applied to the actual warning output to get the
         
     | 
| 
      
 24 
     | 
    
         
            +
              #   expected warning output after any normalization of the warning outputs
         
     | 
| 
      
 25 
     | 
    
         
            +
              #   have been performed
         
     | 
| 
      
 26 
     | 
    
         
            +
              def diff(other)
         
     | 
| 
      
 27 
     | 
    
         
            +
                self == normalized ? super(other.normalized) : normalized.diff(other)
         
     | 
| 
      
 28 
     | 
    
         
            +
              end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              # @return [Expected::Lookout::Warning] A wrapper around the receiver, making
         
     | 
| 
      
 31 
     | 
    
         
            +
              #   it an expected value
         
     | 
| 
      
 32 
     | 
    
         
            +
              def to_lookout_expected; Lookout::Expected::Lookout::Warning.new(self) end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              protected
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
              def normalized
         
     | 
| 
      
 37 
     | 
    
         
            +
                normalized = expected.sub(/\A.*?:\d+: warning: /, '')
         
     | 
| 
      
 38 
     | 
    
         
            +
                expected == normalized ? self : self.class.new(normalized)
         
     | 
| 
      
 39 
     | 
    
         
            +
              end
         
     | 
| 
      
 40 
     | 
    
         
            +
            end
         
     | 
    
        data/test/unit/examples.rb
    CHANGED
    
    | 
         @@ -8,42 +8,62 @@ Expectations do 
     | 
|
| 
       8 
8 
     | 
    
         
             
                1 + 1
         
     | 
| 
       9 
9 
     | 
    
         
             
              end
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
              #  
     | 
| 
       12 
     | 
    
         
            -
              expect  
     | 
| 
       13 
     | 
    
         
            -
                 
     | 
| 
      
 11 
     | 
    
         
            +
              # Verify that an exception is raised.
         
     | 
| 
      
 12 
     | 
    
         
            +
              expect ArgumentError do
         
     | 
| 
      
 13 
     | 
    
         
            +
                Integer('1 + 1')
         
     | 
| 
       14 
14 
     | 
    
         
             
              end
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
     | 
    
         
            -
              #  
     | 
| 
       17 
     | 
    
         
            -
               
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
      
 16 
     | 
    
         
            +
              # Verify that the result is an Array.
         
     | 
| 
      
 17 
     | 
    
         
            +
              expect Array do
         
     | 
| 
      
 18 
     | 
    
         
            +
                [1, 2, 3].select{ |i| i % 2 == 0 }
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              # Verify that the result is what we expect it to be.
         
     | 
| 
      
 22 
     | 
    
         
            +
              expect [2, 4, 6] do
         
     | 
| 
      
 23 
     | 
    
         
            +
                [1, 2, 3].map{ |i| i * 2 }
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              # Check that the result is within a given range.
         
     | 
| 
      
 27 
     | 
    
         
            +
              expect 0.099..0.101 do
         
     | 
| 
      
 28 
     | 
    
         
            +
                0.4 - 0.3
         
     | 
| 
       20 
29 
     | 
    
         
             
              end
         
     | 
| 
       21 
30 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
              #  
     | 
| 
       23 
     | 
    
         
            -
              expect  
     | 
| 
       24 
     | 
    
         
            -
                 
     | 
| 
      
 31 
     | 
    
         
            +
              # Check an explicit result.
         
     | 
| 
      
 32 
     | 
    
         
            +
              expect 'ab' do
         
     | 
| 
      
 33 
     | 
    
         
            +
                'abc'[0..1]
         
     | 
| 
       25 
34 
     | 
    
         
             
              end
         
     | 
| 
       26 
35 
     | 
    
         | 
| 
       27 
     | 
    
         
            -
              #  
     | 
| 
      
 36 
     | 
    
         
            +
              # Match against a regexp (using %r{…} syntax to avoid a warning).
         
     | 
| 
      
 37 
     | 
    
         
            +
              expect %r{a substring} do
         
     | 
| 
      
 38 
     | 
    
         
            +
                'a string with a substring'
         
     | 
| 
      
 39 
     | 
    
         
            +
              end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
              # Modules and Classes
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              # Check that the result includes a given module.
         
     | 
| 
       28 
45 
     | 
    
         
             
              expect Enumerable do
         
     | 
| 
       29 
46 
     | 
    
         
             
                []
         
     | 
| 
       30 
47 
     | 
    
         
             
              end
         
     | 
| 
       31 
48 
     | 
    
         | 
| 
       32 
     | 
    
         
            -
              #  
     | 
| 
      
 49 
     | 
    
         
            +
              # Check that the result is of a given class.
         
     | 
| 
       33 
50 
     | 
    
         
             
              expect String do
         
     | 
| 
       34 
51 
     | 
    
         
             
                'a string'
         
     | 
| 
       35 
52 
     | 
    
         
             
              end
         
     | 
| 
       36 
53 
     | 
    
         | 
| 
       37 
     | 
    
         
            -
              #  
     | 
| 
      
 54 
     | 
    
         
            +
              # Verify the equality of modules.
         
     | 
| 
       38 
55 
     | 
    
         
             
              expect Enumerable do
         
     | 
| 
       39 
56 
     | 
    
         
             
                Enumerable
         
     | 
| 
       40 
57 
     | 
    
         
             
              end
         
     | 
| 
       41 
58 
     | 
    
         | 
| 
       42 
     | 
    
         
            -
              #  
     | 
| 
      
 59 
     | 
    
         
            +
              # Verify the equality of classes.
         
     | 
| 
       43 
60 
     | 
    
         
             
              expect String do
         
     | 
| 
       44 
61 
     | 
    
         
             
                String
         
     | 
| 
       45 
62 
     | 
    
         
             
              end
         
     | 
| 
       46 
63 
     | 
    
         | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
              # Booleans
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
       47 
67 
     | 
    
         
             
              # Verify that the result is truthful.
         
     | 
| 
       48 
68 
     | 
    
         
             
              expect true do
         
     | 
| 
       49 
69 
     | 
    
         
             
                1
         
     | 
| 
         @@ -54,43 +74,53 @@ Expectations do 
     | 
|
| 
       54 
74 
     | 
    
         
             
                nil
         
     | 
| 
       55 
75 
     | 
    
         
             
              end
         
     | 
| 
       56 
76 
     | 
    
         | 
| 
       57 
     | 
    
         
            -
              # Verify that the result is  
     | 
| 
      
 77 
     | 
    
         
            +
              # Verify that the result is literally true.
         
     | 
| 
       58 
78 
     | 
    
         
             
              expect TrueClass do
         
     | 
| 
       59 
79 
     | 
    
         
             
                true
         
     | 
| 
       60 
80 
     | 
    
         
             
              end
         
     | 
| 
       61 
81 
     | 
    
         | 
| 
       62 
     | 
    
         
            -
              # Verify that the result is  
     | 
| 
      
 82 
     | 
    
         
            +
              # Verify that the result is literally false.
         
     | 
| 
       63 
83 
     | 
    
         
             
              expect FalseClass do
         
     | 
| 
       64 
84 
     | 
    
         
             
                false
         
     | 
| 
       65 
85 
     | 
    
         
             
              end
         
     | 
| 
       66 
86 
     | 
    
         | 
| 
       67 
     | 
    
         
            -
              # Match XML contents, ignoring whitespace between tags.
         
     | 
| 
       68 
     | 
    
         
            -
              expect xml('<a><foo>bar</foo></a>') do
         
     | 
| 
       69 
     | 
    
         
            -
                "<a>\n\t<foo>bar</foo>  \n</a>"
         
     | 
| 
       70 
     | 
    
         
            -
              end
         
     | 
| 
       71 
87 
     | 
    
         | 
| 
       72 
     | 
    
         
            -
              #  
     | 
| 
       73 
     | 
    
         
            -
              expect xml(<<-EOX) do
         
     | 
| 
       74 
     | 
    
         
            -
                <one>
         
     | 
| 
       75 
     | 
    
         
            -
                  <two>
         
     | 
| 
       76 
     | 
    
         
            -
                    <three>4</three>
         
     | 
| 
       77 
     | 
    
         
            -
                    <five> 6 </five>
         
     | 
| 
       78 
     | 
    
         
            -
                  </two>
         
     | 
| 
       79 
     | 
    
         
            -
                </one>
         
     | 
| 
       80 
     | 
    
         
            -
              EOX
         
     | 
| 
       81 
     | 
    
         
            -
                '<one><two><three>4</three>
         
     | 
| 
       82 
     | 
    
         
            -
                 <five> 6 </five>
         
     | 
| 
       83 
     | 
    
         
            -
                 </two></one>'
         
     | 
| 
       84 
     | 
    
         
            -
              end
         
     | 
| 
      
 88 
     | 
    
         
            +
              # Output
         
     | 
| 
       85 
89 
     | 
    
         | 
| 
       86 
90 
     | 
    
         
             
              # Verify that the given text is output.
         
     | 
| 
       87 
91 
     | 
    
         
             
              expect output("abc\ndef\n") do |io|
         
     | 
| 
       88 
92 
     | 
    
         
             
                io.puts 'abc', 'def'
         
     | 
| 
       89 
93 
     | 
    
         
             
              end
         
     | 
| 
       90 
94 
     | 
    
         | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
              # Warnings
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
              # Expect a warning to be output.
         
     | 
| 
      
 99 
     | 
    
         
            +
              expect warning('this is your final one!') do
         
     | 
| 
      
 100 
     | 
    
         
            +
                warn 'this is your final one!'
         
     | 
| 
      
 101 
     | 
    
         
            +
              end
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
              # Expect a warning to be output; the “header” is automatically ignored.
         
     | 
| 
      
 104 
     | 
    
         
            +
              expect warning('this is your final one!') do
         
     | 
| 
      
 105 
     | 
    
         
            +
                warn '%s:%d: warning: this is your final one!' % [__FILE__, __LINE__]
         
     | 
| 
      
 106 
     | 
    
         
            +
              end
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
              # Verbosity
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
              # Use #with_verbose to set $VERBOSE during the execution of a block.
         
     | 
| 
      
 112 
     | 
    
         
            +
              expect nil do
         
     | 
| 
      
 113 
     | 
    
         
            +
                with_verbose nil do
         
     | 
| 
      
 114 
     | 
    
         
            +
                  $VERBOSE
         
     | 
| 
      
 115 
     | 
    
         
            +
                end
         
     | 
| 
      
 116 
     | 
    
         
            +
              end
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
              # Exceptions
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
       91 
121 
     | 
    
         
             
              # Verify that an exception is raised.
         
     | 
| 
       92 
     | 
    
         
            -
              expect  
     | 
| 
       93 
     | 
    
         
            -
                 
     | 
| 
      
 122 
     | 
    
         
            +
              expect ArgumentError do
         
     | 
| 
      
 123 
     | 
    
         
            +
                Integer('1 + 1')
         
     | 
| 
       94 
124 
     | 
    
         
             
              end
         
     | 
| 
       95 
125 
     | 
    
         | 
| 
       96 
126 
     | 
    
         
             
              # Verify that an exception with a specific message is raised.
         
     | 
| 
         @@ -103,90 +133,185 @@ Expectations do 
     | 
|
| 
       103 
133 
     | 
    
         
             
                raise StandardError.new('message')
         
     | 
| 
       104 
134 
     | 
    
         
             
              end
         
     | 
| 
       105 
135 
     | 
    
         | 
| 
       106 
     | 
    
         
            -
              # State-based Fluent Boolean Expectations
         
     | 
| 
       107 
136 
     | 
    
         | 
| 
       108 
     | 
    
         
            -
              #  
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
      
 137 
     | 
    
         
            +
              # Query Expectations
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
              # Expect #empty? on the result to be true.
         
     | 
| 
      
 140 
     | 
    
         
            +
              expect :empty? do
         
     | 
| 
      
 141 
     | 
    
         
            +
                []
         
     | 
| 
      
 142 
     | 
    
         
            +
              end
         
     | 
| 
      
 143 
     | 
    
         
            +
             
     | 
| 
      
 144 
     | 
    
         
            +
              # Equivalently, but less explicitly, expect #empty? on the result to be true.
         
     | 
| 
      
 145 
     | 
    
         
            +
              expect true do
         
     | 
| 
      
 146 
     | 
    
         
            +
                []
         
     | 
| 
      
 147 
     | 
    
         
            +
              end
         
     | 
| 
      
 148 
     | 
    
         
            +
             
     | 
| 
      
 149 
     | 
    
         
            +
              # Expect #empty? on the result to be false.
         
     | 
| 
      
 150 
     | 
    
         
            +
              expect :not_empty? do
         
     | 
| 
      
 151 
     | 
    
         
            +
                [1, 2, 3]
         
     | 
| 
      
 152 
     | 
    
         
            +
              end
         
     | 
| 
      
 153 
     | 
    
         
            +
             
     | 
| 
      
 154 
     | 
    
         
            +
              # Equivalently, but less explicitly, expect #empty? on the result to be false.
         
     | 
| 
      
 155 
     | 
    
         
            +
              expect false do
         
     | 
| 
      
 156 
     | 
    
         
            +
                [1, 2, 3].empty?
         
     | 
| 
      
 157 
     | 
    
         
            +
              end
         
     | 
| 
      
 158 
     | 
    
         
            +
             
     | 
| 
      
 159 
     | 
    
         
            +
             
     | 
| 
      
 160 
     | 
    
         
            +
              # Explicit Query Expectations
         
     | 
| 
      
 161 
     | 
    
         
            +
             
     | 
| 
      
 162 
     | 
    
         
            +
              # Expect [1, 2, 3] with all even integers removed to include 1.
         
     | 
| 
      
 163 
     | 
    
         
            +
              expect result.to.include? 1 do
         
     | 
| 
      
 164 
     | 
    
         
            +
                [1, 2, 3].reject{ |e| e.even? }
         
     | 
| 
      
 165 
     | 
    
         
            +
              end
         
     | 
| 
      
 166 
     | 
    
         
            +
             
     | 
| 
      
 167 
     | 
    
         
            +
              # Expect [1, 2, 3] with all even integers removed not to include 2.
         
     | 
| 
      
 168 
     | 
    
         
            +
              expect result.not.to.include? 2 do
         
     | 
| 
      
 169 
     | 
    
         
            +
                [1, 2, 3].reject{ |e| e.even? }
         
     | 
| 
       111 
170 
     | 
    
         
             
              end
         
     | 
| 
       112 
171 
     | 
    
         | 
| 
       113 
     | 
    
         
            -
              #  
     | 
| 
       114 
     | 
    
         
            -
               
     | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
      
 172 
     | 
    
         
            +
              # Equivalently, but less explicitly, though marginally faster, expect [1, 2,
         
     | 
| 
      
 173 
     | 
    
         
            +
              # 3] with all even integers not to include 2.
         
     | 
| 
      
 174 
     | 
    
         
            +
              expect false do
         
     | 
| 
      
 175 
     | 
    
         
            +
                [1, 2, 3].reject{ |e| e.even? }.include? 2
         
     | 
| 
       116 
176 
     | 
    
         
             
              end
         
     | 
| 
       117 
177 
     | 
    
         | 
| 
       118 
     | 
    
         
            -
              # Expect nil to respond to #nil?.
         
     | 
| 
       119 
     | 
    
         
            -
              expect nil.to.respond_to? :nil?
         
     | 
| 
       120 
178 
     | 
    
         | 
| 
       121 
     | 
    
         
            -
              #  
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
      
 179 
     | 
    
         
            +
              # Literal Expectations
         
     | 
| 
      
 180 
     | 
    
         
            +
             
     | 
| 
      
 181 
     | 
    
         
            +
              # Expect the symbol :empty?, not #empty? on the result to be true.
         
     | 
| 
      
 182 
     | 
    
         
            +
              expect literal(:empty?) do
         
     | 
| 
      
 183 
     | 
    
         
            +
                :empty?
         
     | 
| 
      
 184 
     | 
    
         
            +
              end
         
     | 
| 
      
 185 
     | 
    
         
            +
             
     | 
| 
       123 
186 
     | 
    
         | 
| 
       124 
     | 
    
         
            -
              # Expect Object not to be nil.
         
     | 
| 
       125 
     | 
    
         
            -
              expect Object.not.to.be.nil?
         
     | 
| 
       126 
187 
     | 
    
         | 
| 
       127 
188 
     | 
    
         
             
              # Behavior-based Expectations
         
     | 
| 
       128 
189 
     | 
    
         | 
| 
       129 
190 
     | 
    
         
             
              # Use a mock to verify that a method is called appropriately.
         
     | 
| 
       130 
     | 
    
         
            -
              expect mock.to.receive. 
     | 
| 
       131 
     | 
    
         
            -
                 
     | 
| 
       132 
     | 
    
         
            -
                phone.dial('2125551212')
         
     | 
| 
      
 191 
     | 
    
         
            +
              expect mock.to.receive.to_str(without_arguments){ '123' } do |o|
         
     | 
| 
      
 192 
     | 
    
         
            +
                o.to_str
         
     | 
| 
       133 
193 
     | 
    
         
             
              end
         
     | 
| 
       134 
194 
     | 
    
         | 
| 
       135 
     | 
    
         
            -
              # Use a stub that  
     | 
| 
       136 
     | 
    
         
            -
              #  
     | 
| 
       137 
     | 
    
         
            -
              expect stub.to.receive. 
     | 
| 
       138 
     | 
    
         
            -
                 
     | 
| 
       139 
     | 
    
         
            -
                phone.hangup
         
     | 
| 
       140 
     | 
    
         
            -
                phone.dial('2125551212')
         
     | 
| 
      
 195 
     | 
    
         
            +
              # Use a stub that returns stub objects for unknown methods to only verify
         
     | 
| 
      
 196 
     | 
    
         
            +
              # that a method of interest is called appropriately.
         
     | 
| 
      
 197 
     | 
    
         
            +
              expect stub.to.receive.to_str(without_arguments){ '123' } do |o|
         
     | 
| 
      
 198 
     | 
    
         
            +
                o.to_str if o.convertable?
         
     | 
| 
       141 
199 
     | 
    
         
             
              end
         
     | 
| 
       142 
200 
     | 
    
         | 
| 
       143 
     | 
    
         
            -
              # Use a  
     | 
| 
      
 201 
     | 
    
         
            +
              # Use a contrete mock to verify that a method is called.
         
     | 
| 
      
 202 
     | 
    
         
            +
              expect Object.to.receive.name do
         
     | 
| 
      
 203 
     | 
    
         
            +
                Object.name
         
     | 
| 
      
 204 
     | 
    
         
            +
              end
         
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
      
 206 
     | 
    
         
            +
              # Expect the reception of #a with any number of arguments.
         
     | 
| 
      
 207 
     | 
    
         
            +
              expect mock.to.receive.a do |m|
         
     | 
| 
      
 208 
     | 
    
         
            +
                m.a
         
     | 
| 
      
 209 
     | 
    
         
            +
              end
         
     | 
| 
      
 210 
     | 
    
         
            +
             
     | 
| 
      
 211 
     | 
    
         
            +
              # Expect the reception of #a with one argument.
         
     | 
| 
      
 212 
     | 
    
         
            +
              expect mock.to.receive.a(Object) do |m|
         
     | 
| 
      
 213 
     | 
    
         
            +
                m.a 0
         
     | 
| 
      
 214 
     | 
    
         
            +
              end
         
     | 
| 
      
 215 
     | 
    
         
            +
             
     | 
| 
      
 216 
     | 
    
         
            +
              # Expect the reception of #a with either 1 or 2.
         
     | 
| 
      
 217 
     | 
    
         
            +
              expect mock.to.receive.a(1..2) do |m|
         
     | 
| 
      
 218 
     | 
    
         
            +
                m.a 1
         
     | 
| 
      
 219 
     | 
    
         
            +
              end
         
     | 
| 
      
 220 
     | 
    
         
            +
             
     | 
| 
      
 221 
     | 
    
         
            +
              # Expect the reception of #a without any arguments.
         
     | 
| 
      
 222 
     | 
    
         
            +
              expect mock.to.receive.a(without_arguments) do |m|
         
     | 
| 
      
 223 
     | 
    
         
            +
                m.a
         
     | 
| 
      
 224 
     | 
    
         
            +
              end
         
     | 
| 
      
 225 
     | 
    
         
            +
             
     | 
| 
      
 226 
     | 
    
         
            +
              # Expect the reception of #a with three arguments, the second being 1.
         
     | 
| 
      
 227 
     | 
    
         
            +
              expect mock.to.receive.a(Object, 2, Object) do |m|
         
     | 
| 
      
 228 
     | 
    
         
            +
                m.a nil, 2, '3'
         
     | 
| 
      
 229 
     | 
    
         
            +
              end
         
     | 
| 
      
 230 
     | 
    
         
            +
             
     | 
| 
      
 231 
     | 
    
         
            +
              # Expect the reception of #a and return 1 so that other code works.
         
     | 
| 
      
 232 
     | 
    
         
            +
              expect mock.to.receive.a{ 1 } do |m|
         
     | 
| 
      
 233 
     | 
    
         
            +
                raise 'not 1' unless m.a == 1
         
     | 
| 
      
 234 
     | 
    
         
            +
              end
         
     | 
| 
      
 235 
     | 
    
         
            +
             
     | 
| 
      
 236 
     | 
    
         
            +
              # Expect the reception of #a and call the block with 1.
         
     | 
| 
      
 237 
     | 
    
         
            +
              expect mock.to.receive.a{ |&b| b.call(1) } do |m|
         
     | 
| 
      
 238 
     | 
    
         
            +
                j = 0
         
     | 
| 
      
 239 
     | 
    
         
            +
                m.a{ |i| j = i }
         
     | 
| 
      
 240 
     | 
    
         
            +
                raise 'not 1' unless j == 1
         
     | 
| 
      
 241 
     | 
    
         
            +
              end
         
     | 
| 
      
 242 
     | 
    
         
            +
             
     | 
| 
      
 243 
     | 
    
         
            +
              # Stub out a specific method on an object.
         
     | 
| 
      
 244 
     | 
    
         
            +
              expect 6 do |m|
         
     | 
| 
      
 245 
     | 
    
         
            +
                stub(Class.new{
         
     | 
| 
      
 246 
     | 
    
         
            +
                       def slips
         
     | 
| 
      
 247 
     | 
    
         
            +
                         raise 'database not available'
         
     | 
| 
      
 248 
     | 
    
         
            +
                       end
         
     | 
| 
      
 249 
     | 
    
         
            +
             
     | 
| 
      
 250 
     | 
    
         
            +
                       def total
         
     | 
| 
      
 251 
     | 
    
         
            +
                         slips.reduce(0){ |m, n| m.to_i + n.to_i }
         
     | 
| 
      
 252 
     | 
    
         
            +
                       end
         
     | 
| 
      
 253 
     | 
    
         
            +
                     }.new, :slips => [1, 2, 3]){ |account| account.total }
         
     | 
| 
      
 254 
     | 
    
         
            +
              end
         
     | 
| 
      
 255 
     | 
    
         
            +
             
     | 
| 
      
 256 
     | 
    
         
            +
             
     | 
| 
      
 257 
     | 
    
         
            +
              # Create a stub object that responds to specific methods.
         
     | 
| 
       144 
258 
     | 
    
         
             
              expect 3 do
         
     | 
| 
       145 
259 
     | 
    
         
             
                s = stub(:a => 1, :b => 2)
         
     | 
| 
       146 
260 
     | 
    
         
             
                s.a + s.b
         
     | 
| 
       147 
261 
     | 
    
         
             
              end
         
     | 
| 
       148 
262 
     | 
    
         | 
| 
      
 263 
     | 
    
         
            +
              # Expect the reception of #a on a stub object that responds to specific methods.
         
     | 
| 
      
 264 
     | 
    
         
            +
              expect stub(:a => 1, :b => 2).to.receive.a do |o|
         
     | 
| 
      
 265 
     | 
    
         
            +
                o.a + o.b
         
     | 
| 
      
 266 
     | 
    
         
            +
              end
         
     | 
| 
      
 267 
     | 
    
         
            +
             
     | 
| 
      
 268 
     | 
    
         
            +
              # Expect the reception of #a on a mock object that responds to specific methods.
         
     | 
| 
      
 269 
     | 
    
         
            +
              expect mock(:a => 2, :b => 2).to.receive.a do |o|
         
     | 
| 
      
 270 
     | 
    
         
            +
                o.a + o.b
         
     | 
| 
      
 271 
     | 
    
         
            +
              end
         
     | 
| 
      
 272 
     | 
    
         
            +
             
     | 
| 
       149 
273 
     | 
    
         
             
              # Use a stub that’s set up with a set of procs as methods.
         
     | 
| 
       150 
274 
     | 
    
         
             
              expect 3 do
         
     | 
| 
       151 
275 
     | 
    
         
             
                s = stub(:a => proc{ |a, b| a + b })
         
     | 
| 
       152 
276 
     | 
    
         
             
                s.a(1, 2)
         
     | 
| 
       153 
277 
     | 
    
         
             
              end
         
     | 
| 
       154 
278 
     | 
    
         | 
| 
       155 
     | 
    
         
            -
              #  
     | 
| 
       156 
     | 
    
         
            -
              expect  
     | 
| 
       157 
     | 
    
         
            -
                 
     | 
| 
      
 279 
     | 
    
         
            +
              # Stub out a specific method on an object.
         
     | 
| 
      
 280 
     | 
    
         
            +
              expect 'def' do
         
     | 
| 
      
 281 
     | 
    
         
            +
                stub('abc', :to_str => 'def'){ |a| a.to_str }
         
     | 
| 
       158 
282 
     | 
    
         
             
              end
         
     | 
| 
       159 
283 
     | 
    
         | 
| 
       160 
     | 
    
         
            -
              # Expect a new object to receive #deal with any arguments.
         
     | 
| 
       161 
     | 
    
         
            -
              expect Object.new.to.receive.deal do |o|
         
     | 
| 
       162 
     | 
    
         
            -
                o.deal(1, 2, 3)
         
     | 
| 
       163 
     | 
    
         
            -
              end
         
     | 
| 
       164 
284 
     | 
    
         | 
| 
       165 
     | 
    
         
            -
              # Expect a new object to receive #deal without arguments.
         
     | 
| 
       166 
     | 
    
         
            -
              expect Object.new.to.receive.deal(without_arguments) do |o|
         
     | 
| 
       167 
     | 
    
         
            -
                o.deal
         
     | 
| 
       168 
     | 
    
         
            -
              end
         
     | 
| 
       169 
285 
     | 
    
         | 
| 
       170 
     | 
    
         
            -
              # Expect a new object to receive #deal with any argument, 1, and any
         
     | 
| 
       171 
     | 
    
         
            -
              # argument.
         
     | 
| 
       172 
     | 
    
         
            -
              expect Object.new.to.receive.deal(arg, 1, arg) do |o|
         
     | 
| 
       173 
     | 
    
         
            -
                o.deal :a, 1, :b
         
     | 
| 
       174 
     | 
    
         
            -
              end
         
     | 
| 
       175 
286 
     | 
    
         | 
| 
       176 
287 
     | 
    
         
             
              # Utilities
         
     | 
| 
       177 
     | 
    
         
            -
             
     | 
| 
       178 
     | 
    
         
            -
              #  
     | 
| 
       179 
     | 
    
         
            -
              expect  
     | 
| 
       180 
     | 
    
         
            -
                 
     | 
| 
       181 
     | 
    
         
            -
                   
     | 
| 
      
 288 
     | 
    
         
            +
             
     | 
| 
      
 289 
     | 
    
         
            +
              # Override the value of a constant during the execution of a block.
         
     | 
| 
      
 290 
     | 
    
         
            +
              expect 'hello' do
         
     | 
| 
      
 291 
     | 
    
         
            +
                with_const 'A::B::C', 'hello' do
         
     | 
| 
      
 292 
     | 
    
         
            +
                  A::B::C
         
     | 
| 
       182 
293 
     | 
    
         
             
                end
         
     | 
| 
       183 
294 
     | 
    
         
             
              end
         
     | 
| 
       184 
295 
     | 
    
         | 
| 
       185 
     | 
    
         
            -
               
     | 
| 
       186 
     | 
    
         
            -
             
     | 
| 
      
 296 
     | 
    
         
            +
              # Override/add environment keys/values during the execution of a block.
         
     | 
| 
      
 297 
     | 
    
         
            +
              expect 'hello' do
         
     | 
| 
      
 298 
     | 
    
         
            +
                with_env 'INTRO' => 'hello' do
         
     | 
| 
      
 299 
     | 
    
         
            +
                  ENV['INTRO']
         
     | 
| 
      
 300 
     | 
    
         
            +
                end
         
     | 
| 
       187 
301 
     | 
    
         
             
              end
         
     | 
| 
       188 
302 
     | 
    
         | 
| 
       189 
     | 
    
         
            -
               
     | 
| 
       190 
     | 
    
         
            -
             
     | 
| 
      
 303 
     | 
    
         
            +
              # Override the value of a global during the execution of a block.
         
     | 
| 
      
 304 
     | 
    
         
            +
              expect 'hello' do
         
     | 
| 
      
 305 
     | 
    
         
            +
                with_global :$stdout, StringIO.new do
         
     | 
| 
      
 306 
     | 
    
         
            +
                  print 'hello'
         
     | 
| 
      
 307 
     | 
    
         
            +
                  $stdout.string
         
     | 
| 
      
 308 
     | 
    
         
            +
                end
         
     | 
| 
      
 309 
     | 
    
         
            +
              end
         
     | 
| 
      
 310 
     | 
    
         
            +
             
     | 
| 
      
 311 
     | 
    
         
            +
              # Use the overridden value of a global during the execution of a block.
         
     | 
| 
      
 312 
     | 
    
         
            +
              expect true do
         
     | 
| 
      
 313 
     | 
    
         
            +
                with_global :$stdout, StringIO.new do |overridden|
         
     | 
| 
      
 314 
     | 
    
         
            +
                  $stdout != overridden
         
     | 
| 
      
 315 
     | 
    
         
            +
                end
         
     | 
| 
       191 
316 
     | 
    
         
             
              end
         
     | 
| 
       192 
317 
     | 
    
         
             
            end
         
     |