Sha256: c22887edaa776d421730c46a58f05235968f294417285e19ff931688df610022

Contents?: true

Size: 654 Bytes

Versions: 6

Compression:

Stored size: 654 Bytes

Contents

module Matchers
  module Type
    class EnumMatcher < TypeMatcher
      def initialize( attribute, valid_hash, enum_type, enum_types, nonsense_value: 'NONSENSE'.freeze )
        valid_value = Fortnox::API::Types.const_get(enum_types).values.first

        super( attribute, valid_hash, enum_type, valid_value, nonsense_value )

        @enum_type = Fortnox::API::Types.const_get(enum_type)
        @expected_error = "Exception missing for nonsense value #{ @invalid_value.inspect }"
      end

      private

        def expected_type?
          @actual_type = @klass.schema[@attribute]
          @actual_type == @enum_type
        end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fortnox-api-0.5.2 spec/support/matchers/type/enum_matcher.rb
fortnox-api-0.5.1 spec/support/matchers/type/enum_matcher.rb
fortnox-api-0.5.0 spec/support/matchers/type/enum_matcher.rb
fortnox-api-0.4.0 spec/support/matchers/type/enum_matcher.rb
fortnox-api-0.3.0 spec/support/matchers/type/enum_matcher.rb
fortnox-api-0.2.0 spec/support/matchers/type/enum_matcher.rb