rspice 0.6.1 → 0.6.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: 10a290b6a0edc7bb707796a7766f97f1798260f8cc883423a4a3a05c44a4f8eb
4
- data.tar.gz: 4b2e96d485deb24593ea985e31d8269d72e0777181bf5f17e1a8a36058979c67
3
+ metadata.gz: 4e9ed511ca6741cf645c3327a0d622ea81a0fc6f4584a1d99bb7c9fc8a1e08cf
4
+ data.tar.gz: 71eed99a74bb44e6b5b6a5081ac2a4ba7d626289998529f776a79bc579951a7d
5
5
  SHA512:
6
- metadata.gz: 47b861cc91c45bb535460a9d13c4533967d27e5b147fe51f16844d5d49122cae5d45b9a6fd102be520836d9fe8dba5b0cedda460ed5b6a19c251cefc5f70afc6
7
- data.tar.gz: e0bbe274f99f675de6f948355f08c0c6f9baf4f7f08ea58bcd86a66df32e83b001ed3bad73ed22fb65d2faf3080cc586673e20246c76a893b94dd3e6dc588425
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
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Rspice
4
4
  # This constant is managed by spicerack
5
- VERSION = "0.6.1"
5
+ VERSION = "0.6.2"
6
6
  end
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.1
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-25 00:00:00.000000000 Z
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