lookout 2.1.3 → 2.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,7 +13,7 @@ module Lookout::Expectation
13
13
  end
14
14
 
15
15
  def initialize(expected, file, line, &block)
16
- @expected, @file, @line, @block = expected, file, line.to_i, block
16
+ @expected, @file, @line, @block = expected, file, line, block
17
17
  end
18
18
 
19
19
  def evaluate
@@ -7,6 +7,7 @@ class Lookout::Expectations
7
7
  def initialize(results = Lookout::Results::Unsuccessful.new, line = nil)
8
8
  @results, @line = results, line
9
9
  @previous = nil
10
+ @ran_previous = false
10
11
  end
11
12
 
12
13
  def mock
@@ -38,14 +39,16 @@ class Lookout::Expectations
38
39
  end
39
40
 
40
41
  def expect(expected, &block)
41
- file, line = /\A(.*):(\d+)(?::in .*)?\z/.match(caller.first)[1..2]
42
- expectation = Lookout::Expectation.on(expected, file, line, &block)
42
+ expectation = Lookout::Expectation.on(expected, *Lookout.location(caller.first), &block)
43
43
  if @line
44
- if @previous and @previous.line <= @line and expectation.line > @line
45
- @results << @previous.evaluate
46
- @previous = nil
47
- else
48
- @previous = expectation
44
+ unless @ran_previous
45
+ if @previous and @previous.line <= @line and expectation.line > @line
46
+ @results << @previous.evaluate
47
+ @ran_previous = true
48
+ @previous = nil
49
+ else
50
+ @previous = expectation
51
+ end
49
52
  end
50
53
  else
51
54
  @results << expectation.evaluate
@@ -25,7 +25,7 @@ class Lookout::Runners::Console
25
25
  raise
26
26
  rescue Exception => e
27
27
  raise unless location = Array(e.backtrace).first
28
- file, line = /\A(.*):(\d+)(?::in .*)?\z/.match(location)[1..2]
28
+ file, line = Lookout.location(location)
29
29
  raise unless file and line
30
30
  @results << Lookout::Results::Error.new(file, line, nil, e)
31
31
  end
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  module Lookout
4
- Version = '2.1.3'
4
+ Version = '2.1.4'
5
5
  end
data/lib/lookout.rb CHANGED
@@ -20,6 +20,11 @@ module Lookout
20
20
  autoload :XML, 'lookout/xml'
21
21
 
22
22
  class << self
23
+ def location(location)
24
+ return nil, nil unless match = /\A(.*):(\d+)(?::in .*)?\z/.match(location)
25
+ [match[1], match[2].to_i]
26
+ end
27
+
23
28
  def runner(runner = nil)
24
29
  return @runner = runner if runner
25
30
  @runner ||= Lookout::Runners::Console.new.install
data/test/unit/lookout.rb CHANGED
@@ -4,4 +4,28 @@ Expectations do
4
4
  expect Lookout.runner.to.receive.expectations_eval do
5
5
  Expectations{ }
6
6
  end
7
+
8
+ expect [nil, nil] do
9
+ Lookout.location('abc')
10
+ end
11
+
12
+ expect ['abc.rb', 123] do
13
+ Lookout.location('abc.rb:123')
14
+ end
15
+
16
+ expect ['abc.rb', 123] do
17
+ Lookout.location('abc.rb:123:in def')
18
+ end
19
+
20
+ expect [String, Integer] do
21
+ Lookout.location(caller.first)
22
+ end
23
+
24
+ expect [__FILE__, __LINE__ + 2] do
25
+ begin
26
+ raise 'hell'
27
+ rescue => e
28
+ Lookout.location(e.backtrace.first)
29
+ end
30
+ end
7
31
  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: 13
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 1
9
- - 3
10
- version: 2.1.3
9
+ - 4
10
+ version: 2.1.4
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-07-15 00:00:00 +02:00
18
+ date: 2011-07-26 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -411,8 +411,8 @@ files:
411
411
  - lib/lookout/aphonic.rb
412
412
  - lib/lookout/recorder.rb
413
413
  - lib/lookout/recorders.rb
414
- - lib/lookout/version.rb
415
414
  - lib/lookout/expectation.rb
415
+ - lib/lookout/version.rb
416
416
  - lib/lookout/expectations.rb
417
417
  - lib/lookout/equalities/object.rb
418
418
  - lib/lookout/equalities/include.rb
@@ -431,7 +431,6 @@ files:
431
431
  - lib/lookout/result.rb
432
432
  - lib/lookout/equalities.rb
433
433
  - lib/lookout.rb
434
- - test/unit/lookout.rb
435
434
  - test/unit/lookout/diff.rb
436
435
  - test/unit/lookout/diff/algorithms/difflib.rb
437
436
  - test/unit/lookout/diff/algorithms/difflib/position.rb
@@ -469,6 +468,7 @@ files:
469
468
  - test/unit/lookout/results.rb
470
469
  - test/unit/lookout/expectations.rb
471
470
  - test/unit/examples.rb
471
+ - test/unit/lookout.rb
472
472
  - README
473
473
  - Rakefile
474
474
  has_rdoc: true