Sha256: b9ec1908aadc39289c9ee929cdf078ca9ea6820a368c37edc7a564c494460c9a

Contents?: true

Size: 702 Bytes

Versions: 8

Compression:

Stored size: 702 Bytes

Contents

module Spout
  module Tests
    module VariableTypeValidation
      VALID_VARIABLE_TYPES = ['identifier', 'choices', 'integer', 'numeric', 'string', 'text', 'date', 'time', 'file'].sort

      def assert_variable_type(item, msg = nil)
        full_message = build_message(msg, "? invalid variable type. Valid types: #{VALID_VARIABLE_TYPES.join(', ')}", item)
        assert_block(full_message) do
          VALID_VARIABLE_TYPES.include?(item)
        end
      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

8 entries across 8 versions & 1 rubygems

Version Path
spout-0.3.0.rc3 lib/spout/tests/variable_type_validation.rb
spout-0.3.0.rc2 lib/spout/tests/variable_type_validation.rb
spout-0.3.0.rc lib/spout/tests/variable_type_validation.rb
spout-0.2.0 lib/spout/tests/variable_type_validation.rb
spout-0.1.0 lib/spout/tests/variable_type_validation.rb
spout-0.1.0.rc5 lib/spout/tests/variable_type_validation.rb
spout-0.1.0.rc4 lib/spout/tests/variable_type_validation.rb
spout-0.1.0.rc3 lib/spout/tests/variable_type_validation.rb