Sha256: c107d4b4b1c4d4df5f51dd3ff5d6638fc3539fbc5467942cc9d1e4eb6abd2180

Contents?: true

Size: 1.54 KB

Versions: 3

Compression:

Stored size: 1.54 KB

Contents

# -*- coding: utf-8 -*-

module DataMapper
  module Validate
    module Fixtures
      class BasketballCourt
        #
        # Behaviors
        #

        include DataMapper::Resource

        #
        # Properties
        #

        property :id,     Serial

        without_auto_validations do
          property :name,   String

          property :length, Float
          property :width,  Float

          property :three_point_line_distance,  Float
          property :free_throw_line_distance,   Float
          property :rim_height,                 Float
        end

        #
        # Validations
        #

        # obviously these are all metrics
        validates_is_number :length, :gte => 15.0,  :lte => 15.24
        validates_is_number :width,  :gte => 25.28, :lte => 28.65

        # 3 pt line distance may use :gte and :lte, but for
        # sake of spec example we make it up a little
        validates_is_number :three_point_line_distance, :gt => 6.7, :lt => 7.24
        validates_is_number :free_throw_line_distance,  :equals => 4.57
        validates_is_number :rim_height,                :eq     => 3.05

        def self.valid_instance(overrides = {})
          defaults = {
            :length                    => 15.24,
            :width                     => 28.65,
            :free_throw_line_distance  => 4.57,
            :rim_height                => 3.05,
            :three_point_line_distance => 6.9
          }

          new(defaults.merge(overrides))
        end
      end
    end # Fixtures
  end # Validate
end # DataMapper

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dm-validations-0.10.2 spec/fixtures/basketball_court.rb
dm-validations-0.10.1 spec/fixtures/basketball_court.rb
dm-validations-0.10.0 spec/fixtures/basketball_court.rb