Sha256: bd3b70d157f4cc7427d3dfef78d8069ae67445cea1af0b2874a21dad93e71860
Contents?: true
Size: 1.15 KB
Versions: 26
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true require 'spec_helper' RSpec.describe GraphqlDevise::MountMethod::OptionSanitizers::ArrayChecker do describe '#call!' do subject(:clean_value) { described_class.new(element_type).call!(value, key) } let(:key) { :any_option } let(:element_type) { Symbol } context 'when no value is provided' do let(:value) { nil } it { is_expected.to eq([]) } end context 'when provided value is not an array' do let(:value) { 'not an array' } it 'raises an error' do expect { clean_value }.to raise_error(GraphqlDevise::InvalidMountOptionsError, "`#{key}` option has an invalid value. Array expected.") end end context 'when provided array contains invalid elements' do let(:value) { [:valid, 'invalid'] } it 'raises an error' do expect { clean_value }.to raise_error(GraphqlDevise::InvalidMountOptionsError, "`#{key}` option has invalid elements. #{element_type} expected.") end end context 'when provided array contains all valid elements' do let(:value) { [:valid1, :valid2] } it { is_expected.to eq(value) } end end end
Version data entries
26 entries across 26 versions & 1 rubygems