muack 1.5.0 → 1.5.1

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
  SHA256:
3
- metadata.gz: e65f1260993f94d96899086e3975500583ec077bfae332a8fd4cefc5a2c7da49
4
- data.tar.gz: 736468eb986e1925f8f83973fec00c2142df16ca80aee9ce051bbdc255cbbfc8
3
+ metadata.gz: 77dfffce2bb5df1930472ff39a8280bd9a1a69f6e81d1f0173d02099b5cdeaf9
4
+ data.tar.gz: aabb83e37e3ae995c02ad1ba1e938866cd3e036fa8a3f7682273a80255c60f90
5
5
  SHA512:
6
- metadata.gz: d3bb1281eab20185484890205696cbed1d3996ed6392b76e08297af8e742bd76a80f2e3a26fffec265848d18a5373dffd517db6d2127b4e511dfdc5a2b475937
7
- data.tar.gz: 2c148e33b0dce444708d09a58f6364e160a926f73e5432120fa8668c7ee0dd65c83128e69723673fd6c95bb62db879b8ff3636af29c93e783954f8409a882ebd
6
+ metadata.gz: 01e57727b0e41455e69a5c4f0f6552b14d1efc192b08435d4b154abe68d86bf62e058cc54196ca05fb1519a301ae7c4fd3bc9924e25a2036c44d1b5a3c3a7843
7
+ data.tar.gz: 2324f6b087b7d79c46c5727078fce53a2f178ff8474bbed48af3750e447ad6e16168b788d148ca3c3a347a6a11ac578b923aa5effeb81013a9ab5e159d5508e3
data/CHANGES.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # CHANGES
2
2
 
3
+ ## Muack 1.5.1 -- 2020-12-06
4
+
5
+ ### Bugs fixed
6
+
7
+ * Eliminated potential keyword arguments warnings for `initialize` when
8
+ mocking against `new`.
9
+
3
10
  ## Muack 1.5.0 -- 2020-11-28
4
11
 
5
12
  ### Bugs fixed
@@ -246,7 +246,13 @@ module Muack
246
246
  ::Kernel.instance_method(:method).bind(object).call(method_name).
247
247
  super_method
248
248
 
249
- super_method && __mock_block_with_kargs?(super_method)
249
+ if super_method.owner == ::Class && super_method.name == :new
250
+ initialize_method = ::Class.instance_method(:instance_method).
251
+ bind(object).call(:initialize)
252
+ __mock_block_with_kargs?(initialize_method)
253
+ else
254
+ super_method && __mock_block_with_kargs?(super_method)
255
+ end
250
256
  end
251
257
 
252
258
  def __mock_block_with_kargs? block
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Muack
3
- VERSION = '1.5.0'
3
+ VERSION = '1.5.1'
4
4
  end
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: muack 1.5.0 ruby lib
2
+ # stub: muack 1.5.1 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "muack".freeze
6
- s.version = "1.5.0"
6
+ s.version = "1.5.1"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["Lin Jen-Shin (godfat)".freeze]
11
- s.date = "2020-11-28"
11
+ s.date = "2020-12-06"
12
12
  s.description = "Muack -- A fast, small, yet powerful mocking library.\n\nInspired by [RR][], and it's 32x times faster (750s vs 23s) than RR\nfor running [Rib][] tests.\n\n[RR]: https://github.com/rr/rr\n[Rib]: https://github.com/godfat/rib".freeze
13
13
  s.email = ["godfat (XD) godfat.org".freeze]
14
14
  s.files = [
@@ -108,4 +108,53 @@ describe Muack::Mock do
108
108
  expect(Obj.say(a: 0)).eq(Obj.object_id)
109
109
  end
110
110
  end
111
+
112
+ describe 'proxy new' do
113
+ would 'handle initialize via ordinal new' do
114
+ kargs_initialize = Class.new do
115
+ def initialize a:
116
+ @a = a
117
+ end
118
+ attr_reader :a
119
+ end
120
+
121
+ mock(kargs_initialize).new(a: 0)
122
+
123
+ expect(kargs_initialize.new(a: 0).a).eq(0)
124
+ end
125
+
126
+ would 'handle overridden new without keyword arguments' do
127
+ kargs_initialize = Class.new do
128
+ def initialize a:
129
+ @a = a
130
+ end
131
+ attr_reader :a
132
+
133
+ def self.new a
134
+ super(a: a)
135
+ end
136
+ end
137
+
138
+ mock(kargs_initialize).new(0)
139
+
140
+ expect(kargs_initialize.new(0).a).eq(0)
141
+ end
142
+
143
+ would 'handle overridden new with keyword arguments' do
144
+ kargs_initialize = Class.new do
145
+ def initialize a
146
+ @a = a
147
+ end
148
+ attr_reader :a
149
+
150
+ def self.new a:
151
+ super(a)
152
+ end
153
+ end
154
+
155
+ mock(kargs_initialize).new(a: 0)
156
+
157
+ expect(kargs_initialize.new(a: 0).a).eq(0)
158
+ end
159
+ end
111
160
  end
@@ -102,6 +102,30 @@ describe Muack::Mock do
102
102
  Muack.verify.should.eq true
103
103
  obj.f .should.eq 0
104
104
  end
105
+
106
+ describe 'not affect the original module' do
107
+ would 'with include' do
108
+ m = Module.new{ def f; :f; end }
109
+ c0 = Class.new{ include m }.new
110
+ c1 = Class.new{ include m }.new
111
+
112
+ mock(c0).f{:g}
113
+
114
+ expect(c0.f).eq :g
115
+ expect(c1.f).eq :f
116
+ end
117
+
118
+ would 'with prepend' do
119
+ m = Module.new{ def f; :f; end }
120
+ c0 = Class.new{ prepend m }.new
121
+ c1 = Class.new{ prepend m }.new
122
+
123
+ mock(c0).f{:g}
124
+
125
+ expect(c0.f).eq :g
126
+ expect(c1.f).eq :f
127
+ end
128
+ end
105
129
  end
106
130
 
107
131
  describe 'Muack.verify==false' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lin Jen-Shin (godfat)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-28 00:00:00.000000000 Z
11
+ date: 2020-12-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |-
14
14
  Muack -- A fast, small, yet powerful mocking library.