Sha256: a9f5ce19867198f0859b134a9c4e110f9eb65b741d9b620e9a4a7d5e8f3cdc46

Contents?: true

Size: 864 Bytes

Versions: 9

Compression:

Stored size: 864 Bytes

Contents

require 'spec_helper'

RSpec.describe GraphqlDevise::MountMethod::OptionSanitizers::StringChecker do
  describe '#call!' do
    subject(:clean_value) { described_class.new(default_string).call!(value, key) }

    let(:key)            { :any_option }
    let(:default_string) { 'default string' }

    context 'when no value is provided' do
      let(:value) { nil }

      it { is_expected.to eq(default_string) }
    end

    context 'when provided value is not a String' do
      let(:value) { 1000 }

      it 'raises an error' do
        expect { clean_value }.to raise_error(GraphqlDevise::InvalidMountOptionsError, "`#{key}` option has an invalid value. String expected.")
      end
    end

    context 'when provided array contains all valid elements' do
      let(:value) { 'custom valid string' }

      it { is_expected.to eq(value) }
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
graphql_devise-0.12.3 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-0.12.2 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-0.12.1 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-0.12.0 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-0.11.4 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-0.11.3 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-0.11.2 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-0.11.1 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-0.11.0 spec/services/mount_method/option_sanitizers/string_checker_spec.rb