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
@@ -1,16 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
class Lookout::Equalities::Warning < Lookout::Equalities::String
|
4
|
-
Lookout::Equality.register self, Lookout::Warning
|
5
|
-
|
6
|
-
def equal?(expected, actual)
|
7
|
-
expected == actual.chomp or
|
8
|
-
actual =~ /\A.*?:\d+: warning: #{Regexp.escape(expected)}\Z/u
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def format(expected, actual)
|
14
|
-
'%p≠%p' % [Lookout::Warning.new(actual), expected]
|
15
|
-
end
|
16
|
-
end
|
data/lib/lookout/equality.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
module Lookout::Equality
|
4
|
-
class << self
|
5
|
-
def register(equality, *types)
|
6
|
-
eq = equality.new
|
7
|
-
types.each do |type|
|
8
|
-
equalities[type] = eq
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def equal?(expected, actual)
|
13
|
-
self[expected].equal? expected, actual
|
14
|
-
end
|
15
|
-
|
16
|
-
def message(expected, actual)
|
17
|
-
self[expected].message expected, actual
|
18
|
-
end
|
19
|
-
|
20
|
-
def diff(expected, actual)
|
21
|
-
self[expected].diff expected, actual
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def [](expected)
|
27
|
-
equalities[expected.class.ancestors.find{ |type| equalities[type] }]
|
28
|
-
end
|
29
|
-
|
30
|
-
def equalities
|
31
|
-
@equalities ||= {}
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
require 'lookout/equalities'
|
36
|
-
end
|
data/lib/lookout/expectation.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
module Lookout::Expectation
|
4
|
-
def self.on(expected, file, line, &block)
|
5
|
-
case expected
|
6
|
-
when Lookout::Recorder
|
7
|
-
Lookout::Expectations::Behavior
|
8
|
-
when Lookout::Warning
|
9
|
-
Lookout::Expectations::State::Warning
|
10
|
-
else
|
11
|
-
Lookout::Expectations::State
|
12
|
-
end.new(expected, file, line, &block)
|
13
|
-
end
|
14
|
-
|
15
|
-
def initialize(expected, file, line, &block)
|
16
|
-
@expected, @file, @line, @block = expected, file, line, block
|
17
|
-
end
|
18
|
-
|
19
|
-
def evaluate
|
20
|
-
Lookout::Stub.methods{ |stubs| @stubs = stubs; evaluate_with_stubs }.tap{ @stubs = nil }
|
21
|
-
end
|
22
|
-
|
23
|
-
def stub(*args)
|
24
|
-
raise ArgumentError,
|
25
|
-
'wrong number of arguments (%d for 1)' % args.length unless args.count < 2
|
26
|
-
return Lookout::Stub::Object.new if args.length < 1
|
27
|
-
case args[0]
|
28
|
-
when Hash
|
29
|
-
Lookout::Stub::Object.new.tap{ |stub|
|
30
|
-
args[0].each do |name, value|
|
31
|
-
if value.respond_to? :to_proc
|
32
|
-
@stubs.define(stub, name, &value)
|
33
|
-
else
|
34
|
-
@stubs.define(stub, name){ value }
|
35
|
-
end
|
36
|
-
end
|
37
|
-
}
|
38
|
-
else
|
39
|
-
Method.new(@stubs, args[0])
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def with_verbose(verbose = true)
|
44
|
-
saved_verbose = $VERBOSE
|
45
|
-
$VERBOSE = verbose
|
46
|
-
begin
|
47
|
-
yield
|
48
|
-
ensure
|
49
|
-
$VERBOSE = saved_verbose
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
attr_reader :file, :line
|
54
|
-
|
55
|
-
private
|
56
|
-
|
57
|
-
class Method < Lookout::Aphonic
|
58
|
-
undef extend
|
59
|
-
undef is_a?
|
60
|
-
|
61
|
-
def initialize(stubs, object)
|
62
|
-
@stubs, @object = stubs, object
|
63
|
-
end
|
64
|
-
|
65
|
-
def method_missing(method, &body)
|
66
|
-
@stubs.define(@object, method, &body)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
data/lib/lookout/expectations.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
class Lookout::Expectations
|
4
|
-
autoload :Behavior, 'lookout/expectations/behavior'
|
5
|
-
autoload :Line, 'lookout/expectations/line'
|
6
|
-
autoload :State, 'lookout/expectations/state'
|
7
|
-
|
8
|
-
def initialize(results = Lookout::Results.new)
|
9
|
-
@results = results
|
10
|
-
end
|
11
|
-
|
12
|
-
def mock
|
13
|
-
Lookout::Mock::Object.new
|
14
|
-
end
|
15
|
-
|
16
|
-
def arg
|
17
|
-
Lookout::Mock::Method::Arguments::Anything.new
|
18
|
-
end
|
19
|
-
|
20
|
-
def without_arguments
|
21
|
-
Lookout::Mock::Method::Arguments::None.new
|
22
|
-
end
|
23
|
-
|
24
|
-
def stub
|
25
|
-
Lookout::Stub::Object.new
|
26
|
-
end
|
27
|
-
|
28
|
-
def output(string)
|
29
|
-
Lookout::Output.new(string)
|
30
|
-
end
|
31
|
-
|
32
|
-
def warning(string)
|
33
|
-
Lookout::Warning.new(string)
|
34
|
-
end
|
35
|
-
|
36
|
-
def xml(string)
|
37
|
-
Lookout::XML.new(string)
|
38
|
-
end
|
39
|
-
|
40
|
-
def expect(expected, &block)
|
41
|
-
@results << Lookout::Expectation.on(expected, *Lookout.location(caller.first), &block).evaluate
|
42
|
-
self
|
43
|
-
end
|
44
|
-
|
45
|
-
# TODO: It would be great if this method wasn’t necessary.
|
46
|
-
def flush
|
47
|
-
self
|
48
|
-
end
|
49
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
class Lookout::Expectations::Behavior
|
4
|
-
include Lookout::Expectation
|
5
|
-
|
6
|
-
def evaluate_with_stubs
|
7
|
-
Lookout::Mock.methods do |mocks|
|
8
|
-
@expected.subject! mocks, @stubs
|
9
|
-
instance_exec @expected.subject, &@block if @block
|
10
|
-
@expected.verify
|
11
|
-
end
|
12
|
-
Lookout::Results::Fulfilled.new(file, line)
|
13
|
-
rescue Lookout::Recorders::State::Error => e
|
14
|
-
Lookout::Results::Failures::State.new(file, line, e.message)
|
15
|
-
rescue Lookout::Mock::Error => e
|
16
|
-
Lookout::Results::Failures::Behavior.new(file, line, e.message)
|
17
|
-
rescue Exception => e
|
18
|
-
Lookout::Results::Error.new(file, line, nil, e)
|
19
|
-
end
|
20
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
class Lookout::Expectations::Line < Lookout::Expectations
|
4
|
-
def initialize(line, results = Lookout::Results.new)
|
5
|
-
super results
|
6
|
-
@line = line
|
7
|
-
@previous = nil
|
8
|
-
@ran_previous = false
|
9
|
-
end
|
10
|
-
|
11
|
-
def expect(expected)
|
12
|
-
return self if @ran_previous
|
13
|
-
expectation = Lookout::Expectation.on(expected, *Lookout.location(caller.first), &Proc.new)
|
14
|
-
if @previous and @previous.line <= @line and expectation.line > @line
|
15
|
-
flush
|
16
|
-
@previous = nil
|
17
|
-
@ran_previous = true
|
18
|
-
else
|
19
|
-
@previous = expectation
|
20
|
-
end
|
21
|
-
self
|
22
|
-
end
|
23
|
-
|
24
|
-
# TODO: It would be great if this method wasn’t necessary.
|
25
|
-
def flush
|
26
|
-
@results << @previous.evaluate if @previous
|
27
|
-
self
|
28
|
-
end
|
29
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
class Lookout::Expectations::State
|
4
|
-
autoload :Warning, 'lookout/expectations/state/warning'
|
5
|
-
|
6
|
-
include Lookout::Expectation
|
7
|
-
|
8
|
-
def evaluate_with_stubs
|
9
|
-
check(@block ? instance_exec(@expected, &@block) : false)
|
10
|
-
rescue Exception => e
|
11
|
-
return check(e) if StandardError === @expected and @expected.class == e.class
|
12
|
-
return Lookout::Results::Fulfilled.new(file, line) if @expected.eql? e.class
|
13
|
-
Lookout::Results::Error.new(file, line,
|
14
|
-
if Class === @expected and StandardError >= @expected
|
15
|
-
Lookout::Equality.message(@expected, e.class)
|
16
|
-
elsif StandardError === @expected
|
17
|
-
Lookout::Equality.message(@expected.class, e.class)
|
18
|
-
else
|
19
|
-
nil
|
20
|
-
end,
|
21
|
-
e)
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def check(actual)
|
27
|
-
(@expected == actual or Lookout::Equality.equal? @expected, actual) ?
|
28
|
-
Lookout::Results::Fulfilled.new(file, line) :
|
29
|
-
Lookout::Results::Failures::State.new(file, line, Lookout::Equality.message(@expected, actual))
|
30
|
-
end
|
31
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
require 'stringio'
|
4
|
-
|
5
|
-
class Lookout::Expectations::State::Warning < Lookout::Expectations::State
|
6
|
-
def evaluate_with_stubs
|
7
|
-
@output = StringIO.new
|
8
|
-
saved_stderr = $stderr
|
9
|
-
$stderr = @output
|
10
|
-
begin
|
11
|
-
with_verbose do
|
12
|
-
super
|
13
|
-
end
|
14
|
-
ensure
|
15
|
-
$stderr = saved_stderr
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def check(actual)
|
22
|
-
@output.rewind
|
23
|
-
|
24
|
-
super @output.read
|
25
|
-
end
|
26
|
-
end
|
data/lib/lookout/mock.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
module Lookout::Mock
|
4
|
-
autoload :Method, 'lookout/mock/method'
|
5
|
-
autoload :Methods, 'lookout/mock/methods'
|
6
|
-
autoload :Object, 'lookout/mock/object'
|
7
|
-
|
8
|
-
Error = Class.new(StandardError)
|
9
|
-
|
10
|
-
class << self
|
11
|
-
def methods
|
12
|
-
methods = Methods.new
|
13
|
-
begin
|
14
|
-
yield methods
|
15
|
-
ensure
|
16
|
-
methods.undefine
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/lib/lookout/mock/method.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
class Lookout::Mock::Method < Lookout::Stub::Method
|
4
|
-
autoload :Arguments, 'lookout/mock/method/arguments'
|
5
|
-
autoload :Calls, 'lookout/mock/method/calls'
|
6
|
-
|
7
|
-
def initialize(object, method, *args, &body)
|
8
|
-
super object, method, &body
|
9
|
-
@args = Arguments.new(*args)
|
10
|
-
at_least_once
|
11
|
-
end
|
12
|
-
|
13
|
-
def never
|
14
|
-
exactly(0)
|
15
|
-
end
|
16
|
-
|
17
|
-
def at_most_once
|
18
|
-
at_most(1)
|
19
|
-
end
|
20
|
-
|
21
|
-
def once
|
22
|
-
exactly(1)
|
23
|
-
end
|
24
|
-
|
25
|
-
def at_least_once
|
26
|
-
at_least(1)
|
27
|
-
end
|
28
|
-
|
29
|
-
def twice
|
30
|
-
exactly(2)
|
31
|
-
end
|
32
|
-
|
33
|
-
def at_most(times)
|
34
|
-
@calls = Calls::Upper.new(self, times)
|
35
|
-
self
|
36
|
-
end
|
37
|
-
|
38
|
-
def exactly(times)
|
39
|
-
@calls = Calls::Exactly.new(self, times)
|
40
|
-
self
|
41
|
-
end
|
42
|
-
|
43
|
-
def at_least(times)
|
44
|
-
@calls = Calls::Lower.new(self, times)
|
45
|
-
self
|
46
|
-
end
|
47
|
-
|
48
|
-
def call(*args, &block)
|
49
|
-
@calls.call
|
50
|
-
@args.verify(*args)
|
51
|
-
super
|
52
|
-
rescue Lookout::Mock::Error => e
|
53
|
-
raise e, '%s: %s' % [self, e]
|
54
|
-
end
|
55
|
-
|
56
|
-
def verify
|
57
|
-
@calls.verify
|
58
|
-
self
|
59
|
-
end
|
60
|
-
|
61
|
-
def to_s
|
62
|
-
'%p.%s%p' % [@object, @method, @args]
|
63
|
-
end
|
64
|
-
|
65
|
-
private
|
66
|
-
|
67
|
-
def stash
|
68
|
-
:"__mocked_method_#{@method}"
|
69
|
-
end
|
70
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
class Lookout::Mock::Method::Arguments
|
4
|
-
autoload :Any, 'lookout/mock/method/arguments/any'
|
5
|
-
autoload :Anything, 'lookout/mock/method/arguments/anything'
|
6
|
-
autoload :List, 'lookout/mock/method/arguments/list'
|
7
|
-
autoload :None, 'lookout/mock/method/arguments/none'
|
8
|
-
|
9
|
-
Error = Class.new(Lookout::Mock::Error)
|
10
|
-
|
11
|
-
def initialize(*args)
|
12
|
-
self.args = args
|
13
|
-
end
|
14
|
-
|
15
|
-
def verify(*args)
|
16
|
-
@args == args or
|
17
|
-
raise Error, 'unexpected arguments: (%s)≠(%p)' %
|
18
|
-
[args.map{ |arg| arg.inspect }.join(', '), @args]
|
19
|
-
end
|
20
|
-
|
21
|
-
def inspect
|
22
|
-
result = @args.inspect
|
23
|
-
result.empty? ? "" : '(%s)' % result
|
24
|
-
end
|
25
|
-
|
26
|
-
protected
|
27
|
-
|
28
|
-
def args=(args)
|
29
|
-
return @args = Any.new if args.empty?
|
30
|
-
none = args.find{ |arg| arg.is_a? None } and return @args = none
|
31
|
-
@args = List.new(args)
|
32
|
-
end
|
33
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
class Lookout::Mock::Method::Arguments::List
|
4
|
-
def initialize(args)
|
5
|
-
@args = args
|
6
|
-
end
|
7
|
-
|
8
|
-
def ==(other)
|
9
|
-
Lookout::Equality.equal?(@args, other)
|
10
|
-
end
|
11
|
-
|
12
|
-
def inspect
|
13
|
-
@args.map{ |arg| arg.inspect }.join(', ')
|
14
|
-
end
|
15
|
-
end
|