Sha256: 5b39054b169fee34255c287f27509ca07e89d4a20ca2dd9eab16906d9bca6d73

Contents?: true

Size: 895 Bytes

Versions: 26

Compression:

Stored size: 895 Bytes

Contents

# frozen_string_literal: true

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

26 entries across 26 versions & 1 rubygems

Version Path
graphql_devise-2.0.0 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-1.4.0 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-1.3.0 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-1.2.0 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-1.1.1 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-1.1.0 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-1.0.1 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-1.0.0 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-0.18.2 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-0.18.1 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-0.18.0 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-0.17.1 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-0.17.0 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-0.16.0 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-0.15.0 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-0.14.3 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-0.14.2 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-0.14.1 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-0.14.0 spec/services/mount_method/option_sanitizers/string_checker_spec.rb
graphql_devise-0.13.6 spec/services/mount_method/option_sanitizers/string_checker_spec.rb