Sha256: bd87a407ebe878d4a2c52c39995ff3d2ae0deb7187e51eb5ed886ed734630f45
Contents?: true
Size: 1.59 KB
Versions: 16
Compression:
Stored size: 1.59 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') class ClassyEnumConversion < ClassyEnum::Base end class ClassyEnumConversion::One < ClassyEnumConversion end class ClassyEnumConversion::Two < ClassyEnumConversion end describe ClassyEnum::Conversion do context '#to_i' do specify { ClassyEnumConversion::One.new.to_i.should == 1 } specify { ClassyEnumConversion::Two.new.to_i.should == 2 } end context '#index' do specify { ClassyEnumConversion::One.new.index.should == 1 } specify { ClassyEnumConversion::Two.new.index.should == 2 } end context '#to_s' do specify { ClassyEnumConversion::One.new.to_s.should == 'one' } specify { ClassyEnumConversion::Two.new.to_s.should == 'two' } end context '#to_sym' do specify { ClassyEnumConversion::One.new.to_sym.should == :one } specify { ClassyEnumConversion::Two.new.to_sym.should == :two } end context '#as_json' do context 'serialize_as_json is false' do specify { ClassyEnumConversion::One.new.as_json.should == 'one' } specify { ClassyEnumConversion::Two.new.as_json.should == 'two' } end context 'serialize_as_json is true' do specify do enum = ClassyEnumConversion::One.new enum.serialize_as_json = true enum.instance_variable_set('@key', 'value') enum.as_json.should == {'key' => 'value' } end specify do enum = ClassyEnumConversion::One.new enum.serialize_as_json = true enum.instance_variable_set('@key', 'value') enum.as_json.should == {'key' => 'value' } end end end end
Version data entries
16 entries across 16 versions & 1 rubygems