|
65 | 65 | it 'allows getting the list of names as symbols' do
|
66 | 66 | expect(enum.names).to eq %i[RED GREEN BLUE]
|
67 | 67 | end
|
| 68 | + |
| 69 | + it 'defines to_s as name on the enums' do |
| 70 | + expect(enum.RED.to_s).to eq 'RED' |
| 71 | + expect(enum.GREEN.to_s).to eq 'GREEN' |
| 72 | + expect(enum.BLUE.to_s).to eq 'BLUE' |
| 73 | + end |
| 74 | + |
| 75 | + it 'defines inspect as a reasonable name on the enums' do |
| 76 | + expect(enum.RED.inspect).to eq '#<Enum:RED :red>' |
| 77 | + expect(enum.GREEN.inspect).to eq '#<Enum:GREEN :green>' |
| 78 | + expect(enum.BLUE.inspect).to eq '#<Enum:BLUE :blue>' |
| 79 | + end |
68 | 80 | end
|
69 | 81 |
|
70 | 82 | context 'with array attributes' do
|
|
115 | 127 | it 'allows getting the list of names as symbols' do
|
116 | 128 | expect(enum.names).to eq %i[RED GREEN BLUE]
|
117 | 129 | end
|
| 130 | + |
| 131 | + it 'defines to_s as name on the enums' do |
| 132 | + expect(enum.RED.to_s).to eq 'RED' |
| 133 | + expect(enum.GREEN.to_s).to eq 'GREEN' |
| 134 | + expect(enum.BLUE.to_s).to eq 'BLUE' |
| 135 | + end |
| 136 | + |
| 137 | + it 'defines inspect as a reasonable name on the enums' do |
| 138 | + expect(enum.RED.inspect).to eq '#<Enum:RED :red>' |
| 139 | + expect(enum.GREEN.inspect).to eq '#<Enum:GREEN :green>' |
| 140 | + expect(enum.BLUE.inspect).to eq '#<Enum:BLUE :blue>' |
| 141 | + end |
118 | 142 | end
|
119 | 143 |
|
120 | 144 | context 'with hash attributes' do
|
|
165 | 189 | it 'allows getting the list of names as symbols' do
|
166 | 190 | expect(enum.names).to eq %i[RED GREEN BLUE]
|
167 | 191 | end
|
| 192 | + |
| 193 | + it 'defines to_s as name on the enums' do |
| 194 | + expect(enum.RED.to_s).to eq 'RED' |
| 195 | + expect(enum.GREEN.to_s).to eq 'GREEN' |
| 196 | + expect(enum.BLUE.to_s).to eq 'BLUE' |
| 197 | + end |
| 198 | + |
| 199 | + it 'defines inspect as a reasonable string on the enums' do |
| 200 | + expect(enum.RED.inspect).to eq '#<Enum:RED "red">' |
| 201 | + expect(enum.GREEN.inspect).to eq '#<Enum:GREEN "green">' |
| 202 | + expect(enum.BLUE.inspect).to eq '#<Enum:BLUE "blue">' |
| 203 | + end |
168 | 204 | end
|
169 | 205 |
|
170 | 206 | context 'with hash attributes and an invalid definition' do
|
|
0 commit comments