1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activesupport/test/ordered_options_test.rb
David Heinemeier Hansson d994b41a05 Added method access to OrdredOptions
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2422 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-09-30 07:14:37 +00:00

55 lines
1.2 KiB
Ruby

require 'test/unit'
require File.dirname(__FILE__) + '/../lib/active_support/ordered_options'
class OrderedOptionsTest < Test::Unit::TestCase
def test_usage
a = OrderedOptions.new
assert_nil a[:not_set]
a[:allow_concurreny] = true
assert_equal 1, a.size
assert a[:allow_concurreny]
a[:allow_concurreny] = false
assert_equal 1, a.size
assert !a[:allow_concurreny]
a["else_where"] = 56
assert_equal 2, a.size
assert_equal 56, a[:else_where]
end
def test_looping
a = OrderedOptions.new
a[:allow_concurreny] = true
a["else_where"] = 56
test = [[:allow_concurreny, true], [:else_where, 56]]
a.each_with_index do |(key, value), index|
assert_equal test[index].first, key
assert_equal test[index].last, value
end
end
def test_method_access
a = OrderedOptions.new
assert_nil a.not_set
a.allow_concurreny = true
assert_equal 1, a.size
assert a.allow_concurreny
a.allow_concurreny = false
assert_equal 1, a.size
assert !a.allow_concurreny
a.else_where = 56
assert_equal 2, a.size
assert_equal 56, a.else_where
end
end