rspec-forward 0.1.0 → 0.1.2
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/Gemfile.lock +35 -0
- data/LICENSE.txt +1 -1
- data/README.md +2 -2
- data/Rakefile +17 -0
- data/lib/rspec/forward.rb +7 -2
- data/lib/rspec/forward/forward_to_instance.rb +77 -0
- data/lib/rspec/forward/version.rb +2 -2
- data/rspec-forward.gemspec +3 -1
- metadata +22 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb73833c9b834db3b7bf53920c017816c30b1d413c5a1a64e1411d85b25f85e5
|
4
|
+
data.tar.gz: d5deb7a128cbfa6e19f3080d261eedf6df9be8181c7c44500acbaff959ca5aab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00002a2f4278529de0bee2aad755f7a46ebd936daf00b3cde5ad2b7c637b2e487c089871e6ebd7477a7a3146d39d986a70b5647d2ed1280a0e002e45cf195b78
|
7
|
+
data.tar.gz: b47cddd3ce77a4c8a5fca7586d07f4b3098a5a0e7cdfd64711f23c01b91a41aabbded9eec442a75a3c1172cb618737b73480b7e9b687f487003160763664f448
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rspec-forward (0.1.2)
|
5
|
+
rspec-mocks (~> 3.10)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.4.4)
|
11
|
+
rake (12.3.3)
|
12
|
+
rspec (3.10.0)
|
13
|
+
rspec-core (~> 3.10.0)
|
14
|
+
rspec-expectations (~> 3.10.0)
|
15
|
+
rspec-mocks (~> 3.10.0)
|
16
|
+
rspec-core (3.10.0)
|
17
|
+
rspec-support (~> 3.10.0)
|
18
|
+
rspec-expectations (3.10.0)
|
19
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
20
|
+
rspec-support (~> 3.10.0)
|
21
|
+
rspec-mocks (3.10.0)
|
22
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
+
rspec-support (~> 3.10.0)
|
24
|
+
rspec-support (3.10.0)
|
25
|
+
|
26
|
+
PLATFORMS
|
27
|
+
ruby
|
28
|
+
|
29
|
+
DEPENDENCIES
|
30
|
+
rake (~> 12.0)
|
31
|
+
rspec (~> 3.0)
|
32
|
+
rspec-forward!
|
33
|
+
|
34
|
+
BUNDLED WITH
|
35
|
+
2.1.4
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# RSpec::Forward
|
2
2
|
|
3
3
|
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rspec/forward`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
4
|
|
@@ -41,4 +41,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
41
41
|
|
42
42
|
## Code of Conduct
|
43
43
|
|
44
|
-
Everyone interacting in the
|
44
|
+
Everyone interacting in the RSpec::Forward project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/rspec-forward/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
@@ -4,3 +4,20 @@ require "rspec/core/rake_task"
|
|
4
4
|
RSpec::Core::RakeTask.new(:spec)
|
5
5
|
|
6
6
|
task :default => :spec
|
7
|
+
|
8
|
+
def gemspec
|
9
|
+
@gemspec ||= eval(File.read("rspec-forward.gemspec"), binding, ".gemspec")
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "Validate the gemspec"
|
13
|
+
task :gemspec do
|
14
|
+
gemspec.validate
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Build the gem"
|
18
|
+
task :gem => :gemspec do
|
19
|
+
sh "gem build #{gemspec.name}.gemspec"
|
20
|
+
|
21
|
+
FileUtils.mkdir_p "pkg"
|
22
|
+
FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", "pkg"
|
23
|
+
end
|
data/lib/rspec/forward.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
require "rspec/forward/version"
|
2
|
+
require "rspec/forward/forward_to_instance"
|
2
3
|
|
3
|
-
module
|
4
|
+
module RSpec
|
4
5
|
module Forward
|
5
6
|
class Error < StandardError; end
|
6
|
-
# Your code goes here...
|
7
7
|
end
|
8
8
|
end
|
9
|
+
|
10
|
+
::RSpec.configure do |config|
|
11
|
+
config.include ::RSpec::Mocks::ExampleMethods
|
12
|
+
config.include ::RSpec::Forward
|
13
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module ::RSpec
|
2
|
+
module Forward
|
3
|
+
class ForwardToInstance
|
4
|
+
include ::RSpec::Mocks::ExampleMethods
|
5
|
+
|
6
|
+
def initialize(expected)
|
7
|
+
@expected = expected
|
8
|
+
@kwargs ||= {}
|
9
|
+
@args ||= []
|
10
|
+
end
|
11
|
+
|
12
|
+
def matches?(actual)
|
13
|
+
@actual = actual
|
14
|
+
|
15
|
+
actual = actual.class unless actual.is_a?(Class)
|
16
|
+
|
17
|
+
instance = instance_double(actual, @expected => :return)
|
18
|
+
|
19
|
+
allow(actual)
|
20
|
+
.to receive(:new)
|
21
|
+
.with(*exp_args, **@kwargs)
|
22
|
+
.and_return(instance)
|
23
|
+
|
24
|
+
actual.send(@expected, *@args, **@kwargs) == :return
|
25
|
+
end
|
26
|
+
|
27
|
+
0.upto(10) do |index|
|
28
|
+
define_method format("with_%<count>d_args", count: index) do
|
29
|
+
@args = Array.new(index, :arg)
|
30
|
+
self
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def with_1_arg
|
35
|
+
with_1_args
|
36
|
+
end
|
37
|
+
|
38
|
+
def with_no_args
|
39
|
+
with_0_args
|
40
|
+
end
|
41
|
+
|
42
|
+
def with(*args, **kwargs)
|
43
|
+
@args = args
|
44
|
+
@kwargs = kwargs
|
45
|
+
self
|
46
|
+
end
|
47
|
+
|
48
|
+
def with_named(**kwargs)
|
49
|
+
@args = []
|
50
|
+
@kwargs = kwargs
|
51
|
+
self
|
52
|
+
end
|
53
|
+
|
54
|
+
def failure_message
|
55
|
+
"expected #{@target.inspect} to be #{@expected}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def failure_message_when_negated
|
59
|
+
"expected #{@target.inspect} not to be #{@expected}"
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def exp_args
|
65
|
+
if @args.size.zero? && @kwargs.size.zero?
|
66
|
+
[no_args]
|
67
|
+
else
|
68
|
+
@args
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def forward_to_instance(expected)
|
74
|
+
ForwardToInstance.new(expected)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/rspec-forward.gemspec
CHANGED
@@ -2,7 +2,7 @@ require_relative "lib/rspec/forward/version"
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "rspec-forward"
|
5
|
-
spec.version =
|
5
|
+
spec.version = RSpec::Forward::VERSION
|
6
6
|
spec.authors= ["Aleksader Długopolski"]
|
7
7
|
spec.email = ["ad@dotpro.org"]
|
8
8
|
|
@@ -39,4 +39,6 @@ Gem::Specification.new do |spec|
|
|
39
39
|
spec.bindir = "exe"
|
40
40
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
41
41
|
spec.require_paths = ["lib"]
|
42
|
+
|
43
|
+
spec.add_runtime_dependency "rspec-mocks", "~> 3.10"
|
42
44
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
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.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aleksader Długopolski
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
11
|
date: 2021-03-13 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec-mocks
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.10'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.10'
|
13
27
|
description: Set of RSpec matchers for checking class method to instnace method forwarding.
|
14
28
|
email:
|
15
29
|
- ad@dotpro.org
|
@@ -22,21 +36,23 @@ files:
|
|
22
36
|
- ".travis.yml"
|
23
37
|
- CODE_OF_CONDUCT.md
|
24
38
|
- Gemfile
|
39
|
+
- Gemfile.lock
|
25
40
|
- LICENSE.txt
|
26
41
|
- README.md
|
27
42
|
- Rakefile
|
28
43
|
- bin/console
|
29
44
|
- bin/setup
|
30
45
|
- lib/rspec/forward.rb
|
46
|
+
- lib/rspec/forward/forward_to_instance.rb
|
31
47
|
- lib/rspec/forward/version.rb
|
32
48
|
- rspec-forward.gemspec
|
33
|
-
homepage:
|
49
|
+
homepage:
|
34
50
|
licenses:
|
35
51
|
- MIT
|
36
52
|
metadata:
|
37
53
|
source_code_uri: https://github.com/adlugopolski/rspec-forward
|
38
54
|
changelog_uri: https://github.com/adlugopolski/rspec-forward/blob/master/CHANGELOG.md
|
39
|
-
post_install_message:
|
55
|
+
post_install_message:
|
40
56
|
rdoc_options: []
|
41
57
|
require_paths:
|
42
58
|
- lib
|
@@ -52,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
68
|
version: '0'
|
53
69
|
requirements: []
|
54
70
|
rubygems_version: 3.1.4
|
55
|
-
signing_key:
|
71
|
+
signing_key:
|
56
72
|
specification_version: 4
|
57
73
|
summary: Set of RSpec matchers for checking class method to instnace method forwarding.
|
58
74
|
test_files: []
|