Sha256: 2c631c43e43e5083604cdff32e117fdc209309cdb68a437c03cd0c6682727646
Contents?: true
Size: 629 Bytes
Versions: 13
Compression:
Stored size: 629 Bytes
Contents
# encoding: UTF-8 require File.expand_path("./helper", File.dirname(__FILE__)) class Order < Ohm::Model include Ohm::ExtraValidations attribute :state def validate assert_member :state, %w(pending authorized declined) end end test "validates for all members" do order = Order.new(:state => 'pending') assert order.valid? order = Order.new(:state => 'authorized') assert order.valid? order = Order.new(:state => 'declined') assert order.valid? end test "fails on a non-member" do order = Order.new(:state => 'foobar') assert ! order.valid? assert [[:state, :not_member]] == order.errors end
Version data entries
13 entries across 13 versions & 1 rubygems