Permalink
Browse files

Fix typo + test

  • Loading branch information...
1 parent 82e6c15 commit ac1c57b778fbed4b01941b0f692882ea2486496f @marcandre marcandre committed Jun 28, 2012
Showing with 9 additions and 4 deletions.
  1. +2 −2 lib/simple_enum.rb
  2. +2 −2 lib/simple_enum/mongoid.rb
  3. +5 −0 test/simple_enum_test.rb
View
@@ -45,7 +45,7 @@ def default_options
end
def included(base) #:nodoc:
- base.send :class_attribute, :enum_definitions, :instance_write => false, :instance_reader => false
+ base.send :class_attribute, :enum_definitions, :instance_writer => false, :instance_reader => false
base.enum_definitions = {}
base.send :extend, ClassMethods
end
@@ -214,7 +214,7 @@ def as_enum(enum_cd, values, options = {})
end
class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
- class_attribute #{enum_attr.inspect}, :instance_write => false, :instance_reader => false
+ class_attribute #{enum_attr.inspect}, :instance_writer => false, :instance_reader => false
def self.#{attr_name}(*args)
return #{enum_attr} if args.first.nil?
@@ -27,7 +27,7 @@ module Mongoid
included do
# create class level methods
- class_attribute :enum_definitions, :instance_write => false, :instance_reader => false
+ class_attribute :enum_definitions, :instance_writer => false, :instance_reader => false
enum_definitions = {}
end
@@ -49,4 +49,4 @@ def as_enum_with_mongoid(enum_cd, values, options = {})
alias_method_chain :as_enum, :mongoid
end
end
-end
+end
View
@@ -9,6 +9,11 @@ def test_reading_public_enum_definitions
assert_equal "gender_cd", Dummy.enum_definitions[:gender][:column]
end
+ def test_enum_definitions_only_available_from_class
+ assert_raises(NoMethodError) { Dummy.new.enum_definitions }
+ assert_raises(NoMethodError) { Dummy.new.enum_definitions= {} }
+ end
+
def test_getting_the_correct_integer_values_when_setting_to_symbol
d = Dummy.new
d.gender = :male

0 comments on commit ac1c57b

Please sign in to comment.