strictly_fake 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +11 -4
- data/lib/strictly_fake.rb +4 -3
- data/lib/strictly_fake/version.rb +1 -1
- data/strictly_fake.gemspec +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 464cb05d93256eb809034b4fc8c729cc3fb7b6907177977bd87bf0c89b15d6a1
|
4
|
+
data.tar.gz: 4b017d1f408c460d05e01d2038a882d764a20384824eeb0743a3b47859163eff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddbf0f4d9fa61c70aba9fc0f3fcbc27389b1bc98cc2075f9e4e307c23f35897ff69c0980edb46a3a7d4c6641a832a74a885f58303f69b4ff9cfd2d1ff676e46a
|
7
|
+
data.tar.gz: 4d05adf7eaec87e2c11e7232f590b005c8938c44bd94a28842241a528b24a411e05ff4bcd9df6a224cb38cbcf6dd192d9f39515ba9db5783e9010de5e630714f
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# StrictlyFake [![Build Status](https://travis-ci.org/featurist/strictly_fake.svg?branch=master)](https://travis-ci.org/featurist/strictly_fake)
|
1
|
+
# StrictlyFake [![Build Status](https://travis-ci.org/featurist/strictly_fake.svg?branch=master)](https://travis-ci.org/featurist/strictly_fake) [![Gem Version](https://badge.fury.io/rb/strictly_fake.svg)](https://badge.fury.io/rb/strictly_fake)
|
2
2
|
|
3
3
|
Sometimes fakes are a good choice. But the price is high. In particular, they make changing code harder. You rename a method, but all tests that stub the previous version _keep_ passing. It would be nice if those started to fail so that when they're green again, you can be certain that everything that had to be updated was updated. Well, now you can.
|
4
4
|
|
@@ -6,8 +6,8 @@ To be fair, you already can in Rspec with their [verifying double](https://relis
|
|
6
6
|
|
7
7
|
- here you need to supply real objects to create fakes. That's controversial - as it goes against the idea of testing in isolation - but realistically, at least in Rails, everything is loaded anyway, so that's a moot point;
|
8
8
|
- strictly_fake is aware of autogenerated methods (e.g. ActiveRecord model accessors);
|
9
|
-
- strictly_fake does not stub constants (e.g. classes). You can,
|
10
|
-
- strictly_fake performs a full parameter check, comparing required, optional and keyword arguments (veryfing double only checks arity).
|
9
|
+
- strictly_fake does not stub constants (e.g. classes). You can, however, pass a fake to Minitest's `Object#stub` to achieve this (see example below);
|
10
|
+
- strictly_fake performs a full parameter check, comparing required, optional and keyword arguments (veryfing double only checks arity afaik).
|
11
11
|
|
12
12
|
## Installation
|
13
13
|
|
@@ -36,7 +36,7 @@ end
|
|
36
36
|
# We can use a fake instead
|
37
37
|
payment_gateway = StrictlyFake.new(PaymentGateway.new)
|
38
38
|
|
39
|
-
# Let's stub a method that
|
39
|
+
# Let's stub a method that _isn't_ defined in PaymentGateway:
|
40
40
|
payment_gateway.stub(:bar)
|
41
41
|
# => throws "Can't stub non-existent method PaymentGateway#bar (StrictlyFake::Error)"
|
42
42
|
|
@@ -60,6 +60,7 @@ end
|
|
60
60
|
|
61
61
|
payment_gateway.pay('Dave', Money.new(10))
|
62
62
|
assert(invoked)
|
63
|
+
# => Pass
|
63
64
|
|
64
65
|
# Stubbing class methods is no different
|
65
66
|
time = StrictlyFake.new(Time)
|
@@ -67,6 +68,12 @@ time = StrictlyFake.new(Time)
|
|
67
68
|
time.stub(:now) { 'XYZ' }
|
68
69
|
time.now
|
69
70
|
# => 'XYZ'
|
71
|
+
|
72
|
+
# Combine with Minitest stub to actually stub constant
|
73
|
+
Time.stub :now, time.now do
|
74
|
+
Time.now
|
75
|
+
# => 'XYZ'
|
76
|
+
end
|
70
77
|
```
|
71
78
|
|
72
79
|
Note: Minitest is required for `assert*` to work.
|
data/lib/strictly_fake.rb
CHANGED
@@ -41,8 +41,8 @@ class StrictlyFake
|
|
41
41
|
end
|
42
42
|
|
43
43
|
# rubocop:disable Lint/MissingSuper
|
44
|
-
def method_missing(meth, *args)
|
45
|
-
@fake.send(meth, *args)
|
44
|
+
def method_missing(meth, *args, &block)
|
45
|
+
@fake.send(meth, *args, &block)
|
46
46
|
end
|
47
47
|
# rubocop:enable Lint/MissingSuper
|
48
48
|
|
@@ -92,7 +92,8 @@ class StrictlyFake
|
|
92
92
|
rest: '*rest',
|
93
93
|
key: ":#{name}",
|
94
94
|
keyreq: ":#{name}",
|
95
|
-
keyrest: '**keyrest'
|
95
|
+
keyrest: '**keyrest',
|
96
|
+
block: '&block'
|
96
97
|
}.fetch(type)
|
97
98
|
end.join(', ')
|
98
99
|
end
|
data/strictly_fake.gemspec
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative 'lib/strictly_fake/version'
|
4
4
|
|
5
|
+
# rubocop:disable Layout/LineLength
|
5
6
|
Gem::Specification.new do |spec|
|
6
7
|
spec.name = 'strictly_fake'
|
7
8
|
spec.version = StrictlyFake::VERSION
|
@@ -26,3 +27,4 @@ Gem::Specification.new do |spec|
|
|
26
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
28
|
spec.require_paths = ['lib']
|
28
29
|
end
|
30
|
+
# rubocop:enable Layout/LineLength
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strictly_fake
|
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
|
- artemave
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Stub that automatically verifies that stubbed methods exist and the signatures
|
14
14
|
match the original.
|