|
127 | 127 | end |
128 | 128 | end |
129 | 129 |
|
130 | | - it 'raises ArgumentError if any of the limit values are not Symbols' do |
131 | | - [['first', 'second', 'third'], [1, 2, 3], nil, []].each do |limit| |
132 | | - expect do |
133 | | - described_class.new(model, :status, :enum, limit: limit, null: false, position: 2) |
134 | | - end.to raise_exception(ArgumentError, /enum limit: must be an array of 1 or more Symbols; got #{Regexp.escape(limit.inspect)}/) |
| 130 | + describe 'default' do |
| 131 | + it 'allows default of nil or a Symbol' do |
| 132 | + [nil, :first].each do |default| |
| 133 | + expect do |
| 134 | + subject = described_class.new(model, :status, :enum, limit: [:first, :second, :third], default: default, null: false, position: 2) |
| 135 | + expect(subject.default).to eq(default) |
| 136 | + end.to_not raise_exception |
| 137 | + end |
| 138 | + end |
| 139 | + |
| 140 | + it 'raises ArgumentError if default is not nil or a Symbol' do |
| 141 | + ["first", 1].each do |default| |
| 142 | + expect do |
| 143 | + described_class.new(model, :status, :enum, limit: [:first, :second, :third], default: default, null: false, position: 2) |
| 144 | + end.to raise_exception(ArgumentError, /enum default: must be nil or a Symbol; got #{Regexp.escape(default.inspect)}/) |
| 145 | + end |
| 146 | + end |
| 147 | + end |
| 148 | + |
| 149 | + describe 'limit' do |
| 150 | + it 'raises ArgumentError if any of the limit values are not Symbols' do |
| 151 | + [['first', 'second', 'third'], [1, 2, 3], nil, []].each do |limit| |
| 152 | + expect do |
| 153 | + described_class.new(model, :status, :enum, limit: limit, null: false, position: 2) |
| 154 | + end.to raise_exception(ArgumentError, /enum limit: must be an array of 1 or more Symbols; got #{Regexp.escape(limit.inspect)}/) |
| 155 | + end |
135 | 156 | end |
136 | 157 | end |
137 | 158 | end |
|
0 commit comments