spec/lib/abstractivator/enum_spec.rb in abstractivator-0.0.25 vs spec/lib/abstractivator/enum_spec.rb in abstractivator-0.0.26
- old
+ new
@@ -10,10 +10,12 @@
define_enum(:Fruits, :apple, :orange)
define_enum(:Vegetables, cucumber: 'Cucumis sativus', eggplant: 8)
end
+define_enum(:Meats, :bacon, :more_bacon)
+
describe Enum do
describe '::values' do
it 'enumerates the values' do
expect(Container::Traditional.values).to eql %w(foo bar)
end
@@ -56,9 +58,12 @@
it 'values know their parent' do
expect(Container::Fruits::APPLE.enum_type).to eql Container::Fruits
expect(Container::Fruits::ORANGE.enum_type).to eql Container::Fruits
expect(Container::Vegetables::CUCUMBER.enum_type).to eql Container::Vegetables
expect(Container::Vegetables::EGGPLANT.enum_type).to eql Container::Vegetables
+ end
+ it 'can define top level enumerations' do
+ expect(Meats.values).to eql %w(bacon more_bacon)
end
it 'raises an error when called with bad arguments' do
expect{define_enum(:Stuff, 5)}.to raise_error /Arguments must be/
expect{define_enum(:Stuff, '!@$' => '')}.to raise_error /Arguments must be/
end