spy_rb 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb161a2c4eabb953bcc5eefefba4927bb7159a56
4
- data.tar.gz: 569fda1c72a9b7a80d3efde9f9c3980623c10f3d
3
+ metadata.gz: 1fc7717987d2a804c55203a19a3a665d33f96f58
4
+ data.tar.gz: 517c1723f922c931ff5e745694b491b289798a7e
5
5
  SHA512:
6
- metadata.gz: bf682739d04fb7f083606dba03ea4be0d24482be2ab9bfd413fbcef9e1488ac2887d5d7bde04d44d2462416a34b0adece5a6a11f7eca259716c2b9d2b928c23e
7
- data.tar.gz: 2b75eacf01aa6781efea38a9efb23dd2b8f9a88d831d26ace9a8e8af20e079cf8497c0b460d9b8b888bafac967bc24834c90cbc5bb238017677025dc3e618b72
6
+ metadata.gz: 75da4d827d5b93e47dfe145321f17d8c8a41fca8f550477e9e3d10c7922c7a7567dcce3a7da3c645a322584079ad810b699d4e9b5ad35aa28505d0af40f4b8fe
7
+ data.tar.gz: e91d8363fff8c5675af653b778d47447da235db493d6325d1d19fec06b0c4f8e4e8447910bcfc5ad2dd26052a8bce6c9743c9de88f7afd660f00cc93fdb367ad
@@ -80,11 +80,15 @@ module Spy
80
80
  end
81
81
 
82
82
  def call_and_record(receiver, args, opts = {}, &block)
83
- record = opts[:record] || build_method_call(receiver, *args, &block)
84
- @call_history << record
83
+ if @instead
84
+ @instead.call build_method_call(receiver, *args, &block)
85
+ else
86
+ record = opts[:record] || build_method_call(receiver, *args, &block)
87
+ @call_history << record
85
88
 
86
- result = call_original(receiver, *args, &block)
87
- record.result = result
89
+ result = call_original(receiver, *args, &block)
90
+ record.result = result
91
+ end
88
92
  end
89
93
 
90
94
  def call_original(receiver, *args, &block)
data/lib/spy/instance.rb CHANGED
@@ -21,6 +21,7 @@ module Spy
21
21
  @around_procs = []
22
22
  @call_history = []
23
23
  @strategy = Strategy.factory_build(self)
24
+ @instead = nil
24
25
  end
25
26
 
26
27
  def name
@@ -67,6 +68,10 @@ module Spy
67
68
  self
68
69
  end
69
70
 
71
+ def instead(&block)
72
+ @instead = block
73
+ end
74
+
70
75
  private
71
76
 
72
77
  def extract_visibility
data/lib/spy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Spy
2
- VERSION = '2.0.0'
2
+ VERSION = '2.1.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spy_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Bodah