rspec-forward 0.1.6 → 0.2.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60586a2b506f34e4fe653293535ece8b206d47923a3fef6b0c2adfa5b82005ce
4
- data.tar.gz: 6c3384494e394a33996bc1580f15d3a3ae6d7a1976b196e98fd2ad1f73672c2a
3
+ metadata.gz: 2f5a4ed137097daa1757f224dcd888b8f5c88e5a63d1f2afafeddd7fe9a8fcb7
4
+ data.tar.gz: c7a4e5a3417e5efffb2a717438e75aa50e1fcbc7c758412c1bf0f0ebfbcae96f
5
5
  SHA512:
6
- metadata.gz: 39019b0a6c054365e0f5e26d39f3081e07d91db3a42bcbf60d57f3907cd92761cf530e905916227f5919c2959a6e3f7c984960e3fc068ddc216159a2f324a6b2
7
- data.tar.gz: 46d07febe0734cc50532a5cf8c3772541153c47e98391c7f8a2b30f9b97670a8e98c633d02e22edacda53ace9b828f80cf6a4b243e5f2c14f703b66b3d479408
6
+ metadata.gz: 8d0b9616d308d756af92c4b3c2f2ef2f5141aa7e59870949907374f2f5a00002985cad8894fe00584899b2b9e6a55e0681b005f7f4143b0bc95f27cc37fcc1af
7
+ data.tar.gz: ccddd1bd2fa526e9df698a6ff147e7b52c87d601a7dc7dede2d4b6c620aa2522468db237a50579e5165e20c9757ad56c47d96e591fb9faf45b678807c664b066
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-forward (0.1.6)
4
+ rspec-forward (0.2.1)
5
5
  rspec-mocks (~> 3.9)
6
6
 
7
7
  GEM
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2021 Aleksander Długopolski
3
+ Copyright (c) 2022 Marz Drel
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -12,7 +12,8 @@ module ::RSpec
12
12
 
13
13
  define_method name do |*kwargs|
14
14
  @args = Array.new(index, :arg)
15
- @kwargs = Hash[kwargs.map { [_1, _1] }]
15
+ @kwargs = Hash[kwargs.map { |name| [name, name] }]
16
+
16
17
  self
17
18
  end
18
19
  end
@@ -22,7 +23,11 @@ module ::RSpec
22
23
  end
23
24
 
24
25
  def with_1_arg_and_named(*args, **kwargs)
25
- with_1_args_and_named(*args, **kwargs)
26
+ if kwargs.empty?
27
+ with_1_args_and_named(*args)
28
+ else
29
+ with_1_args_and_named(*args, **kwargs)
30
+ end
26
31
  end
27
32
 
28
33
  def with_no_args
@@ -37,7 +42,7 @@ module ::RSpec
37
42
 
38
43
  def with_named(*kwargs)
39
44
  @args = []
40
- @kwargs = Hash[kwargs.map { [_1, _1] }]
45
+ @kwargs = Hash[kwargs.map { |name| [name, name] }]
41
46
  self
42
47
  end
43
48
 
@@ -73,16 +78,29 @@ module ::RSpec
73
78
  def matches_for?(actual, return_value)
74
79
  assign_actual(actual)
75
80
 
76
- allow(@actual)
77
- .to receive(:new)
78
- .with(*exp_args, **@kwargs)
79
- .and_return(instance)
81
+ if @kwargs.any?
82
+ allow(@actual)
83
+ .to receive(:new)
84
+ .with(*exp_args, **@kwargs)
85
+ .and_return(instance)
80
86
 
81
- result = @actual.send(@expected, *@args, **@kwargs) == return_value
87
+ result = @actual.send(@expected, *@args, **@kwargs) == return_value
82
88
 
83
- expect(@actual)
84
- .to have_received(:new)
85
- .with(*exp_args, **@kwargs)
89
+ expect(@actual)
90
+ .to have_received(:new)
91
+ .with(*exp_args, **@kwargs)
92
+ else
93
+ allow(@actual)
94
+ .to receive(:new)
95
+ .with(*exp_args)
96
+ .and_return(instance)
97
+
98
+ result = @actual.send(@expected, *@args) == return_value
99
+
100
+ expect(@actual)
101
+ .to have_received(:new)
102
+ .with(*exp_args)
103
+ end
86
104
 
87
105
  result
88
106
  end
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module Forward
3
- VERSION = "0.1.6"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-forward
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marz Drel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-20 00:00:00.000000000 Z
11
+ date: 2022-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-mocks
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  - !ruby/object:Gem::Version
100
100
  version: '0'
101
101
  requirements: []
102
- rubygems_version: 3.2.3
102
+ rubygems_version: 3.3.7
103
103
  signing_key:
104
104
  specification_version: 4
105
105
  summary: Set of RSpec matchers for checking class method to instance method forwarding.