lookout 2.3.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/Rakefile
CHANGED
@@ -1,9 +1,24 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
-
|
4
|
-
require 'lookout/rake/tasks'
|
3
|
+
require 'inventory-rake-1.0'
|
5
4
|
|
6
|
-
|
7
|
-
|
5
|
+
load File.expand_path('../lib/lookout-3.0/version.rb', __FILE__)
|
6
|
+
|
7
|
+
Inventory::Rake::Tasks.define Lookout::Version, :gem => proc{ |_, s|
|
8
|
+
s.author = 'Nikolai Weibull'
|
9
|
+
s.email = 'now@bitwi.se'
|
10
|
+
s.homepage = 'https://github.com/now/lookout'
|
11
|
+
}
|
12
|
+
|
13
|
+
Inventory::Rake::Tasks.unless_installing_dependencies do
|
14
|
+
require 'lookout-rake-3.0'
|
15
|
+
Lookout::Rake::Tasks::Test.new do |t|
|
16
|
+
ENV['LOOKOUT_DO_NOT_FILTER_BACKTRACE'] = ''
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'inventory-rake-tasks-yard-1.0'
|
20
|
+
Inventory::Rake::Tasks::YARD.new do |t|
|
21
|
+
t.options += %w'--plugin yard-heuristics-1.0 --plugin yard-value-1.0'
|
22
|
+
t.globals[:source_code_url] = 'https://github.com/now/%s/blob/v%s/%%s#L%%d' % [t.inventory.package, t.inventory]
|
23
|
+
end
|
8
24
|
end
|
9
|
-
Lookout::Rake::Tasks::Gem.new
|
data/lib/lookout-3.0.rb
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
# Main namespace of the Lookout library.
|
4
|
+
#
|
5
|
+
# {Expectations} is the main entry point to the library, representing the
|
6
|
+
# “Expectations” keyword in expectation files and allowing such files to be
|
7
|
+
# loaded, enumerating the {Expect} blocks found in such files. Each such block
|
8
|
+
# has an {Expected} value that’s an {Actual} result wrapper, a {Literal}, an
|
9
|
+
# expected {Output}, an expected {Warning}, an expected method {Reception}, or
|
10
|
+
# any {::Object} really, which it’ll compare to the actual result of executing
|
11
|
+
# the block, reporting any {Difference}s – which may, in turn, be shown as
|
12
|
+
# {Diff}s – as its {Result}.
|
13
|
+
#
|
14
|
+
# To help out, {Stub stub} and {Mock mock} objects may be created.
|
15
|
+
# Furthermore, all ::Objects have been extended to support easy creation of
|
16
|
+
# expected method {Reception}s, using a simple {Object domain-specific
|
17
|
+
# language} that uses {Aphonic} receivers to gather the necessary information.
|
18
|
+
#
|
19
|
+
# To avoid failing while trying to report failures, non-failing access to
|
20
|
+
# {Exception}s and {Inspect}ions of objects is used, as well as making sure to
|
21
|
+
# {Encode} any output properly.
|
22
|
+
#
|
23
|
+
# There’s a command-line interface defined in {Interfaces::Commandline} that can
|
24
|
+
# be used by other interfaces that want to invoke Lookout on a set of files.
|
25
|
+
# It’s used by the {http://disu.se/software/lookout-rake Lookout-Rake} library.
|
26
|
+
#
|
27
|
+
# Plugins should place their namespace under the {Lookout::Plugins} namespace.
|
28
|
+
module Lookout
|
29
|
+
class << self
|
30
|
+
def location(location)
|
31
|
+
return nil, nil unless match = /\A(.*):(\d+)(?::in .*)?\z/.match(location)
|
32
|
+
[match[1], match[2].to_i]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
load File.expand_path('../lookout-3.0/version.rb', __FILE__)
|
37
|
+
Version.load
|
38
|
+
end
|
39
|
+
|
40
|
+
# Adds keyword methods “to” and “not” and #to_lookout_expected for Objects.
|
41
|
+
class Object
|
42
|
+
# @return [Lookout::Object::To] A wrapper around the receiver that handles
|
43
|
+
# “to” keywords, such as “receive”
|
44
|
+
def to; Lookout::Object::To.new(self) end
|
45
|
+
|
46
|
+
# @return [Lookout::Object::To] A wrapper around the receiver that handles
|
47
|
+
# “not” keywords, such as “to”, that’ll then handle “receive”
|
48
|
+
def not; Lookout::Object::Not.new(self) end
|
49
|
+
|
50
|
+
# @return [Lookout::Expected::Object] A wrapper around the receiver, making
|
51
|
+
# it an expected value
|
52
|
+
def to_lookout_expected; Lookout::Expected::Object.new(self) end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Adds #to_lookout_expected to Arrays for better difference reports.
|
56
|
+
class Array
|
57
|
+
# @return [Lookout::Expected::Array] A wrapper around the receiver, making
|
58
|
+
# it an expected value
|
59
|
+
def to_lookout_expected; Lookout::Expected::Array.new(self) end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Adds #to_lookout_expected to TrueClasses (`true`) for better difference
|
63
|
+
# reports.
|
64
|
+
class TrueClass
|
65
|
+
# @return [Lookout::Expected::TrueClass] A wrapper around the receiver,
|
66
|
+
# making it an expected value
|
67
|
+
def to_lookout_expected; Lookout::Expected::TrueClass.new(self) end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Adds #to_lookout_expected to FalseClasses (`false`) for better difference
|
71
|
+
# reports.
|
72
|
+
class FalseClass
|
73
|
+
# @return [Lookout::Expected::FalseClass] A wrapper around the receiver,
|
74
|
+
# making it an expected value
|
75
|
+
def to_lookout_expected; Lookout::Expected::FalseClass.new(self) end
|
76
|
+
end
|
77
|
+
|
78
|
+
# Adds #to_lookout_expected to Hashes for better difference reports.
|
79
|
+
class Hash
|
80
|
+
# @return [Lookout::Expected::Hash] A wrapper around the receiver, making it
|
81
|
+
# an expected value
|
82
|
+
def to_lookout_expected; Lookout::Expected::Hash.new(self) end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Adds #to_lookout_expected to Modules for better difference reports.
|
86
|
+
class Module
|
87
|
+
# @return [Lookout::Expected::Module] A wrapper around the receiver, making
|
88
|
+
# it an expected value
|
89
|
+
def to_lookout_expected; Lookout::Expected::Module.new(self) end
|
90
|
+
end
|
91
|
+
|
92
|
+
# Adds #to_lookout_expected to Ranges for better difference reports.
|
93
|
+
class Range
|
94
|
+
# @return [Lookout::Expected::Range] A wrapper around the receiver, making it
|
95
|
+
# an expected value
|
96
|
+
def to_lookout_expected; Lookout::Expected::Range.new(self) end
|
97
|
+
end
|
98
|
+
|
99
|
+
# Adds #to_lookout_expected to Regexps for better difference reports.
|
100
|
+
class Regexp
|
101
|
+
# @return [Lookout::Expected::Regexps] A wrapper around the receiver, making
|
102
|
+
# it an expected value
|
103
|
+
def to_lookout_expected; Lookout::Expected::Regexp.new(self) end
|
104
|
+
end
|
105
|
+
|
106
|
+
# Adds #to_lookout_expected to Exceptions and their classes for better
|
107
|
+
# difference reports.
|
108
|
+
class Exception
|
109
|
+
class << self
|
110
|
+
# @return [Lookout::Expected::Classes::Exception] A wrapper around the
|
111
|
+
# receiver, making it an expected value
|
112
|
+
def to_lookout_expected; Lookout::Expected::Classes::Exception.new(self) end
|
113
|
+
end
|
114
|
+
|
115
|
+
# @return [Lookout::Expected::Exception] A wrapper around the receiver,
|
116
|
+
# making it an expected value
|
117
|
+
def to_lookout_expected; Lookout::Expected::Exception.new(self) end
|
118
|
+
end
|
119
|
+
|
120
|
+
# Adds #to_lookout_expected to Strings for better difference reports.
|
121
|
+
class String
|
122
|
+
# @return [Lookout::Expected::String] A wrapper around the receiver, making
|
123
|
+
# it an expected value
|
124
|
+
def to_lookout_expected; Lookout::Expected::String.new(self) end
|
125
|
+
end
|
126
|
+
|
127
|
+
# Adds #to_lookout_expected to Symbols for query method expectations and better
|
128
|
+
# difference reports.
|
129
|
+
class Symbol
|
130
|
+
# @return [Lookout::Expected::Smybol] A wrapper around the receiver, making
|
131
|
+
# it an expected value
|
132
|
+
def to_lookout_expected; Lookout::Expected::Symbol.new(self) end
|
133
|
+
end
|
134
|
+
|
135
|
+
def Expectations(&block)
|
136
|
+
Lookout::Expectations.evaluate Lookout.location(caller.first).first, &block
|
137
|
+
self
|
138
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
# Stands in for the actual result of the {Lookout::Expect expect block},
|
4
|
+
# allowing a query method to call on the actual result to be set up and checked
|
5
|
+
# after the expect block returns. Used by
|
6
|
+
# {Lookout::Expectations::Context#result}.
|
7
|
+
class Lookout::Actual < Lookout::Aphonic
|
8
|
+
# @return [Actual::Not] A result stand-in that’s the inversion of the
|
9
|
+
# receiver
|
10
|
+
def not; Lookout::Actual::Not.new end
|
11
|
+
|
12
|
+
# Method for improving readability of query method set-up.
|
13
|
+
# @return [self]
|
14
|
+
def to; self end
|
15
|
+
|
16
|
+
# Method for improving readability of query method set-up.
|
17
|
+
# @return [self]
|
18
|
+
def be; self end
|
19
|
+
|
20
|
+
# Method for improving readability of query method set-up.
|
21
|
+
# @return [self]
|
22
|
+
def have; self end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
# @param (see Method#initialize)
|
27
|
+
# @return [Method] A method wrapper that’ll call METHOD with ARGS and BLOCK
|
28
|
+
# when called
|
29
|
+
def method_missing(method, *args, &block) Method.new(method, *args, &block) end
|
30
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
# Proxies a method for later invocation on the actual result. The method
|
4
|
+
# information is stored and used when this method is {#call}ed, which passes it
|
5
|
+
# along to the given actual result.
|
6
|
+
class Lookout::Actual::Method
|
7
|
+
# Proxies METHOD, passing in ARGS and BLOCK when {#call}ed.
|
8
|
+
# @param [Symbol] method
|
9
|
+
# @param [Object, …] args
|
10
|
+
Value(:method, :'*args', :'&block')
|
11
|
+
|
12
|
+
# @param [Object] actual
|
13
|
+
# @return [Object] The result of invoking the method with the given arguments
|
14
|
+
# on the ACTUAL result
|
15
|
+
def call(actual) actual.__send__(method, *args, &block) end
|
16
|
+
|
17
|
+
# @return [Expected::Lookout::Actual::Method] An expected value wrapper of
|
18
|
+
# the receiver
|
19
|
+
def to_lookout_expected; Lookout::Expected::Lookout::Actual::Method.new(self) end
|
20
|
+
|
21
|
+
# @return A string of the form “#_method_(_args_){ … }”, depending on if any
|
22
|
+
# arguments or block has been given
|
23
|
+
def to_s
|
24
|
+
['#',
|
25
|
+
method,
|
26
|
+
args.empty? ? '' : '(%s)' % Lookout::Inspect.args(*args),
|
27
|
+
block ? '{ … }' : ''].join('')
|
28
|
+
end
|
29
|
+
|
30
|
+
alias inspect to_s
|
31
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
# Inverts {Actual}. Allows a query method to call on the actual result to be
|
4
|
+
# set up and its inversion checked after the expect block returns.
|
5
|
+
class Lookout::Actual::Not < Lookout::Actual
|
6
|
+
# @return [Actual] A result stand-in that’s the inversion of the receiver
|
7
|
+
def not; Lookout::Actual.new end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
# (see Lookout::Actual#method_missing)
|
12
|
+
def method_missing(method, *args, &block); Method.new(method, *args, &block) end
|
13
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
# Proxies a method for later invocation on the actual result. The method
|
4
|
+
# information is stored and used when this method is {#call}ed, which passes it
|
5
|
+
# along to the given actual result.
|
6
|
+
class Lookout::Actual::Not::Method < Lookout::Actual::Method
|
7
|
+
# @return [Expected::Lookout::Actual::Not::Method] An expected value wrapper
|
8
|
+
# of the receiver
|
9
|
+
def to_lookout_expected; Lookout::Expected::Lookout::Actual::Not::Method.new(self) end
|
10
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
# Class that only responds to `#__send__` and #object_id. Useful for DSLs and
|
4
|
+
# classes that make use of #method_missing. Things are set
|
5
|
+
# up so that if methods are added to Kernel, Object, or Method after the
|
6
|
+
# initial set-up, such methods will similarly be {.silence}d.
|
7
|
+
class Lookout::Aphonic
|
8
|
+
Methods = [:__send__, :object_id]
|
9
|
+
Methods << :__id__ if RUBY_VERSION < '1.9' # Ruby 1.8 warns if __id__ is undefined
|
10
|
+
|
11
|
+
class << self
|
12
|
+
# Undefines METHOD unless it’s on the short-list of methods to keep.
|
13
|
+
# @param [Symbol] method
|
14
|
+
# @return [self]
|
15
|
+
def silence(method)
|
16
|
+
undef_method method if
|
17
|
+
instance_methods.include?(RUBY_VERSION < '1.9' ? method.to_s : method.to_sym) and
|
18
|
+
not Methods.include? method.to_sym
|
19
|
+
self
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
instance_methods.each(&method(:silence))
|
24
|
+
end
|
25
|
+
|
26
|
+
[Kernel, Object].each do |object|
|
27
|
+
object.instance_eval{ class << self; self; end }.instance_eval do
|
28
|
+
method_added = method(:method_added)
|
29
|
+
define_method :method_added do |name|
|
30
|
+
result = method_added.call(name)
|
31
|
+
Lookout::Aphonic.silence name if self == object
|
32
|
+
result
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class Module
|
38
|
+
append_features = instance_method(:append_features)
|
39
|
+
define_method :append_features do |mod|
|
40
|
+
result = append_features.bind(self).call(mod)
|
41
|
+
instance_methods.each{ |name| Lookout::Aphonic.silence name } if mod == Object
|
42
|
+
result
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
# Namespace for the “diff” subsystem. Includes various algorithms for
|
4
|
+
# generating “diffs” and output formats for displaying them. Used by
|
5
|
+
# {Difference} to generate meaningful “diffs” of objects.
|
6
|
+
#
|
7
|
+
# A “diff” is a {Operations sequence} of {Operation}s that describe how to turn
|
8
|
+
# an old/original/from version of a structure, such as an {::Array}, to a
|
9
|
+
# new/new/to version of that structure. For example, if the old version of an
|
10
|
+
# Array is [1, 2, 3] and the new version of that array is [1, 2, 3, 4], then
|
11
|
+
# the “diff” is a sequence of operations containing one operation, the
|
12
|
+
# {Operations::Insert insertion} of the element 4 at the end of the Array.
|
13
|
+
#
|
14
|
+
# A “diff” is generated by one of various {Algorithms} that calculate optimal
|
15
|
+
# sequences of operations, for some definition of “optimal”. A common goal is
|
16
|
+
# to provide the shortest sequence of operations necessary, but providing a
|
17
|
+
# sequence that “feels natural” to a human is often also a priority. The
|
18
|
+
# algorithms work by looking for {Match}es between {Slice}s of the sequences
|
19
|
+
# and then turning the information provided by these matches into the
|
20
|
+
# operations that describe the changes that need to be made.
|
21
|
+
#
|
22
|
+
# “Diffs” can be turned into quite a few different textual {Formats} for
|
23
|
+
# display to a human. Such formats may {Group} together related {Groups} of
|
24
|
+
# operations, focusing the display on the actual differences.
|
25
|
+
#
|
26
|
+
# You can find more information about “diffs” at
|
27
|
+
# {http://en.wikipedia.org/wiki/Diff}.
|
28
|
+
module Lookout::Diff
|
29
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
# The difflib algorithm is based on the algorithm employed by the difflib
|
4
|
+
# library for Python, which is, in turn, based on an algorithm by Ratcliff and
|
5
|
+
# Obershelp, see {http://docs.python.org/library/difflib.html}.
|
6
|
+
#
|
7
|
+
# It’s implemented as an Enumerable over the {Match}es between two sequences.
|
8
|
+
# There are very few requirements on these sequences (see {#initialize}), which
|
9
|
+
# makes this implementation useful for a wide class of objects.
|
10
|
+
class Lookout::Diff::Algorithms::Difflib
|
11
|
+
# Initializes the algorithm to generate matches between the OLD and NEW
|
12
|
+
# versions of the indexable sequences. The sequences must be indexable by
|
13
|
+
# {::Range}s and Integers with the semantics that, for example, {::Array}s
|
14
|
+
# have, and their elements must also respond to #hash and #==.
|
15
|
+
#
|
16
|
+
# A block may be given to determine what elements in NEW are to be ignored.
|
17
|
+
# This can be used to, for example, ignore whitespace differences.
|
18
|
+
#
|
19
|
+
# @param [#each, #[]] old
|
20
|
+
# @param [#each, #[]] new
|
21
|
+
# @yield [?]
|
22
|
+
# @yieldparam element
|
23
|
+
# @yieldreturn [Boolean]
|
24
|
+
Value(:old, :new, :'&ignorable')
|
25
|
+
include Enumerable
|
26
|
+
|
27
|
+
# @overload
|
28
|
+
# Enumerates the matches between the two sequences. There’ll always be at
|
29
|
+
# least one match yielded, the {Match#empty? empty} one at the end of the
|
30
|
+
# sequences.
|
31
|
+
#
|
32
|
+
# @yieldparam [Match] match
|
33
|
+
# @overload
|
34
|
+
# @return [Enumerator<Match>] An Enumerator over the matches between the
|
35
|
+
# two sequences
|
36
|
+
def each
|
37
|
+
return enum_for(__method__) unless block_given?
|
38
|
+
current = Lookout::Diff::Match.new(Lookout::Diff::Slice.new(old, 0...0),
|
39
|
+
Lookout::Diff::Slice.new(new, 0...0))
|
40
|
+
stack = [Position.origin(old, new, &ignorable)]
|
41
|
+
until stack.empty?
|
42
|
+
case item = stack.pop
|
43
|
+
when Position
|
44
|
+
match = item.match
|
45
|
+
next if match.empty?
|
46
|
+
stack.push item.begin_after(match) if item.end_after? match
|
47
|
+
stack.push match
|
48
|
+
stack.push item.end_before(match) if item.begin_before? match
|
49
|
+
when Lookout::Diff::Match
|
50
|
+
if current.touch? item
|
51
|
+
current += item
|
52
|
+
else
|
53
|
+
yield current unless current.empty?
|
54
|
+
current = item
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
yield current unless current.empty?
|
59
|
+
yield current.at(old.size...old.size, new.size...new.size)
|
60
|
+
self
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
# Keeps track of a position into the two sequences currently being “diffed” of
|
4
|
+
# the difflib algorithm and generates matches and new positions based on this
|
5
|
+
# position.
|
6
|
+
#
|
7
|
+
# @private
|
8
|
+
class Lookout::Diff::Algorithms::Difflib::Position
|
9
|
+
Value(:old, :new, :junk)
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def origin(old, new)
|
13
|
+
new = New.new(new)
|
14
|
+
new(Lookout::Diff::Slice.new(old),
|
15
|
+
new,
|
16
|
+
block_given? ? new.indexes.reduce({}){ |j, (k, _)| j[k] = yield(k); j } : {})
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def match; junk.empty? ? leftmost_longest : expand(expand(leftmost_longest, false), true) end
|
21
|
+
def begin_before?(match) old.begin_before? match.old and new.begin_before? match.new end
|
22
|
+
def end_after?(match) old.end_after? match.old and new.end_after? match.new end
|
23
|
+
def begin_after(match) self.class.new(old.begin_after(match.old), new.begin_after(match.new), junk) end
|
24
|
+
def end_before(match) self.class.new(old.end_before(match.old), new.end_before(match.new), junk) end
|
25
|
+
def inspect; '#<%s %p,%p>' % [self.class, old, new] end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def leftmost_longest
|
30
|
+
match = Lookout::Diff::Match.new(@old.at(0...0), @new.at(0...0))
|
31
|
+
sizes = Hash.new(0)
|
32
|
+
@old.each_with_index do |item, old|
|
33
|
+
_sizes = Hash.new(0)
|
34
|
+
@new.each_index(item) do |new|
|
35
|
+
size = _sizes[new] = sizes[new - 1] + 1
|
36
|
+
match = match.at(old - size + 1..old,
|
37
|
+
new - size + 1..new) if size > match.size
|
38
|
+
end unless junk[item]
|
39
|
+
sizes = _sizes
|
40
|
+
end
|
41
|
+
match
|
42
|
+
end
|
43
|
+
|
44
|
+
def expand(match, junking)
|
45
|
+
old_begin, new_begin = match.old.begin, match.new.begin
|
46
|
+
while old_begin > old.begin and new_begin > new.begin and
|
47
|
+
junk[new[new_begin - 1]] ^ !junking and
|
48
|
+
old[old_begin - 1] == new[new_begin - 1]
|
49
|
+
old_begin -= 1
|
50
|
+
new_begin -= 1
|
51
|
+
end
|
52
|
+
|
53
|
+
old_end, new_end = match.old.end, match.new.end
|
54
|
+
while old_end + 1 <= old.end and new_end + 1 <= new.end and
|
55
|
+
junk[new[new_end + 1]] ^ !junking and
|
56
|
+
old[old_end + 1] == new[new_end + 1]
|
57
|
+
old_end += 1
|
58
|
+
new_end += 1
|
59
|
+
end
|
60
|
+
|
61
|
+
match.at(old_begin..old_end, new_begin..new_end)
|
62
|
+
end
|
63
|
+
end
|