Sha256: eb0c57cf738cad2058178f90d6e291ce264ba9d64eb7735ddd88f2608cdb1ec7

Contents?: true

Size: 647 Bytes

Versions: 10

Compression:

Stored size: 647 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))["type"] rescue nil end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
spout-1.0.0.beta1 lib/spout/tests/variable_type_validation.rb
spout-0.14.1 lib/spout/tests/variable_type_validation.rb
spout-0.14.0 lib/spout/tests/variable_type_validation.rb
spout-0.14.0.rc lib/spout/tests/variable_type_validation.rb
spout-0.14.0.beta3 lib/spout/tests/variable_type_validation.rb
spout-0.14.0.beta2 lib/spout/tests/variable_type_validation.rb
spout-0.14.0.beta1 lib/spout/tests/variable_type_validation.rb
spout-0.13.0 lib/spout/tests/variable_type_validation.rb
spout-0.13.0.beta2 lib/spout/tests/variable_type_validation.rb
spout-0.13.0.beta1 lib/spout/tests/variable_type_validation.rb