lookout 2.0.1

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.
Files changed (118) hide show
  1. data/README +645 -0
  2. data/Rakefile +9 -0
  3. data/lib/lookout.rb +34 -0
  4. data/lib/lookout/aphonic.rb +40 -0
  5. data/lib/lookout/benchmark.rb +11 -0
  6. data/lib/lookout/diff.rb +10 -0
  7. data/lib/lookout/diff/algorithms.rb +5 -0
  8. data/lib/lookout/diff/algorithms/difflib.rb +38 -0
  9. data/lib/lookout/diff/algorithms/difflib/position.rb +92 -0
  10. data/lib/lookout/diff/algorithms/difflib/position/to.rb +47 -0
  11. data/lib/lookout/diff/formats.rb +7 -0
  12. data/lib/lookout/diff/formats/hash.rb +53 -0
  13. data/lib/lookout/diff/formats/inline.rb +39 -0
  14. data/lib/lookout/diff/formats/unified.rb +57 -0
  15. data/lib/lookout/diff/group.rb +61 -0
  16. data/lib/lookout/diff/groups.rb +34 -0
  17. data/lib/lookout/diff/match.rb +36 -0
  18. data/lib/lookout/diff/operation.rb +33 -0
  19. data/lib/lookout/diff/operations.rb +36 -0
  20. data/lib/lookout/diff/operations/delete.rb +9 -0
  21. data/lib/lookout/diff/operations/equal.rb +27 -0
  22. data/lib/lookout/diff/operations/insert.rb +9 -0
  23. data/lib/lookout/diff/operations/replace.rb +9 -0
  24. data/lib/lookout/diff/range.rb +91 -0
  25. data/lib/lookout/equality.rb +178 -0
  26. data/lib/lookout/expectation.rb +50 -0
  27. data/lib/lookout/expectations.rb +62 -0
  28. data/lib/lookout/expectations/behavior.rb +20 -0
  29. data/lib/lookout/expectations/state.rb +29 -0
  30. data/lib/lookout/mock.rb +18 -0
  31. data/lib/lookout/mock/method.rb +70 -0
  32. data/lib/lookout/mock/method/arguments.rb +33 -0
  33. data/lib/lookout/mock/method/arguments/any.rb +11 -0
  34. data/lib/lookout/mock/method/arguments/anything.rb +11 -0
  35. data/lib/lookout/mock/method/arguments/list.rb +15 -0
  36. data/lib/lookout/mock/method/arguments/none.rb +11 -0
  37. data/lib/lookout/mock/method/arguments/one.rb +11 -0
  38. data/lib/lookout/mock/method/calls.rb +11 -0
  39. data/lib/lookout/mock/method/calls/class.rb +21 -0
  40. data/lib/lookout/mock/method/calls/exactly.rb +28 -0
  41. data/lib/lookout/mock/method/calls/instance.rb +25 -0
  42. data/lib/lookout/mock/method/calls/lower.rb +22 -0
  43. data/lib/lookout/mock/method/calls/upper.rb +22 -0
  44. data/lib/lookout/mock/methods.rb +12 -0
  45. data/lib/lookout/mock/object.rb +12 -0
  46. data/lib/lookout/object.rb +11 -0
  47. data/lib/lookout/output.rb +21 -0
  48. data/lib/lookout/rake/tasks.rb +36 -0
  49. data/lib/lookout/rake/tasks/gem.rb +49 -0
  50. data/lib/lookout/rake/tasks/tags.rb +16 -0
  51. data/lib/lookout/rake/tasks/test.rb +46 -0
  52. data/lib/lookout/rake/tasks/test/loader.rb +19 -0
  53. data/lib/lookout/recorder.rb +45 -0
  54. data/lib/lookout/recorder/not.rb +11 -0
  55. data/lib/lookout/recorder/tape.rb +21 -0
  56. data/lib/lookout/recorders.rb +6 -0
  57. data/lib/lookout/recorders/reception.rb +47 -0
  58. data/lib/lookout/recorders/state.rb +35 -0
  59. data/lib/lookout/result.rb +23 -0
  60. data/lib/lookout/results.rb +46 -0
  61. data/lib/lookout/results/error.rb +18 -0
  62. data/lib/lookout/results/error/exception.rb +36 -0
  63. data/lib/lookout/results/error/exception/backtrace.rb +41 -0
  64. data/lib/lookout/results/failure.rb +16 -0
  65. data/lib/lookout/results/failures.rb +6 -0
  66. data/lib/lookout/results/failures/behavior.rb +4 -0
  67. data/lib/lookout/results/failures/state.rb +4 -0
  68. data/lib/lookout/results/fulfilled.rb +9 -0
  69. data/lib/lookout/runners.rb +5 -0
  70. data/lib/lookout/runners/console.rb +22 -0
  71. data/lib/lookout/stub.rb +16 -0
  72. data/lib/lookout/stub/method.rb +105 -0
  73. data/lib/lookout/stub/methods.rb +18 -0
  74. data/lib/lookout/stub/object.rb +11 -0
  75. data/lib/lookout/ui.rb +7 -0
  76. data/lib/lookout/ui/console.rb +36 -0
  77. data/lib/lookout/ui/silent.rb +12 -0
  78. data/lib/lookout/version.rb +5 -0
  79. data/lib/lookout/xml.rb +17 -0
  80. data/test/unit/examples.rb +169 -0
  81. data/test/unit/lookout.rb +7 -0
  82. data/test/unit/lookout/diff.rb +4 -0
  83. data/test/unit/lookout/diff/algorithms/difflib.rb +56 -0
  84. data/test/unit/lookout/diff/algorithms/difflib/position.rb +92 -0
  85. data/test/unit/lookout/diff/algorithms/difflib/position/to.rb +12 -0
  86. data/test/unit/lookout/diff/formats/inline.rb +17 -0
  87. data/test/unit/lookout/diff/formats/unified.rb +67 -0
  88. data/test/unit/lookout/diff/group.rb +4 -0
  89. data/test/unit/lookout/diff/groups.rb +102 -0
  90. data/test/unit/lookout/diff/match.rb +5 -0
  91. data/test/unit/lookout/diff/operations.rb +22 -0
  92. data/test/unit/lookout/diff/operations/delete.rb +45 -0
  93. data/test/unit/lookout/diff/operations/equal.rb +45 -0
  94. data/test/unit/lookout/diff/operations/insert.rb +45 -0
  95. data/test/unit/lookout/diff/operations/replace.rb +45 -0
  96. data/test/unit/lookout/diff/range.rb +50 -0
  97. data/test/unit/lookout/equality.rb +113 -0
  98. data/test/unit/lookout/expectation.rb +39 -0
  99. data/test/unit/lookout/expectations.rb +58 -0
  100. data/test/unit/lookout/expectations/behavior.rb +35 -0
  101. data/test/unit/lookout/expectations/state.rb +29 -0
  102. data/test/unit/lookout/mock.rb +4 -0
  103. data/test/unit/lookout/mock/method.rb +143 -0
  104. data/test/unit/lookout/mock/method/arguments.rb +57 -0
  105. data/test/unit/lookout/mock/method/arguments/any.rb +11 -0
  106. data/test/unit/lookout/recorder.rb +11 -0
  107. data/test/unit/lookout/results.rb +30 -0
  108. data/test/unit/lookout/results/error.rb +7 -0
  109. data/test/unit/lookout/results/failures/behavior.rb +7 -0
  110. data/test/unit/lookout/results/failures/state.rb +7 -0
  111. data/test/unit/lookout/results/fulfilled.rb +7 -0
  112. data/test/unit/lookout/runners/console.rb +4 -0
  113. data/test/unit/lookout/stub.rb +4 -0
  114. data/test/unit/lookout/stub/method.rb +48 -0
  115. data/test/unit/lookout/ui/formatters/exception.rb +5 -0
  116. data/test/unit/lookout/ui/formatters/exception/backtrace.rb +11 -0
  117. data/test/unit/lookout/xml.rb +55 -0
  118. metadata +496 -0
@@ -0,0 +1,12 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ class Lookout::UI::Silent
4
+ def start
5
+ end
6
+
7
+ def report(result)
8
+ end
9
+
10
+ def summarize(results, time)
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ module Lookout
4
+ Version = '2.0.1'
5
+ end
@@ -0,0 +1,17 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ class Lookout::XML < String
4
+ def ==(other)
5
+ not normalize(other).index(normalize).nil?
6
+ end
7
+
8
+ def inspect
9
+ 'xml(%s)' % [normalize]
10
+ end
11
+
12
+ private
13
+
14
+ def normalize(xml = self)
15
+ xml.strip.gsub(/>\s*</, '><')
16
+ end
17
+ end
@@ -0,0 +1,169 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ # State-based Expectations
5
+
6
+ # Determine if the result equals a value.
7
+ expect 2 do
8
+ 1 + 1
9
+ end
10
+
11
+ # Determine if the result, retrieved through a stub, equals a value.
12
+ expect 2 do
13
+ Object.new.tap{ |o| stub(o).two{ 2 } }.two
14
+ end
15
+
16
+ # Match against a Regexp. Please note the use of parentheses to silence
17
+ # warnings.
18
+ expect(/a string/) do
19
+ 'a string'
20
+ end
21
+
22
+ # Match inside a Range.
23
+ expect 1..5 do
24
+ 3
25
+ end
26
+
27
+ # Verify that the result is an Enumerable.
28
+ expect Enumerable do
29
+ []
30
+ end
31
+
32
+ # Verify that the result is a String.
33
+ expect String do
34
+ 'a string'
35
+ end
36
+
37
+ # Determine equality of modules.
38
+ expect Enumerable do
39
+ Enumerable
40
+ end
41
+
42
+ # Determine equality of classes.
43
+ expect String do
44
+ String
45
+ end
46
+
47
+ # Verify that the result is truthful.
48
+ expect true do
49
+ 1
50
+ end
51
+
52
+ # Verify that the result is “falseful”.
53
+ expect false do
54
+ nil
55
+ end
56
+
57
+ # Verify that the result is actually true.
58
+ expect TrueClass do
59
+ true
60
+ end
61
+
62
+ # Verify that the result is actually false.
63
+ expect FalseClass do
64
+ false
65
+ end
66
+
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
+
72
+ # Match XML contents, ignoring whitespace between tags.
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
85
+
86
+ # Verify that the given text is output.
87
+ expect output("abc\ndef\n") do |io|
88
+ io.puts 'abc', 'def'
89
+ end
90
+
91
+ # Verify that an exception is raised.
92
+ expect NoMethodError do
93
+ Object.no_method
94
+ end
95
+
96
+ # Verify that an exception with a specific message is raised.
97
+ expect StandardError.new('message') do
98
+ raise StandardError.new('message')
99
+ end
100
+
101
+ # Verify that an exception with a message matching a given Regexp is raised.
102
+ expect StandardError.new(/mess/) do
103
+ raise StandardError.new('message')
104
+ end
105
+
106
+ # State-based Fluent Boolean Expectations
107
+
108
+ # Expect an object to “be” something.
109
+ expect(Class.new{ attr_accessor :running }.new.to.be.running) do |process|
110
+ process.running = true
111
+ end
112
+
113
+ # Expect an object to “have” something.
114
+ expect(Class.new{ attr_accessor :finished }.new.to.have.finished) do |process|
115
+ process.finished = true
116
+ end
117
+
118
+ # Expect nil to respond to #nil?.
119
+ expect nil.to.respond_to? :nil?
120
+
121
+ # Expect nil to be nil.
122
+ expect nil.to.be.nil?
123
+
124
+ # Expect Object not to be nil.
125
+ expect Object.not.to.be.nil?
126
+
127
+ # Behavior-based Expectations
128
+
129
+ # Use a mock to verify that a method is called appropriately.
130
+ expect mock.to.receive.dial('2125551212').twice do |phone|
131
+ phone.dial('2125551212')
132
+ phone.dial('2125551212')
133
+ end
134
+
135
+ # Use a stub that ignores all calls to verify that a method is called
136
+ # appropriately. Any other calls made are ignored.
137
+ expect stub.to.receive.dial('2125551212').twice do |phone|
138
+ phone.dial('2125551212')
139
+ phone.hangup
140
+ phone.dial('2125551212')
141
+ end
142
+
143
+ # Use a stub that’s set up with a set of methods.
144
+ expect 3 do
145
+ s = stub(:a => 1, :b => 2)
146
+ s.a + s.b
147
+ end
148
+
149
+ # Use a contrete mock to verify that a method is called.
150
+ expect Object.to.receive.deal do
151
+ Object.deal
152
+ end
153
+
154
+ # Expect a new object to receive #deal with any arguments.
155
+ expect Object.new.to.receive.deal do |o|
156
+ o.deal(1, 2, 3)
157
+ end
158
+
159
+ # Expect a new object to receive #deal without arguments.
160
+ expect Object.new.to.receive.deal(without_arguments) do |o|
161
+ o.deal
162
+ end
163
+
164
+ # Expect a new object to receive #deal with any argument, 1, and any
165
+ # argument.
166
+ expect Object.new.to.receive.deal(arg, 1, arg) do |o|
167
+ o.deal :a, 1, :b
168
+ end
169
+ end
@@ -0,0 +1,7 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ expect Lookout.runner.to.receive.expectations_eval do
5
+ Expectations{ }
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ end
@@ -0,0 +1,56 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ expect [Lookout::Diff::Match.new(Lookout::Diff::Range.new('abxcd', 0..1),
5
+ Lookout::Diff::Range.new('abcd', 0..1)),
6
+ Lookout::Diff::Match.new(Lookout::Diff::Range.new('abxcd', 3..4),
7
+ Lookout::Diff::Range.new('abcd', 2..3)),
8
+ Lookout::Diff::Match.new(Lookout::Diff::Range.new('abxcd', 5...5),
9
+ Lookout::Diff::Range.new('abcd', 4...4))] do
10
+ Lookout::Diff::Algorithms::Difflib.new('abxcd', 'abcd').to_a
11
+ end
12
+
13
+ expect [Lookout::Diff::Match.new(Lookout::Diff::Range.new('acbxcd', 0..0),
14
+ Lookout::Diff::Range.new('aybcd', 0..0)),
15
+ Lookout::Diff::Match.new(Lookout::Diff::Range.new('acbxcd', 2..2),
16
+ Lookout::Diff::Range.new('aybcd', 2..2)),
17
+ Lookout::Diff::Match.new(Lookout::Diff::Range.new('acbxcd', 4..5),
18
+ Lookout::Diff::Range.new('aybcd', 3..4)),
19
+ Lookout::Diff::Match.new(Lookout::Diff::Range.new('acbxcd', 6...6),
20
+ Lookout::Diff::Range.new('aybcd', 5...5))] do
21
+ Lookout::Diff::Algorithms::Difflib.new('acbxcd', 'aybcd').to_a
22
+ end
23
+
24
+ expect [Lookout::Diff::Match.new(Lookout::Diff::Range.new('qabxcd', 1..2),
25
+ Lookout::Diff::Range.new('abycdf', 0..1)),
26
+ Lookout::Diff::Match.new(Lookout::Diff::Range.new('qabxcd', 4..5),
27
+ Lookout::Diff::Range.new('abycdf', 3..4)),
28
+ Lookout::Diff::Match.new(Lookout::Diff::Range.new('qabxcd', 6...6),
29
+ Lookout::Diff::Range.new('abycdf', 6...6))] do
30
+ Lookout::Diff::Algorithms::Difflib.new('qabxcd', 'abycdf').to_a
31
+ end
32
+
33
+ expect [Lookout::Diff::Match.new(Lookout::Diff::Range.new('abxcd', 0..1),
34
+ Lookout::Diff::Range.new('abcd', 0..1)),
35
+ Lookout::Diff::Match.new(Lookout::Diff::Range.new('abxcd', 3..4),
36
+ Lookout::Diff::Range.new('abcd', 2..3)),
37
+ Lookout::Diff::Match.new(Lookout::Diff::Range.new('abxcd', 5...5),
38
+ Lookout::Diff::Range.new('abcd', 4...4)),] do
39
+ Lookout::Diff::Algorithms::Difflib.new('abxcd', 'abcd').to_a
40
+ end
41
+
42
+ # 0, 0, 8
43
+ # 8, 17, 21
44
+ # 29, 38, 0
45
+ expect [Lookout::Diff::Match.new(Lookout::Diff::Range.new('private Thread currentThread;', 0..7),
46
+ Lookout::Diff::Range.new('private volatile Thread currentThread;', 0..7)),
47
+ Lookout::Diff::Match.new(Lookout::Diff::Range.new('private Thread currentThread;', 8..28),
48
+ Lookout::Diff::Range.new('private volatile Thread currentThread;', 17..37)),
49
+ Lookout::Diff::Match.new(Lookout::Diff::Range.new('private Thread currentThread;', 29...29),
50
+ Lookout::Diff::Range.new('private volatile Thread currentThread;', 38...38))] do
51
+ Lookout::Diff::Algorithms::Difflib.new('private Thread currentThread;',
52
+ 'private volatile Thread currentThread;'){ |c|
53
+ c == ' '[0]
54
+ }.to_a
55
+ end
56
+ end
@@ -0,0 +1,92 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ expect Lookout::Diff::Match.new(Lookout::Diff::Range.new('abc', 0...0),
5
+ Lookout::Diff::Range.new('xyz', 0...0)) do
6
+ Lookout::Diff::Algorithms::Difflib::Position.origin('abc', 'xyz').match
7
+ end
8
+
9
+ expect Lookout::Diff::Match.new(Lookout::Diff::Range.new('abc'),
10
+ Lookout::Diff::Range.new('abc')) do
11
+ Lookout::Diff::Algorithms::Difflib::Position.origin('abc', 'abc').match
12
+ end
13
+
14
+ expect Lookout::Diff::Match.new(Lookout::Diff::Range.new('Xabc', 1..3),
15
+ Lookout::Diff::Range.new('abc')) do
16
+ Lookout::Diff::Algorithms::Difflib::Position.origin('Xabc', 'abc').match
17
+ end
18
+
19
+ expect Lookout::Diff::Match.new(Lookout::Diff::Range.new('abcX', 0..2),
20
+ Lookout::Diff::Range.new('abc')) do
21
+ Lookout::Diff::Algorithms::Difflib::Position.origin('abcX', 'abc').match
22
+ end
23
+
24
+ expect Lookout::Diff::Match.new(Lookout::Diff::Range.new('abc'),
25
+ Lookout::Diff::Range.new('Xabc', 1..3)) do
26
+ Lookout::Diff::Algorithms::Difflib::Position.origin('abc', 'Xabc').match
27
+ end
28
+
29
+ expect Lookout::Diff::Match.new(Lookout::Diff::Range.new('abc'),
30
+ Lookout::Diff::Range.new('abcX', 0..2)) do
31
+ Lookout::Diff::Algorithms::Difflib::Position.origin('abc', 'abcX').match
32
+ end
33
+
34
+ expect Lookout::Diff::Match.new(Lookout::Diff::Range.new('ab', 0..1),
35
+ Lookout::Diff::Range.new('abXabc', 0..1)) do
36
+ Lookout::Diff::Algorithms::Difflib::Position.origin('ab', 'abXabc').match
37
+ end
38
+
39
+ expect Lookout::Diff::Match.new(Lookout::Diff::Range.new('abc'),
40
+ Lookout::Diff::Range.new('abXabc', 3..5)) do
41
+ Lookout::Diff::Algorithms::Difflib::Position.origin('abc', 'abXabc').match
42
+ end
43
+
44
+ expect Lookout::Diff::Match.new(Lookout::Diff::Range.new(' abc', 1..3),
45
+ Lookout::Diff::Range.new('abc abc', 0..2)) do
46
+ Lookout::Diff::Algorithms::Difflib::Position.origin(' abc', 'abc abc'){ |c| c == ' '[0] }.match
47
+ end
48
+
49
+ # TODO: Need more tests for is_junk.
50
+
51
+ expect false do
52
+ Lookout::Diff::Algorithms::Difflib::Position.origin('abc', 'abc').
53
+ begins_before? Lookout::Diff::Match.new(Lookout::Diff::Range.new('abc', 0..0),
54
+ Lookout::Diff::Range.new('abc', 0..0))
55
+ end
56
+
57
+ expect true do
58
+ Lookout::Diff::Algorithms::Difflib::Position.origin('abc', 'abc').
59
+ begins_before? Lookout::Diff::Match.new(Lookout::Diff::Range.new('abc', 1..1),
60
+ Lookout::Diff::Range.new('abc', 1..1))
61
+ end
62
+
63
+ expect false do
64
+ Lookout::Diff::Algorithms::Difflib::Position.origin('abc', 'abc').
65
+ ends_after? Lookout::Diff::Match.new(Lookout::Diff::Range.new('abc', 3..3),
66
+ Lookout::Diff::Range.new('abc', 3..3))
67
+ end
68
+
69
+ expect true do
70
+ Lookout::Diff::Algorithms::Difflib::Position.origin('abc', 'abc').
71
+ ends_after? Lookout::Diff::Match.new(Lookout::Diff::Range.new('abc', 1..1),
72
+ Lookout::Diff::Range.new('abc', 1..1))
73
+ end
74
+
75
+ expect Lookout::Diff::Algorithms::Difflib::Position.
76
+ new(Lookout::Diff::Range.new('dabcX', 4..4),
77
+ Lookout::Diff::Algorithms::Difflib::Position::To.new('ddabcY', 5..5),
78
+ {}) do
79
+ Lookout::Diff::Algorithms::Difflib::Position.origin('dabcX', 'ddabcY').
80
+ begin_after(Lookout::Diff::Match.new(Lookout::Diff::Range.new('dabcX', 0..3),
81
+ Lookout::Diff::Range.new('ddabcY', 1..4)))
82
+ end
83
+
84
+ expect Lookout::Diff::Algorithms::Difflib::Position.
85
+ new(Lookout::Diff::Range.new('dabcX', 0...0),
86
+ Lookout::Diff::Algorithms::Difflib::Position::To.new('ddabcY', 0..0),
87
+ {}) do
88
+ Lookout::Diff::Algorithms::Difflib::Position.origin('dabcX', 'ddabcY').
89
+ end_before(Lookout::Diff::Match.new(Lookout::Diff::Range.new('dabcX', 0..3),
90
+ Lookout::Diff::Range.new('ddabcY', 1..4)))
91
+ end
92
+ end
@@ -0,0 +1,12 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ expect [0, 2] do
5
+ result = []
6
+ Lookout::Diff::Algorithms::Difflib::Position::To.
7
+ new(%w[a b a]).each_index('a') do |index|
8
+ result << index
9
+ end
10
+ result
11
+ end
12
+ end
@@ -0,0 +1,17 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ expect 'one two three' do
5
+ Lookout::Diff::Formats::Inline.
6
+ new(Lookout::Diff::Operations.
7
+ new(Lookout::Diff::Algorithms::Difflib.new('one two three',
8
+ 'one two three'))).to_s
9
+ end
10
+
11
+ expect 'one t[-w-]{+o+}o three' do
12
+ Lookout::Diff::Formats::Inline.
13
+ new(Lookout::Diff::Operations.
14
+ new(Lookout::Diff::Algorithms::Difflib.new('one two three',
15
+ 'one too three'))).to_s
16
+ end
17
+ end
@@ -0,0 +1,67 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ expect '' do
5
+ Lookout::Diff::Formats::Unified.
6
+ new(Lookout::Diff::Groups.
7
+ new(Lookout::Diff::Operations.
8
+ new(Lookout::Diff::Algorithms::Difflib.
9
+ new(%w[one two three],
10
+ %w[one two three])))).to_a.join("\n")
11
+ end
12
+
13
+ expect <<EOD.chomp do
14
+ @@ -1,4 +1,4 @@
15
+ +zero
16
+ one
17
+ -two
18
+ -three
19
+ +tree
20
+ four
21
+ EOD
22
+ Lookout::Diff::Formats::Unified.
23
+ new(Lookout::Diff::Groups.
24
+ new(Lookout::Diff::Operations.
25
+ new(Lookout::Diff::Algorithms::Difflib.
26
+ new(%w[one two three four],
27
+ %w[zero one tree four])))).to_a.join("\n")
28
+ end
29
+
30
+ expect <<EOD.chomp do
31
+ @@ -1,4 +1,4 @@
32
+ -two
33
+ +too
34
+ 1
35
+ 2
36
+ 3
37
+ EOD
38
+ Lookout::Diff::Formats::Unified.
39
+ new(Lookout::Diff::Groups.
40
+ new(Lookout::Diff::Operations.
41
+ new(Lookout::Diff::Algorithms::Difflib.
42
+ new(%w[two 1 2 3 4 5 6 7 8],
43
+ %w[too 1 2 3 4 5 6 7 8])))).to_a.join("\n")
44
+ end
45
+
46
+ expect <<EOD.chomp do
47
+ @@ -1,4 +1,4 @@
48
+ -two
49
+ +too
50
+ 1
51
+ 2
52
+ 3
53
+ @@ -7,4 +7,4 @@
54
+ 6
55
+ 7
56
+ 8
57
+ -one
58
+ +tre
59
+ EOD
60
+ Lookout::Diff::Formats::Unified.
61
+ new(Lookout::Diff::Groups.
62
+ new(Lookout::Diff::Operations.
63
+ new(Lookout::Diff::Algorithms::Difflib.
64
+ new(%w[two 1 2 3 4 5 6 7 8 one],
65
+ %w[too 1 2 3 4 5 6 7 8 tre])))).to_a.join("\n")
66
+ end
67
+ end