lookout 2.0.2 → 2.1.2

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.
@@ -17,6 +17,7 @@ module Lookout
17
17
  autoload :Stub, 'lookout/stub'
18
18
  autoload :UI, 'lookout/ui'
19
19
  autoload :Version, 'lookout/version'
20
+ autoload :Warning, 'lookout/warning'
20
21
  autoload :XML, 'lookout/xml'
21
22
 
22
23
  class << self
@@ -176,3 +176,18 @@ private
176
176
  '%p≠%p' % [Lookout::Output.new(expected.actual), expected]
177
177
  end
178
178
  end
179
+
180
+ class Lookout::Equality::Warning < Lookout::Equality::String
181
+ Lookout::Equality.register self, Lookout::Warning
182
+
183
+ def equal?(expected, actual)
184
+ expected == actual.chomp or
185
+ actual =~ /\A.*?:\d+: warning: #{Regexp.escape(expected)}\Z/u
186
+ end
187
+
188
+ private
189
+
190
+ def format(expected, actual)
191
+ '%p≠%p' % [Lookout::Warning.new(actual), expected]
192
+ end
193
+ end
@@ -2,9 +2,14 @@
2
2
 
3
3
  module Lookout::Expectation
4
4
  def self.on(expected, file, line, &block)
5
- (expected.is_a?(Lookout::Recorder) ?
6
- Lookout::Expectations::Behavior :
7
- Lookout::Expectations::State).new(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)
8
13
  end
9
14
 
10
15
  def initialize(expected, file, line, &block)
@@ -31,6 +36,16 @@ module Lookout::Expectation
31
36
  end
32
37
  end
33
38
 
39
+ def with_verbose(verbose = true)
40
+ saved_verbose = $VERBOSE
41
+ $VERBOSE = verbose
42
+ begin
43
+ yield
44
+ ensure
45
+ $VERBOSE = saved_verbose
46
+ end
47
+ end
48
+
34
49
  attr_reader :file, :line
35
50
 
36
51
  private
@@ -30,6 +30,10 @@ class Lookout::Expectations
30
30
  Lookout::Output.new(string)
31
31
  end
32
32
 
33
+ def warning(string)
34
+ Lookout::Warning.new(string)
35
+ end
36
+
33
37
  def xml(string)
34
38
  Lookout::XML.new(string)
35
39
  end
@@ -1,6 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  class Lookout::Expectations::State
4
+ autoload :Warning, 'lookout/expectations/state/warning'
5
+
4
6
  include Lookout::Expectation
5
7
 
6
8
  def evaluate_with_stubs
@@ -0,0 +1,26 @@
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
@@ -41,7 +41,7 @@ class Lookout::Rake::Tasks::Gem < Rake::TaskLib
41
41
 
42
42
  desc 'Push %s to rubygems.org' % specification.file_name
43
43
  task :push => :check do
44
- sh 'gem -%s-verbose push %s' % [verbose ? '' : '-no', specification.file_name]
44
+ sh 'gem push -%s-verbose %s' % [verbose ? '' : '-no', specification.file_name]
45
45
  end
46
46
  end
47
47
 
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  module Lookout
4
- Version = '2.0.2'
4
+ Version = '2.1.2'
5
5
  end
@@ -0,0 +1,7 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ class Lookout::Warning < String
4
+ def inspect
5
+ 'warning(%s)' % super
6
+ end
7
+ end
@@ -166,4 +166,21 @@ Expectations do
166
166
  expect Object.new.to.receive.deal(arg, 1, arg) do |o|
167
167
  o.deal :a, 1, :b
168
168
  end
169
+
170
+ # Utilities
171
+
172
+ # Use #with_verbose to set $VERBOSE during the execution of a block.
173
+ expect nil do
174
+ with_verbose(nil) do
175
+ $VERBOSE
176
+ end
177
+ end
178
+
179
+ expect warning('this is your final one!') do
180
+ warn 'this is your final one!'
181
+ end
182
+
183
+ expect warning('this is your final one!') do
184
+ warn '%s:%d: warning: this is your final one!' % [__FILE__, __LINE__]
185
+ end
169
186
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lookout
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
- - 0
8
+ - 1
9
9
  - 2
10
- version: 2.0.2
10
+ version: 2.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nikolai Weibull
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-20 00:00:00 +02:00
18
+ date: 2011-05-24 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -341,121 +341,123 @@ extensions: []
341
341
  extra_rdoc_files: []
342
342
 
343
343
  files:
344
- - lib/lookout/aphonic.rb
345
344
  - lib/lookout/benchmark.rb
346
- - lib/lookout/diff/algorithms/difflib/position/to.rb
347
- - lib/lookout/diff/algorithms/difflib/position.rb
348
- - lib/lookout/diff/algorithms/difflib.rb
345
+ - lib/lookout/diff.rb
349
346
  - lib/lookout/diff/algorithms.rb
347
+ - lib/lookout/diff/algorithms/difflib.rb
348
+ - lib/lookout/diff/algorithms/difflib/position.rb
349
+ - lib/lookout/diff/algorithms/difflib/position/to.rb
350
+ - lib/lookout/diff/formats.rb
350
351
  - lib/lookout/diff/formats/hash.rb
351
352
  - lib/lookout/diff/formats/inline.rb
352
353
  - lib/lookout/diff/formats/unified.rb
353
- - lib/lookout/diff/formats.rb
354
354
  - lib/lookout/diff/group.rb
355
355
  - lib/lookout/diff/groups.rb
356
356
  - lib/lookout/diff/match.rb
357
357
  - lib/lookout/diff/operation.rb
358
+ - lib/lookout/diff/operations.rb
358
359
  - lib/lookout/diff/operations/delete.rb
359
360
  - lib/lookout/diff/operations/equal.rb
360
361
  - lib/lookout/diff/operations/insert.rb
361
362
  - lib/lookout/diff/operations/replace.rb
362
- - lib/lookout/diff/operations.rb
363
363
  - lib/lookout/diff/range.rb
364
- - lib/lookout/diff.rb
365
- - lib/lookout/equality.rb
366
- - lib/lookout/expectation.rb
367
364
  - lib/lookout/expectations/behavior.rb
365
+ - lib/lookout/expectations/state/warning.rb
368
366
  - lib/lookout/expectations/state.rb
369
- - lib/lookout/expectations.rb
367
+ - lib/lookout/mock.rb
368
+ - lib/lookout/mock/method.rb
369
+ - lib/lookout/mock/method/arguments.rb
370
370
  - lib/lookout/mock/method/arguments/any.rb
371
371
  - lib/lookout/mock/method/arguments/anything.rb
372
372
  - lib/lookout/mock/method/arguments/list.rb
373
373
  - lib/lookout/mock/method/arguments/none.rb
374
374
  - lib/lookout/mock/method/arguments/one.rb
375
- - lib/lookout/mock/method/arguments.rb
375
+ - lib/lookout/mock/method/calls.rb
376
376
  - lib/lookout/mock/method/calls/class.rb
377
377
  - lib/lookout/mock/method/calls/exactly.rb
378
378
  - lib/lookout/mock/method/calls/instance.rb
379
379
  - lib/lookout/mock/method/calls/lower.rb
380
380
  - lib/lookout/mock/method/calls/upper.rb
381
- - lib/lookout/mock/method/calls.rb
382
- - lib/lookout/mock/method.rb
383
381
  - lib/lookout/mock/methods.rb
384
382
  - lib/lookout/mock/object.rb
385
- - lib/lookout/mock.rb
386
383
  - lib/lookout/object.rb
387
384
  - lib/lookout/output.rb
388
- - lib/lookout/rake/tasks/gem.rb
389
- - lib/lookout/rake/tasks/tags.rb
390
385
  - lib/lookout/rake/tasks/test/loader.rb
386
+ - lib/lookout/rake/tasks/tags.rb
391
387
  - lib/lookout/rake/tasks/test.rb
388
+ - lib/lookout/rake/tasks/gem.rb
392
389
  - lib/lookout/rake/tasks.rb
393
390
  - lib/lookout/recorder/not.rb
394
391
  - lib/lookout/recorder/tape.rb
395
- - lib/lookout/recorder.rb
396
392
  - lib/lookout/recorders/reception.rb
397
393
  - lib/lookout/recorders/state.rb
398
- - lib/lookout/recorders.rb
399
- - lib/lookout/result.rb
400
- - lib/lookout/results/error/exception/backtrace.rb
401
- - lib/lookout/results/error/exception.rb
402
- - lib/lookout/results/error.rb
403
- - lib/lookout/results/failure.rb
394
+ - lib/lookout/results/failures.rb
404
395
  - lib/lookout/results/failures/behavior.rb
405
396
  - lib/lookout/results/failures/state.rb
406
- - lib/lookout/results/failures.rb
397
+ - lib/lookout/results/error.rb
398
+ - lib/lookout/results/error/exception.rb
399
+ - lib/lookout/results/error/exception/backtrace.rb
400
+ - lib/lookout/results/failure.rb
407
401
  - lib/lookout/results/fulfilled.rb
408
- - lib/lookout/results.rb
409
- - lib/lookout/runners/console.rb
410
402
  - lib/lookout/runners.rb
403
+ - lib/lookout/runners/console.rb
404
+ - lib/lookout/stub.rb
411
405
  - lib/lookout/stub/method.rb
412
406
  - lib/lookout/stub/methods.rb
413
407
  - lib/lookout/stub/object.rb
414
- - lib/lookout/stub.rb
415
- - lib/lookout/ui/console.rb
416
- - lib/lookout/ui/silent.rb
417
408
  - lib/lookout/ui.rb
418
- - lib/lookout/version.rb
409
+ - lib/lookout/ui/silent.rb
410
+ - lib/lookout/ui/console.rb
419
411
  - lib/lookout/xml.rb
412
+ - lib/lookout/aphonic.rb
413
+ - lib/lookout/result.rb
414
+ - lib/lookout/results.rb
415
+ - lib/lookout/recorder.rb
416
+ - lib/lookout/recorders.rb
417
+ - lib/lookout/expectations.rb
418
+ - lib/lookout/expectation.rb
419
+ - lib/lookout/warning.rb
420
+ - lib/lookout/equality.rb
421
+ - lib/lookout/version.rb
420
422
  - lib/lookout.rb
421
- - test/unit/examples.rb
422
- - test/unit/lookout/diff/algorithms/difflib/position/to.rb
423
- - test/unit/lookout/diff/algorithms/difflib/position.rb
423
+ - test/unit/lookout.rb
424
+ - test/unit/lookout/diff.rb
424
425
  - test/unit/lookout/diff/algorithms/difflib.rb
426
+ - test/unit/lookout/diff/algorithms/difflib/position.rb
427
+ - test/unit/lookout/diff/algorithms/difflib/position/to.rb
425
428
  - test/unit/lookout/diff/formats/inline.rb
426
429
  - test/unit/lookout/diff/formats/unified.rb
427
430
  - test/unit/lookout/diff/group.rb
428
431
  - test/unit/lookout/diff/groups.rb
429
432
  - test/unit/lookout/diff/match.rb
433
+ - test/unit/lookout/diff/operations.rb
430
434
  - test/unit/lookout/diff/operations/delete.rb
431
435
  - test/unit/lookout/diff/operations/equal.rb
432
436
  - test/unit/lookout/diff/operations/insert.rb
433
437
  - test/unit/lookout/diff/operations/replace.rb
434
- - test/unit/lookout/diff/operations.rb
435
438
  - test/unit/lookout/diff/range.rb
436
- - test/unit/lookout/diff.rb
437
439
  - test/unit/lookout/equality.rb
438
440
  - test/unit/lookout/expectation.rb
441
+ - test/unit/lookout/expectations.rb
439
442
  - test/unit/lookout/expectations/behavior.rb
440
443
  - test/unit/lookout/expectations/state.rb
441
- - test/unit/lookout/expectations.rb
442
- - test/unit/lookout/mock/method/arguments/any.rb
443
- - test/unit/lookout/mock/method/arguments.rb
444
- - test/unit/lookout/mock/method.rb
445
444
  - test/unit/lookout/mock.rb
445
+ - test/unit/lookout/mock/method.rb
446
+ - test/unit/lookout/mock/method/arguments.rb
447
+ - test/unit/lookout/mock/method/arguments/any.rb
446
448
  - test/unit/lookout/recorder.rb
449
+ - test/unit/lookout/results.rb
447
450
  - test/unit/lookout/results/error.rb
448
451
  - test/unit/lookout/results/failures/behavior.rb
449
452
  - test/unit/lookout/results/failures/state.rb
450
453
  - test/unit/lookout/results/fulfilled.rb
451
- - test/unit/lookout/results.rb
452
454
  - test/unit/lookout/runners/console.rb
453
- - test/unit/lookout/stub/method.rb
454
455
  - test/unit/lookout/stub.rb
455
- - test/unit/lookout/ui/formatters/exception/backtrace.rb
456
+ - test/unit/lookout/stub/method.rb
456
457
  - test/unit/lookout/ui/formatters/exception.rb
458
+ - test/unit/lookout/ui/formatters/exception/backtrace.rb
457
459
  - test/unit/lookout/xml.rb
458
- - test/unit/lookout.rb
460
+ - test/unit/examples.rb
459
461
  - README
460
462
  - Rakefile
461
463
  has_rdoc: true