smart_params 5.1.0 → 6.0.1

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.
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SmartParams
4
- class Error
5
- class InvalidPropertyType < Error
6
- attr_reader :keychain
7
- attr_reader :wanted
8
- attr_reader :raw
9
- attr_reader :missing_key
10
-
11
- def initialize(keychain:, wanted:, raw:, missing_key: nil)
12
- super
13
- @keychain = keychain
14
- @wanted = wanted
15
- @raw = raw
16
- @missing_key = missing_key
17
- end
18
-
19
- def message
20
- if missing_key
21
- "expected #{keychain.inspect} to be #{wanted.name} with key #{missing_key.inspect}, but is #{raw.inspect}"
22
- else
23
- "expected #{keychain.inspect} to be #{wanted.name}, but is #{raw.inspect}"
24
- end
25
- end
26
-
27
- def as_json
28
- {
29
- "keychain" => keychain,
30
- "wanted" => wanted.name,
31
- "raw" => raw
32
- }
33
- end
34
- end
35
- end
36
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- RSpec.describe SmartParams::Error::InvalidPropertyType do
6
- describe "#message" do
7
- subject { error.message }
8
-
9
- context "when the error is about the type mismatch" do
10
- let(:error) { described_class.new(keychain: [:data], wanted: SmartParams::Strict::Hash, raw: "") }
11
-
12
- it "returns the message" do
13
- expect(subject).to eq("expected [:data] to be Hash, but is \"\"")
14
- end
15
- end
16
-
17
- context "when the error is about a missing key" do
18
- let(:error) { described_class.new(keychain: [:data], wanted: SmartParams::Strict::Hash.schema(data: SmartParams::Strict::String), raw: {}, missing_key: :data) }
19
-
20
- it "returns the message" do
21
- expect(subject).to eq("expected [:data] to be Hash with key :data, but is {}")
22
- end
23
- end
24
- end
25
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SmartParams
4
- class Error < StandardError
5
- require_relative "error/invalid_property_type"
6
- end
7
- end