rspec-forward 0.1.4 → 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 +4 -4
- data/.ruby-version +1 -0
- data/Gemfile.lock +13 -13
- data/Guardfile +3 -3
- data/LICENSE.txt +1 -1
- data/README.md +6 -8
- data/Rakefile +5 -3
- data/lib/rspec/forward/forward_methods.rb +29 -11
- data/lib/rspec/forward/version.rb +1 -1
- data/rspec-forward.gemspec +10 -10
- metadata +16 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f5a4ed137097daa1757f224dcd888b8f5c88e5a63d1f2afafeddd7fe9a8fcb7
|
4
|
+
data.tar.gz: c7a4e5a3417e5efffb2a717438e75aa50e1fcbc7c758412c1bf0f0ebfbcae96f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d0b9616d308d756af92c4b3c2f2ef2f5141aa7e59870949907374f2f5a00002985cad8894fe00584899b2b9e6a55e0681b005f7f4143b0bc95f27cc37fcc1af
|
7
|
+
data.tar.gz: ccddd1bd2fa526e9df698a6ff147e7b52c87d601a7dc7dede2d4b6c620aa2522468db237a50579e5165e20c9757ad56c47d96e591fb9faf45b678807c664b066
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.0.0
|
data/Gemfile.lock
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rspec-forward (0.1
|
5
|
-
rspec-mocks (~> 3.
|
4
|
+
rspec-forward (0.2.1)
|
5
|
+
rspec-mocks (~> 3.9)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
coderay (1.1.3)
|
11
11
|
diff-lcs (1.4.4)
|
12
|
-
ffi (1.15.
|
13
|
-
formatador (0.
|
14
|
-
guard (2.
|
12
|
+
ffi (1.15.3)
|
13
|
+
formatador (0.3.0)
|
14
|
+
guard (2.17.0)
|
15
15
|
formatador (>= 0.2.4)
|
16
16
|
listen (>= 2.7, < 4.0)
|
17
17
|
lumberjack (>= 1.0.12, < 2.0)
|
@@ -25,7 +25,7 @@ GEM
|
|
25
25
|
guard (~> 2.1)
|
26
26
|
guard-compat (~> 1.1)
|
27
27
|
rspec (>= 2.99.0, < 4.0)
|
28
|
-
listen (3.
|
28
|
+
listen (3.5.1)
|
29
29
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
30
30
|
rb-inotify (~> 0.9, >= 0.9.10)
|
31
31
|
lumberjack (1.2.8)
|
@@ -34,26 +34,26 @@ GEM
|
|
34
34
|
notiffany (0.1.3)
|
35
35
|
nenv (~> 0.1)
|
36
36
|
shellany (~> 0.0)
|
37
|
-
pry (0.14.
|
37
|
+
pry (0.14.1)
|
38
38
|
coderay (~> 1.1)
|
39
39
|
method_source (~> 1.0)
|
40
40
|
rake (12.3.3)
|
41
|
-
rb-fsevent (0.
|
41
|
+
rb-fsevent (0.11.0)
|
42
42
|
rb-inotify (0.10.1)
|
43
43
|
ffi (~> 1.0)
|
44
44
|
rspec (3.10.0)
|
45
45
|
rspec-core (~> 3.10.0)
|
46
46
|
rspec-expectations (~> 3.10.0)
|
47
47
|
rspec-mocks (~> 3.10.0)
|
48
|
-
rspec-core (3.10.
|
48
|
+
rspec-core (3.10.1)
|
49
49
|
rspec-support (~> 3.10.0)
|
50
|
-
rspec-expectations (3.10.
|
50
|
+
rspec-expectations (3.10.1)
|
51
51
|
diff-lcs (>= 1.2.0, < 2.0)
|
52
52
|
rspec-support (~> 3.10.0)
|
53
|
-
rspec-mocks (3.10.
|
53
|
+
rspec-mocks (3.10.2)
|
54
54
|
diff-lcs (>= 1.2.0, < 2.0)
|
55
55
|
rspec-support (~> 3.10.0)
|
56
|
-
rspec-support (3.10.
|
56
|
+
rspec-support (3.10.2)
|
57
57
|
shellany (0.0.1)
|
58
58
|
thor (1.1.0)
|
59
59
|
|
@@ -68,4 +68,4 @@ DEPENDENCIES
|
|
68
68
|
rspec-forward!
|
69
69
|
|
70
70
|
BUNDLED WITH
|
71
|
-
2.
|
71
|
+
2.2.3
|
data/Guardfile
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
GUARD_OPTIONS = {
|
5
5
|
failed_mode: :keep,
|
6
6
|
cmd: "rspec --order rand:$RANDOM",
|
7
|
-
title: "RSpec"
|
7
|
+
title: "RSpec"
|
8
8
|
}.freeze
|
9
9
|
|
10
10
|
guard :rspec, GUARD_OPTIONS do
|
@@ -15,11 +15,11 @@ guard :rspec, GUARD_OPTIONS do
|
|
15
15
|
watch(%r{^lib/(.+)\.rb$}) do |m|
|
16
16
|
"spec/#{m[1]}_spec.rb"
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
watch("spec/spec_helper.rb") do
|
20
20
|
"spec"
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
watch(%r{^spec/support/(.+)\.rb$}) do
|
24
24
|
"spec"
|
25
25
|
end
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -59,7 +59,7 @@ Add.call(3, 5) # => 8
|
|
59
59
|
```
|
60
60
|
|
61
61
|
Gem `rspec-forward` adds matcher `forward_to_instance` to verify if the
|
62
|
-
call using Class Methods is properly building the instance of the
|
62
|
+
call using Class Methods is properly building the instance of the class and
|
63
63
|
forwarding the method call to expected instance method.
|
64
64
|
|
65
65
|
```ruby
|
@@ -87,10 +87,10 @@ If you would rather not use the old, deprecated
|
|
87
87
|
|
88
88
|
```ruby
|
89
89
|
describe ".call" do
|
90
|
-
let(:
|
90
|
+
let(:klass) { described_class }
|
91
91
|
|
92
92
|
it "passes arguments to instance" do
|
93
|
-
expect(
|
93
|
+
expect(klass)
|
94
94
|
.to forward_to_instance(:call)
|
95
95
|
.with_2_args
|
96
96
|
end
|
@@ -104,15 +104,13 @@ it { should forward_to_instance(:call).with_no_args }
|
|
104
104
|
it { should forward_to_instance(:call).with_1_arg }
|
105
105
|
it { should forward_to_instance(:call).with_2_args }
|
106
106
|
it { should forward_to_instance(:call).with_3_args }
|
107
|
-
# ...
|
108
|
-
|
109
107
|
it { should forward_to_instance(:call).with_named(:foo, :bar) }
|
110
108
|
it { should forward_to_instance(:call).with_1_arg_and_named(:foo) }
|
111
109
|
it { should forward_to_instance(:call).with_2_args_and_named(:foo) }
|
112
110
|
it { should forward_to_instance(:call).with_3_args_and_named(:foo, :bar) }
|
113
111
|
```
|
114
112
|
|
115
|
-
TODO
|
113
|
+
**TODO**: Explain `forward_to_instance_build(...)`
|
116
114
|
|
117
115
|
## Development
|
118
116
|
|
@@ -122,7 +120,7 @@ After checking out the repo, run `bundle install` to install dependencies. Then,
|
|
122
120
|
## Contributing
|
123
121
|
|
124
122
|
Bug reports and pull requests are welcome on GitHub at
|
125
|
-
https://github.com/
|
123
|
+
https://github.com/marzdrel/rspec-forward.
|
126
124
|
|
127
125
|
## License
|
128
126
|
|
@@ -132,4 +130,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
132
130
|
|
133
131
|
Everyone interacting in the RSpec::Forward project's codebases, issue
|
134
132
|
trackers, chat rooms and mailing lists is expected to follow the [code of
|
135
|
-
conduct](https://github.com/
|
133
|
+
conduct](https://github.com/marzdrel/rspec-forward/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
@@ -3,11 +3,13 @@ require "rspec/core/rake_task"
|
|
3
3
|
|
4
4
|
RSpec::Core::RakeTask.new(:spec)
|
5
5
|
|
6
|
-
task :
|
6
|
+
task default: :spec
|
7
7
|
|
8
|
+
# rubocop:disable Security/Eval
|
8
9
|
def gemspec
|
9
|
-
@
|
10
|
+
@_gemspec ||= eval(File.read("rspec-forward.gemspec"), binding, ".gemspec")
|
10
11
|
end
|
12
|
+
# rubocop:enable Security/Eval
|
11
13
|
|
12
14
|
desc "Validate the gemspec"
|
13
15
|
task :gemspec do
|
@@ -15,7 +17,7 @@ task :gemspec do
|
|
15
17
|
end
|
16
18
|
|
17
19
|
desc "Build the gem"
|
18
|
-
task :
|
20
|
+
task gem: :gemspec do
|
19
21
|
sh "gem build #{gemspec.name}.gemspec"
|
20
22
|
|
21
23
|
FileUtils.mkdir_p "pkg"
|
@@ -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 { [
|
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
|
-
|
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 { [
|
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
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
81
|
+
if @kwargs.any?
|
82
|
+
allow(@actual)
|
83
|
+
.to receive(:new)
|
84
|
+
.with(*exp_args, **@kwargs)
|
85
|
+
.and_return(instance)
|
80
86
|
|
81
|
-
|
87
|
+
result = @actual.send(@expected, *@args, **@kwargs) == return_value
|
82
88
|
|
83
|
-
|
84
|
-
|
85
|
-
|
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
|
data/rspec-forward.gemspec
CHANGED
@@ -3,16 +3,16 @@ require_relative "lib/rspec/forward/version"
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "rspec-forward"
|
5
5
|
spec.version = RSpec::Forward::VERSION
|
6
|
-
spec.authors= ["
|
7
|
-
spec.email = ["
|
6
|
+
spec.authors = ["Marz Drel"]
|
7
|
+
spec.email = ["marzdrel@dotpro.org"]
|
8
8
|
|
9
9
|
spec.summary = <<~TXT.gsub(/[[:space:]]+/, " ").strip
|
10
|
-
Set of RSpec matchers for checking class method to
|
10
|
+
Set of RSpec matchers for checking class method to instance
|
11
11
|
method forwarding.
|
12
12
|
TXT
|
13
13
|
|
14
14
|
spec.description = <<~TXT.gsub(/[[:space:]]+/, " ").strip
|
15
|
-
Set of RSpec matchers for checking class method to
|
15
|
+
Set of RSpec matchers for checking class method to instance
|
16
16
|
method forwarding.
|
17
17
|
TXT
|
18
18
|
|
@@ -23,16 +23,16 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
24
24
|
|
25
25
|
# spec.metadata["homepage_uri"] = spec.homepage
|
26
|
-
spec.metadata["source_code_uri"] =
|
27
|
-
"https://github.com/
|
26
|
+
spec.metadata["source_code_uri"] =
|
27
|
+
"https://github.com/marzdrel/rspec-forward"
|
28
28
|
|
29
|
-
spec.metadata["changelog_uri"] =
|
30
|
-
"https://github.com/
|
29
|
+
spec.metadata["changelog_uri"] =
|
30
|
+
"https://github.com/marzdrel/rspec-forward/blob/master/CHANGELOG.md"
|
31
31
|
|
32
32
|
# Specify which files should be added to the gem when it is released.
|
33
33
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
34
34
|
|
35
|
-
spec.files = Dir.chdir(File.expand_path(
|
35
|
+
spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
|
36
36
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
37
37
|
end
|
38
38
|
|
@@ -40,7 +40,7 @@ Gem::Specification.new do |spec|
|
|
40
40
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
41
41
|
spec.require_paths = ["lib"]
|
42
42
|
|
43
|
-
spec.add_runtime_dependency "rspec-mocks", "~> 3.
|
43
|
+
spec.add_runtime_dependency "rspec-mocks", "~> 3.9"
|
44
44
|
spec.add_development_dependency "guard", "~> 2.16"
|
45
45
|
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
46
46
|
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
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
7
|
+
- Marz Drel
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-mocks
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3.
|
19
|
+
version: '3.9'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '3.
|
26
|
+
version: '3.9'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: guard
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,15 +52,16 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '4.7'
|
55
|
-
description: Set of RSpec matchers for checking class method to
|
55
|
+
description: Set of RSpec matchers for checking class method to instance method forwarding.
|
56
56
|
email:
|
57
|
-
-
|
57
|
+
- marzdrel@dotpro.org
|
58
58
|
executables: []
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- ".gitignore"
|
63
63
|
- ".rspec"
|
64
|
+
- ".ruby-version"
|
64
65
|
- ".travis.yml"
|
65
66
|
- CODE_OF_CONDUCT.md
|
66
67
|
- Gemfile
|
@@ -77,13 +78,13 @@ files:
|
|
77
78
|
- lib/rspec/forward/forward_to_instance_build.rb
|
78
79
|
- lib/rspec/forward/version.rb
|
79
80
|
- rspec-forward.gemspec
|
80
|
-
homepage:
|
81
|
+
homepage:
|
81
82
|
licenses:
|
82
83
|
- MIT
|
83
84
|
metadata:
|
84
|
-
source_code_uri: https://github.com/
|
85
|
-
changelog_uri: https://github.com/
|
86
|
-
post_install_message:
|
85
|
+
source_code_uri: https://github.com/marzdrel/rspec-forward
|
86
|
+
changelog_uri: https://github.com/marzdrel/rspec-forward/blob/master/CHANGELOG.md
|
87
|
+
post_install_message:
|
87
88
|
rdoc_options: []
|
88
89
|
require_paths:
|
89
90
|
- lib
|
@@ -98,8 +99,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
99
|
- !ruby/object:Gem::Version
|
99
100
|
version: '0'
|
100
101
|
requirements: []
|
101
|
-
rubygems_version: 3.
|
102
|
-
signing_key:
|
102
|
+
rubygems_version: 3.3.7
|
103
|
+
signing_key:
|
103
104
|
specification_version: 4
|
104
|
-
summary: Set of RSpec matchers for checking class method to
|
105
|
+
summary: Set of RSpec matchers for checking class method to instance method forwarding.
|
105
106
|
test_files: []
|