Added spec coverage for required values. Refer #7

This commit is contained in:
Nicholas Bruning 2015-07-22 14:58:04 +10:00
parent 288bfcc978
commit 1c3d10e407

View File

@ -68,6 +68,22 @@ describe Mongoid::Enum do
end
end
describe "'required' option" do
context "when true" do
let(:instance) { User.new status: nil }
it "is not valid with nil value" do
expect(instance).to_not be_valid
end
end
context "when false" do
let(:instance) { User.new roles: nil }
it "is valid with nil value" do
expect(instance).to be_valid
end
end
end
describe "constant" do
it "is set to the values" do
expect(klass::STATUS).to eq values