Sha256: f8a3abba81e873a9432939698b41577e8dfd41edb093ce33f8756286b01f2a2f
Contents?: true
Size: 1.6 KB
Versions: 8
Compression:
Stored size: 1.6 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') class ClassyEnumBase < ClassyEnum::Base end class ClassyEnumBase::One < ClassyEnumBase end class ClassyEnumBase::Two < ClassyEnumBase end describe ClassyEnum::Base do context '.build' do context 'invalid option' do it 'should return the option' do ClassyEnumBase.build(:invalid_option).should == :invalid_option end end context 'string option' do subject { ClassyEnumBase.build("one") } it { should be_a(ClassyEnumBase::One) } end context 'symbol option' do subject { ClassyEnumBase.build(:two) } it { should be_a(ClassyEnumBase::Two) } end context 'nil' do subject { ClassyEnumBase.build(nil) } it { should be_a(ClassyEnumBase) } it { should be_nil } it { should be_blank } end context 'empty string' do subject { ClassyEnumBase.build('') } it { should be_a(ClassyEnumBase) } it { should_not be_nil } it { should be_blank } end end context '#new' do subject { ClassyEnumBase::One } its(:new) { should be_a(ClassyEnumBase::One) } its(:new) { should == ClassyEnumBase::One.new } end context 'Subclass naming' do it 'should raise an error when invalid' do lambda { class WrongSublcassName < ClassyEnumBase; end }.should raise_error(ClassyEnum::SubclassNameError) end end end describe ClassyEnum::Base, 'Arel visitor' do specify do Arel::Visitors::ToSql.instance_methods.map(&:to_sym).should include(:'visit_ClassyEnumBase_One', :'visit_ClassyEnumBase_Two') end end
Version data entries
8 entries across 8 versions & 1 rubygems