haveapi-client 0.29.4 → 0.29.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd152485887e7737693110495d6bdd627db3d43aa5cb81ffb96619d59473f704
4
- data.tar.gz: 9914768b6f5b145929fe6c257de001b9c6f26a9d8fabac689790f5037092a621
3
+ metadata.gz: d2bd2997fa01f67713bf17e28740a8a24363f40daf8a3707868495bd2edbb863
4
+ data.tar.gz: ecbfda7acc42a0d0e782de2f80f6cdd0c3d92b1fcbecbcfa307ead6939e8d2ad
5
5
  SHA512:
6
- metadata.gz: db8e0e7a6c327e7b9ad96350051fc62d0bf89bd26a5c38ffb7551ec36daac13b34b349e3c03dd209511da015bd5042ad8bcfc4ae9fa75617f3e8c9e2038258df
7
- data.tar.gz: dedb09777b253bb7076c46660c3399bc1a352184fc9956bc41ae8168173fe415acc3566ae0af177bbc8ee45e4a3450c4a6157f45d5ca5a2c0f16ac214aa219dd
6
+ metadata.gz: 3fa58eb4ff7603855c2214cbc26e2116128c65cf0720043601bd913dd004a721d43b6290fcc58e0c5b36d41f47b08dc8326bb7b59267de3652f3b6824104cf18
7
+ data.tar.gz: da464e8a0826c3bfebf2a6e622fa3e9fa45d1574f38e5c0b91b56142a023feedff5c57b090e1f6144cbed8e838717cb1f90d39e96475c93fd01a945fa8dfcfb8
@@ -6,7 +6,7 @@ module HaveAPI::Client
6
6
 
7
7
  def valid?
8
8
  if opts[:values].is_a?(::Hash)
9
- opts[:values].keys.include?(value)
9
+ opts[:values].keys.any? { |v| v.to_s == value.to_s }
10
10
 
11
11
  else
12
12
  opts[:values].include?(value)
@@ -1,6 +1,6 @@
1
1
  module HaveAPI
2
2
  module Client
3
3
  PROTOCOL_VERSION = '2.0'.freeze
4
- VERSION = '0.29.4'.freeze
4
+ VERSION = '0.29.5'.freeze
5
5
  end
6
6
  end
data/spec/i18n_spec.rb CHANGED
@@ -33,4 +33,17 @@ RSpec.describe HaveAPI::Client::Client do
33
33
  expect(err.errors[:i]).to include('není platné celé číslo')
34
34
  end
35
35
  end
36
+
37
+ it 'accepts a value from localized choice metadata' do
38
+ client = described_class.new(TEST_SERVER.base_url, language: 'cs')
39
+ values = client.test.actions[:echo_choice]
40
+ .input_params[:format]
41
+ .dig(:validators, :include, :values)
42
+
43
+ expect(values).to eq(archive: 'Archiv', stream: 'Proud')
44
+
45
+ response = client.test.echo_choice(format: 'archive')
46
+
47
+ expect(response[:format]).to eq('archive')
48
+ end
36
49
  end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe HaveAPI::Client::Validators::Inclusion do
6
+ subject(:validator) do
7
+ described_class.new(
8
+ { values: values, message: 'not included' },
9
+ value,
10
+ other_params
11
+ )
12
+ end
13
+
14
+ let(:other_params) { Struct.new(:params).new({}) }
15
+
16
+ context 'with an array of values' do
17
+ let(:values) { %w[archive stream] }
18
+
19
+ it 'uses exact membership' do
20
+ expect(described_class.new(
21
+ { values: values, message: 'not included' },
22
+ 'archive',
23
+ other_params
24
+ )).to be_valid
25
+ expect(described_class.new(
26
+ { values: values, message: 'not included' },
27
+ :archive,
28
+ other_params
29
+ )).not_to be_valid
30
+ end
31
+ end
32
+
33
+ context 'with a map of labeled values' do
34
+ let(:values) { { archive: 'Archive', stream: 'Stream' } }
35
+
36
+ context 'with a matching string value' do
37
+ let(:value) { 'archive' }
38
+
39
+ it { is_expected.to be_valid }
40
+ end
41
+
42
+ context 'with a missing string value' do
43
+ let(:value) { 'incremental_stream' }
44
+
45
+ it { is_expected.not_to be_valid }
46
+ end
47
+ end
48
+
49
+ context 'with a numeric map key parsed from JSON' do
50
+ let(:values) { { '1': 'One', '2': 'Two' } }
51
+ let(:value) { 1 }
52
+
53
+ it { is_expected.to be_valid }
54
+ end
55
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haveapi-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.29.4
4
+ version: 0.29.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakub Skokan
@@ -164,6 +164,7 @@ files:
164
164
  - spec/load_spec.rb
165
165
  - spec/spec_helper.rb
166
166
  - spec/support/test_server.rb
167
+ - spec/validators/inclusion_spec.rb
167
168
  homepage: ''
168
169
  licenses:
169
170
  - MIT