Sha256: 2caab1c7d47dcf18380d3606491d9ca559e8ac7385a444e26a4d17cd15503d1a

Contents?: true

Size: 666 Bytes

Versions: 3

Compression:

Stored size: 666 Bytes

Contents

# frozen_string_literal: true

module Spout
  module Tests
    module VariableTypeValidation
      VALID_VARIABLE_TYPES = %w(identifier choices integer numeric string text date time file datetime).sort

      def assert_variable_type(item)
        message = "#{item} invalid variable type. Valid types: #{VALID_VARIABLE_TYPES.join(', ')}"
        assert VALID_VARIABLE_TYPES.include?(item), message
      end

      Dir.glob("variables/**/*.json").each do |file|
        define_method("test_variable_type: #{file}") do
          assert_variable_type begin JSON.parse(File.read(file, encoding: "utf-8"))["type"] rescue nil end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spout-1.0.0 lib/spout/tests/variable_type_validation.rb
spout-1.0.0.beta3 lib/spout/tests/variable_type_validation.rb
spout-1.0.0.beta2 lib/spout/tests/variable_type_validation.rb