mocktail 1.2.1 → 1.2.3

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: f98c176c091bd92d1c3f28be3c8c3eea66cbc3f3b56f9a2fac3f7f78d5eb2775
4
- data.tar.gz: 9422af274277a791b225540f74e3c77f99aff75b908fb1529c56d6f47e35a27f
3
+ metadata.gz: 846ef7f8484c4d2cc0566c5d7629b6a5ec123d969e3881a3db58617f1cd2870a
4
+ data.tar.gz: 16c61a6097d9cc1d2350f4f278d08ae94d0fb346c10875e627706a5d9d8ec371
5
5
  SHA512:
6
- metadata.gz: bc5ae9538c17efdc5675c1f19ca1daaa72dea52162f469fd4a295e68d6d5755792f8533a4c7244d0146e82edfb688dab3a608ea449ba57da3b56ac2e15c75f48
7
- data.tar.gz: 381e52bf6c28151c0ab1dfba3f300df8cd8bc5cf218ddcc735e7dfdced93649f5f4e299fffefc449eb24cf3589c4067d23f7cffb313262c54409290ca10ac1a2
6
+ metadata.gz: 2833970faf892efa75528df04d23954bcb5a9ccfbcaf2ac674558c87766b5210812c72ab73cd380b81600b062d1eab27857520d7f2150a2caddaa75b6e45004b
7
+ data.tar.gz: ac0f9b1f1f79960949cee6baca016496f1a473c9630df7c8b24549dda887e05b65ddaf4816987ff4bca683ce1d6ca3bf447ae0fc918799ae435a007352eccfb1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 1.2.3
2
+
3
+ * Don't class extend Struct.new
4
+
5
+ # 1.2.2
6
+
7
+ * As promised in 1.2.1, there were bugs. [#19](https://github.com/testdouble/mocktail/pull/19)
8
+
1
9
  # 1.2.1
2
10
 
3
11
  * Adds support for faking methods that use options hashes that are called with
data/Gemfile CHANGED
@@ -8,3 +8,4 @@ gem "minitest"
8
8
  gem "standard"
9
9
  gem "pry"
10
10
  gem "simplecov"
11
+ gem "m"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mocktail (1.2.1)
4
+ mocktail (1.2.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -10,6 +10,9 @@ GEM
10
10
  coderay (1.1.3)
11
11
  docile (1.4.0)
12
12
  json (2.6.2)
13
+ m (1.6.1)
14
+ method_source (>= 0.6.7)
15
+ rake (>= 0.9.2.2)
13
16
  method_source (1.0.0)
14
17
  minitest (5.16.3)
15
18
  parallel (1.22.1)
@@ -54,6 +57,7 @@ PLATFORMS
54
57
  ruby
55
58
 
56
59
  DEPENDENCIES
60
+ m
57
61
  minitest
58
62
  mocktail!
59
63
  pry
data/bin/m ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'm' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("m", "m")
@@ -3,6 +3,8 @@ require_relative "../share/bind"
3
3
  module Mocktail
4
4
  class TransformsParams
5
5
  def transform(dry_call, params: dry_call.original_method.parameters)
6
+ params = name_unnamed_params(params)
7
+
6
8
  Signature.new(
7
9
  positional_params: Params.new(
8
10
  all: params.select { |t, _|
@@ -28,5 +30,17 @@ module Mocktail
28
30
  block_arg: dry_call.block
29
31
  )
30
32
  end
33
+
34
+ private
35
+
36
+ def name_unnamed_params(params)
37
+ params.map.with_index { |param, i|
38
+ if param.size == 1
39
+ param + ["unnamed_arg_#{i + 1}"]
40
+ else
41
+ param
42
+ end
43
+ }
44
+ end
31
45
  end
32
46
  end
@@ -1,5 +1,5 @@
1
1
  module Mocktail
2
- class Call < Struct.new(
2
+ Call = Struct.new(
3
3
  :singleton,
4
4
  :double,
5
5
  :original_type,
@@ -11,5 +11,4 @@ module Mocktail
11
11
  :block,
12
12
  keyword_init: true
13
13
  )
14
- end
15
14
  end
@@ -1,10 +1,9 @@
1
1
  module Mocktail
2
- class DemoConfig < Struct.new(
2
+ DemoConfig = Struct.new(
3
3
  :ignore_block,
4
4
  :ignore_extra_args,
5
5
  :ignore_arity,
6
6
  :times,
7
7
  keyword_init: true
8
8
  )
9
- end
10
9
  end
@@ -1,10 +1,9 @@
1
1
  module Mocktail
2
- class Double < Struct.new(
2
+ Double = Struct.new(
3
3
  :original_type,
4
4
  :dry_type,
5
5
  :dry_instance,
6
6
  :dry_methods,
7
7
  keyword_init: true
8
8
  )
9
- end
10
9
  end
@@ -1,10 +1,9 @@
1
1
  module Mocktail
2
- class DoubleData < Struct.new(
2
+ DoubleData = Struct.new(
3
3
  :type,
4
4
  :double,
5
5
  :calls,
6
6
  :stubbings,
7
7
  keyword_init: true
8
8
  )
9
- end
10
9
  end
@@ -1,9 +1,8 @@
1
1
  module Mocktail
2
- class FakeMethodData < Struct.new(
2
+ FakeMethodData = Struct.new(
3
3
  :receiver,
4
4
  :calls,
5
5
  :stubbings,
6
6
  keyword_init: true
7
7
  )
8
- end
9
8
  end
@@ -1,5 +1,5 @@
1
1
  module Mocktail
2
- class Signature < Struct.new(
2
+ Signature = Struct.new(
3
3
  :positional_params,
4
4
  :positional_args,
5
5
  :keyword_params,
@@ -8,19 +8,19 @@ module Mocktail
8
8
  :block_arg,
9
9
  keyword_init: true
10
10
  )
11
+ class Signature
11
12
  DEFAULT_REST_ARGS = "args"
12
13
  DEFAULT_REST_KWARGS = "kwargs"
13
14
  DEFAULT_BLOCK_PARAM = "blk"
14
15
  end
15
16
 
16
- class Params < Struct.new(
17
+ Params = Struct.new(
17
18
  :all,
18
19
  :required,
19
20
  :optional,
20
21
  :rest,
21
22
  keyword_init: true
22
- )
23
-
23
+ ) do
24
24
  def initialize(**params)
25
25
  super
26
26
  self.all ||= []
@@ -1,13 +1,12 @@
1
1
  module Mocktail
2
- class Stubbing < Struct.new(
2
+ Stubbing = Struct.new(
3
3
  :demonstration,
4
4
  :demo_config,
5
5
  :satisfaction_count,
6
6
  :recording,
7
7
  :effect,
8
8
  keyword_init: true
9
- )
10
-
9
+ ) do
11
10
  def initialize(**kwargs)
12
11
  super
13
12
  self.satisfaction_count ||= 0
@@ -1,5 +1,5 @@
1
1
  module Mocktail
2
- class TypeReplacement < Struct.new(
2
+ TypeReplacement = Struct.new(
3
3
  :type,
4
4
  :original_methods,
5
5
  :replacement_methods,
@@ -7,5 +7,4 @@ module Mocktail
7
7
  :replacement_new,
8
8
  keyword_init: true
9
9
  )
10
- end
11
10
  end
@@ -1,11 +1,11 @@
1
1
  module Mocktail
2
- class TypeReplacementData < Struct.new(
2
+ TypeReplacementData = Struct.new(
3
3
  :type,
4
4
  :replaced_method_names,
5
5
  :calls,
6
6
  :stubbings,
7
7
  keyword_init: true
8
- )
8
+ ) do
9
9
  def double
10
10
  type
11
11
  end
@@ -1,9 +1,8 @@
1
1
  module Mocktail
2
- class UnsatisfyingCall < Struct.new(
2
+ UnsatisfyingCall = Struct.new(
3
3
  :call,
4
4
  :other_stubbings,
5
5
  :backtrace,
6
6
  keyword_init: true
7
7
  )
8
- end
9
8
  end
@@ -1,3 +1,3 @@
1
1
  module Mocktail
2
- VERSION = "1.2.1"
2
+ VERSION = "1.2.3"
3
3
  end
data/mocktail.gemspec CHANGED
@@ -13,6 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.metadata["homepage_uri"] = spec.homepage
14
14
  spec.metadata["source_code_uri"] = spec.homepage
15
15
  spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
16
+ spec.metadata["rubygems_mfa_required"] = "true"
16
17
 
17
18
  # Specify which files should be added to the gem when it is released.
18
19
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mocktail
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Searls
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-11-17 00:00:00.000000000 Z
11
+ date: 2023-08-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -27,6 +27,7 @@ files:
27
27
  - README.md
28
28
  - Rakefile
29
29
  - bin/console
30
+ - bin/m
30
31
  - bin/rake
31
32
  - bin/setup
32
33
  - lib/mocktail.rb
@@ -108,6 +109,7 @@ metadata:
108
109
  homepage_uri: https://github.com/testdouble/mocktail
109
110
  source_code_uri: https://github.com/testdouble/mocktail
110
111
  changelog_uri: https://github.com/testdouble/mocktail/blob/main/CHANGELOG.md
112
+ rubygems_mfa_required: 'true'
111
113
  post_install_message:
112
114
  rdoc_options: []
113
115
  require_paths:
@@ -123,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
125
  - !ruby/object:Gem::Version
124
126
  version: '0'
125
127
  requirements: []
126
- rubygems_version: 3.3.20
128
+ rubygems_version: 3.4.6
127
129
  signing_key:
128
130
  specification_version: 4
129
131
  summary: Take your objects, and make them a double