rspice 0.25.4 → 0.26.0.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b67418827d3db0b66d3b94cdd03a0b432dd6b12b8ebf46afa33dba211ce9d92e
|
4
|
+
data.tar.gz: cf3e0b4e415a1311dbfb79bea3308cd49c5caeb18353e1249ece16f223a9638d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13e8786266e4d9c5b0efe9523acf10a6c8cbe6d68c9553b93bf982438f4f22ad10c945062972cc133cefcef155379d0a71760c6530553fad2b29f99377da90de
|
7
|
+
data.tar.gz: 8175dafe73e7db8e313696c88ed363d1da66fc4a6603d72b4aaff5353886d68782b891b96bfb5fb486f754c2cec4f29a1a4d4998c3c798a9a5da16c131083477
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
A dash of custom matchers, a pinch of shared contexts, and shared examples (to taste) for RSpec
|
4
4
|
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/rspice.svg)](https://badge.fury.io/rb/rspice)
|
6
|
-
[![Build Status](https://semaphoreci.com/api/v1/freshly/spicerack/branches/
|
6
|
+
[![Build Status](https://semaphoreci.com/api/v1/freshly/spicerack/branches/main/badge.svg)](https://semaphoreci.com/freshly/spicerack)
|
7
7
|
[![Maintainability](https://api.codeclimate.com/v1/badges/7e089c2617c530a85b17/maintainability)](https://codeclimate.com/github/Freshly/spicerack/maintainability)
|
8
8
|
[![Test Coverage](https://api.codeclimate.com/v1/badges/7e089c2617c530a85b17/test_coverage)](https://codeclimate.com/github/Freshly/spicerack/test_coverage)
|
9
9
|
|
@@ -26,6 +26,8 @@ RSpec::Matchers.define :have_error_on_attribute do |attribute|
|
|
26
26
|
@errors = (record.errors.details[attribute.to_sym] || []).pluck(:error).map(&:to_sym)
|
27
27
|
|
28
28
|
expect(@errors).to include(@detail_key.to_sym)
|
29
|
+
|
30
|
+
expect { record.errors[attribute.to_sym] }.to_not raise_error
|
29
31
|
end
|
30
32
|
|
31
33
|
chain :with_detail_key do |detail_key|
|
@@ -34,7 +34,13 @@
|
|
34
34
|
RSpec.shared_examples_for "a class pass method" do |method|
|
35
35
|
subject do
|
36
36
|
if accepts_block?
|
37
|
-
|
37
|
+
if options.present?
|
38
|
+
call_class.public_send(method, *arguments, **options, &block)
|
39
|
+
else
|
40
|
+
call_class.public_send(method, *arguments, &block)
|
41
|
+
end
|
42
|
+
elsif options.present?
|
43
|
+
call_class.public_send(method, *arguments, **options)
|
38
44
|
else
|
39
45
|
call_class.public_send(method, *arguments)
|
40
46
|
end
|
@@ -47,13 +53,11 @@ RSpec.shared_examples_for "a class pass method" do |method|
|
|
47
53
|
let(:argument_arity) { method_parameters.map(&:first).select { |type| type.in?(%i[req opt]) }.length }
|
48
54
|
let(:option_keys) { method_parameters.select { |param| param.first.in?(%i[key keyreq]) }.map(&:last) }
|
49
55
|
let(:accepts_block?) { method_parameters.any? { |param| param.first == :block } }
|
56
|
+
let(:keyrest?) { method_parameters.any? { |param| param.first == :keyrest } }
|
50
57
|
|
51
|
-
let(:arguments)
|
52
|
-
|
53
|
-
|
54
|
-
end
|
55
|
-
end
|
56
|
-
let(:options) { option_keys.each_with_object({}) { |key, hash| hash[key] = Faker::Lorem.word } }
|
58
|
+
let(:arguments) { Array.new(argument_arity) { double } }
|
59
|
+
let(:keyrest_keys) { keyrest? ? Faker::Lorem.unique.words.map(&:to_sym) : [] }
|
60
|
+
let(:options) { (option_keys + keyrest_keys).each_with_object({}) { |key, hash| hash[key] = Faker::Lorem.word } }
|
57
61
|
let(:block) { -> {} }
|
58
62
|
let(:instance) { instance_double(test_class) }
|
59
63
|
let(:output) { double }
|
@@ -61,10 +65,26 @@ RSpec.shared_examples_for "a class pass method" do |method|
|
|
61
65
|
before do
|
62
66
|
allow(instance).to receive(method).and_return(output)
|
63
67
|
|
64
|
-
if
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
+
if arguments.present?
|
69
|
+
if options.present?
|
70
|
+
if accepts_block?
|
71
|
+
allow(test_class).to receive(:new).with(*arguments, **options, &block).and_return(instance)
|
72
|
+
else
|
73
|
+
allow(test_class).to receive(:new).with(*arguments, **options).and_return(instance)
|
74
|
+
end
|
75
|
+
elsif accepts_block?
|
76
|
+
allow(test_class).to receive(:new).with(*arguments, &block).and_return(instance)
|
77
|
+
else
|
78
|
+
allow(test_class).to receive(:new).with(*arguments).and_return(instance)
|
79
|
+
end
|
80
|
+
elsif options.present?
|
81
|
+
if accepts_block?
|
82
|
+
allow(test_class).to receive(:new).with(**options, &block).and_return(instance)
|
83
|
+
else
|
84
|
+
allow(test_class).to receive(:new).with(**options).and_return(instance)
|
85
|
+
end
|
86
|
+
elsif accepts_block?
|
87
|
+
allow(test_class).to receive(:new).with(&block).and_return(instance)
|
68
88
|
else
|
69
89
|
allow(test_class).to receive(:new).with(no_args).and_return(instance)
|
70
90
|
end
|
data/lib/rspice/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.26.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Garside
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2021-
|
14
|
+
date: 2021-04-28 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rspec
|
@@ -85,14 +85,14 @@ files:
|
|
85
85
|
- lib/rspice/shared_examples/an_inherited_property.rb
|
86
86
|
- lib/rspice/shared_examples/an_instrumented_event.rb
|
87
87
|
- lib/rspice/version.rb
|
88
|
-
homepage: https://github.com/Freshly/spicerack/tree/
|
88
|
+
homepage: https://github.com/Freshly/spicerack/tree/main/rspice
|
89
89
|
licenses:
|
90
90
|
- MIT
|
91
91
|
metadata:
|
92
|
-
homepage_uri: https://github.com/Freshly/spicerack/tree/
|
93
|
-
source_code_uri: https://github.com/Freshly/spicerack/tree/
|
94
|
-
changelog_uri: https://github.com/Freshly/spicerack/blob/
|
95
|
-
documentation_uri: https://www.rubydoc.info/gems/rspice/0.
|
92
|
+
homepage_uri: https://github.com/Freshly/spicerack/tree/main/rspice
|
93
|
+
source_code_uri: https://github.com/Freshly/spicerack/tree/main/rspice
|
94
|
+
changelog_uri: https://github.com/Freshly/spicerack/blob/main/rspice/CHANGELOG.md
|
95
|
+
documentation_uri: https://www.rubydoc.info/gems/rspice/0.26.0.2
|
96
96
|
post_install_message:
|
97
97
|
rdoc_options: []
|
98
98
|
require_paths:
|
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
|
-
rubygems_version: 3.1.
|
111
|
+
rubygems_version: 3.1.6
|
112
112
|
signing_key:
|
113
113
|
specification_version: 4
|
114
114
|
summary: An `RSpec` utility gem of custom matchers, shared contexts and examples
|