test/test_characterizable.rb in characterizable-0.0.11 vs test/test_characterizable.rb in characterizable-0.0.12

- old
+ new

@@ -1,7 +1,11 @@ require 'helper' +# just to see if it hurts +require 'active_support/json' +require 'to_json_fix' + class Characterizable::Characteristic def hidden? !!options[:hidden] end end @@ -368,14 +372,42 @@ end should 'be nice to active_support to_json for characteristics (i.e. BetterHashes)' do a = Automobile.new a.make = 'Ford' - assert_equal "{\"make\":\"Ford\"}", a.characteristics.to_json + assert_nothing_raised do + a.characteristics.to_json + end end should 'be nice to active_support to_json for snapshots' do a = Automobile.new a.make = 'Ford' - assert_equal "{\"make\":{\"trumps\":[],\"name\":\"make\",\"options\":{},\"prerequisite\":null}}", a.characteristics.effective.to_json + assert_nothing_raised do + a.characteristics.effective.to_json + end + end + + should 'raise an exception if #has is called more than once in a single block' do + assert_raises ::Characterizable::CharacteristicAlreadyDefined do + class SimpleAutomobile3 + include Characterizable + attr_accessor :make + characterize do + has :make + has :make + end + end + end + end + + should 'raise an exception if #has is called more than once in a subclass' do + assert_raises ::Characterizable::CharacteristicAlreadyDefined do + class SimpleAutomobile2 < SimpleAutomobile + include Characterizable + characterize do + has :make + end + end + end end end