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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88be5297f72452972a9aef57325123dd9070d4a1ea4c1af9af6f33f009fd50be
4
- data.tar.gz: 89b5cec6552879279a4b114d1a0995719d9075b8e9e87501c3727e75b7263900
3
+ metadata.gz: 464cb05d93256eb809034b4fc8c729cc3fb7b6907177977bd87bf0c89b15d6a1
4
+ data.tar.gz: 4b017d1f408c460d05e01d2038a882d764a20384824eeb0743a3b47859163eff
5
5
  SHA512:
6
- metadata.gz: 1f2c2cad6d61d30ec6efb191b374621ed4482e7a491e06e2c3041a6a6e7ac855a35020dc4eb67278295e9993b7c43981752b70bbc2bc74544f7442783be63421
7
- data.tar.gz: 4feb0ed6d90a2f26f07648d1d109abf2628531c74ede0efce1d30d1f4de43d82c3a870b00ab552670d8eb2b2dbdd0a8bfaf22309ae7d47edd412d09c070642ec
6
+ metadata.gz: ddbf0f4d9fa61c70aba9fc0f3fcbc27389b1bc98cc2075f9e4e307c23f35897ff69c0980edb46a3a7d4c6641a832a74a885f58303f69b4ff9cfd2d1ff676e46a
7
+ data.tar.gz: 4d05adf7eaec87e2c11e7232f590b005c8938c44bd94a28842241a528b24a411e05ff4bcd9df6a224cb38cbcf6dd192d9f39515ba9db5783e9010de5e630714f
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- strict_fake (0.1.0)
4
+ strictly_fake (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -59,7 +59,7 @@ DEPENDENCIES
59
59
  rspec
60
60
  rubocop
61
61
  simplecov
62
- strict_fake!
62
+ strictly_fake!
63
63
 
64
64
  BUNDLED WITH
65
65
  2.1.4
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, of course, create a fake of a class, but it'll need to be explicitely "injected" into the consumer code;
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 isn't defined in PaymentGateway:
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.
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class StrictlyFake
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
@@ -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.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-24 00:00:00.000000000 Z
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.