rspice 0.6.1 → 0.6.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/lib/rspice/custom_matchers/have_error_with_detail_key.rb +39 -0
- data/lib/rspice/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e9ed511ca6741cf645c3327a0d622ea81a0fc6f4584a1d99bb7c9fc8a1e08cf
|
4
|
+
data.tar.gz: 71eed99a74bb44e6b5b6a5081ac2a4ba7d626289998529f776a79bc579951a7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 762802315143cc3686e0c0542e26dbfd51d2d8679b08d01ff3a1ea14e7e0e5d21bc670e5dc350df5a88f92eb98a6dabb1114214db4c6bebe21ca27ef74799aaf
|
7
|
+
data.tar.gz: a7bf5390d49d7c745b0707ea6fe1c7f66e4ee62866485bb9130c7004c78dcc5b71772f465886209c521c449f49e054a9ce74d1c4d43f66563aa7c311a126178d
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# RSpec matcher to test activities.
|
4
|
+
#
|
5
|
+
# Usage:
|
6
|
+
#
|
7
|
+
# RSpec.describe ApplicationRecord, type: :model do
|
8
|
+
# subject { described_class.new }
|
9
|
+
#
|
10
|
+
# before { # put record in invalid statae }
|
11
|
+
#
|
12
|
+
# it { is_expected.to have_error_on_attribute(:foo).with_detail_key(:bar) }
|
13
|
+
# end
|
14
|
+
|
15
|
+
RSpec::Matchers.define :have_error_on_attribute do |attribute|
|
16
|
+
match do |record|
|
17
|
+
raise ArgumentError, "have_error_on_attribute matcher requires a detail_key" if @detail_key.blank?
|
18
|
+
|
19
|
+
errors = (record.errors.details[attribute.to_sym] || []).pluck(:error)
|
20
|
+
|
21
|
+
expect(errors).to include(@detail_key)
|
22
|
+
end
|
23
|
+
|
24
|
+
chain :with_detail_key do |detail_key|
|
25
|
+
@detail_key = detail_key
|
26
|
+
end
|
27
|
+
|
28
|
+
description do
|
29
|
+
"have_error_on_attribute #{attribute} with_detail_key #{@detail_key.inspect}"
|
30
|
+
end
|
31
|
+
|
32
|
+
failure_message do |record|
|
33
|
+
"expected #{record} to have error on attribute #{attribute} with detail key #{@detail_key.inspect}"
|
34
|
+
end
|
35
|
+
|
36
|
+
failure_message_when_negated do |record|
|
37
|
+
"expected #{record} not to have error on attribute #{attribute} with detail key #{@detail_key.inspect}"
|
38
|
+
end
|
39
|
+
end
|
data/lib/rspice/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Garside
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- lib/rspice/custom_matchers.rb
|
52
52
|
- lib/rspice/custom_matchers/alias_method.rb
|
53
53
|
- lib/rspice/custom_matchers/extend_module.rb
|
54
|
+
- lib/rspice/custom_matchers/have_error_with_detail_key.rb
|
54
55
|
- lib/rspice/custom_matchers/include_module.rb
|
55
56
|
- lib/rspice/custom_matchers/inherit_from.rb
|
56
57
|
- lib/rspice/shared_context.rb
|