|
85 | 85 | it { is_expected.to include(maxLength: 1) }
|
86 | 86 | end
|
87 | 87 |
|
| 88 | + context 'when it contains values array' do |
| 89 | + let(:entity_options) { { documentation: { type: 'string', desc: 'Colors', values: %w[red blue] } } } |
| 90 | + |
| 91 | + it { is_expected.to_not include('minimum') } |
| 92 | + it { is_expected.to_not include('maximum') } |
| 93 | + end |
| 94 | + |
| 95 | + context 'when it contains values range' do |
| 96 | + let(:entity_options) { { documentation: { type: 'string', desc: 'Colors', values: 'a'...'c' } } } |
| 97 | + |
| 98 | + it { is_expected.to_not include('minimum') } |
| 99 | + it { is_expected.to_not include('maximum') } |
| 100 | + end |
| 101 | + |
88 | 102 | context 'when it contains extensions' do
|
89 | 103 | let(:entity_options) { { documentation: { type: 'string', desc: 'Colors', x: { some: 'stuff' } } } }
|
90 | 104 |
|
91 | 105 | it { is_expected.to include('x-some' => 'stuff') }
|
92 | 106 | end
|
93 | 107 | end
|
94 | 108 |
|
| 109 | + context 'when it is exposed as a number' do |
| 110 | + let(:entity_options) { { documentation: { type: 'number', desc: 'Solution pH' } } } |
| 111 | + |
| 112 | + it { is_expected.to include(type: 'number') } |
| 113 | + |
| 114 | + context 'when it contains minimum' do |
| 115 | + let(:entity_options) { { documentation: { type: 'number', desc: 'Solution pH', minimum: 2.5 } } } |
| 116 | + |
| 117 | + it { is_expected.to include(minimum: 2.5) } |
| 118 | + end |
| 119 | + |
| 120 | + context 'when it contains maximum' do |
| 121 | + let(:entity_options) { { documentation: { type: 'number', desc: 'Solution pH', maximum: 9.1 } } } |
| 122 | + |
| 123 | + it { is_expected.to include(maximum: 9.1) } |
| 124 | + end |
| 125 | + |
| 126 | + context 'when it contains values array' do |
| 127 | + let(:entity_options) { { documentation: { type: 'number', desc: 'Solution pH', values: [6.0, 7.0, 8.0] } } } |
| 128 | + |
| 129 | + it { is_expected.to_not include('minimum') } |
| 130 | + it { is_expected.to_not include('maximum') } |
| 131 | + end |
| 132 | + |
| 133 | + context 'when it contains values range' do |
| 134 | + let(:entity_options) { { documentation: { type: 'number', desc: 'Solution pH', values: 0.0..14.0 } } } |
| 135 | + |
| 136 | + it { is_expected.to include(minimum: 0.0, maximum: 14.0) } |
| 137 | + end |
| 138 | + |
| 139 | + context 'when it contains values range with no minimum' do |
| 140 | + let(:entity_options) { { documentation: { type: 'number', desc: 'Solution pH', values: ..14.0 } } } |
| 141 | + |
| 142 | + it { is_expected.to_not include('minimum') } |
| 143 | + it { is_expected.to include(maximum: 14.0) } |
| 144 | + end |
| 145 | + |
| 146 | + context 'when it contains values range with no maximum' do |
| 147 | + let(:entity_options) { { documentation: { type: 'number', desc: 'Solution pH', values: 0.0.. } } } |
| 148 | + |
| 149 | + it { is_expected.to_not include('maximum') } |
| 150 | + it { is_expected.to include(minimum: 0.0) } |
| 151 | + end |
| 152 | + |
| 153 | + context 'when it contains extensions' do |
| 154 | + let(:entity_options) { { documentation: { type: 'number', desc: 'Solution pH', x: { some: 'stuff' } } } } |
| 155 | + |
| 156 | + it { is_expected.to include('x-some' => 'stuff') } |
| 157 | + end |
| 158 | + end |
| 159 | + |
| 160 | + context 'when it is exposed as an integer' do |
| 161 | + let(:entity_options) { { documentation: { type: 'integer', desc: 'Count' } } } |
| 162 | + |
| 163 | + it { is_expected.to include(type: 'integer') } |
| 164 | + |
| 165 | + context 'when it contains minimum' do |
| 166 | + let(:entity_options) { { documentation: { type: 'integer', desc: 'Count', minimum: 2 } } } |
| 167 | + |
| 168 | + it { is_expected.to include(minimum: 2) } |
| 169 | + end |
| 170 | + |
| 171 | + context 'when it contains maximum' do |
| 172 | + let(:entity_options) { { documentation: { type: 'integer', desc: 'Count', maximum: 100 } } } |
| 173 | + |
| 174 | + it { is_expected.to include(maximum: 100) } |
| 175 | + end |
| 176 | + |
| 177 | + context 'when it contains values array' do |
| 178 | + let(:entity_options) { { documentation: { type: 'integer', desc: 'Count', values: 1..10 } } } |
| 179 | + |
| 180 | + it { is_expected.to_not include('minimum') } |
| 181 | + it { is_expected.to_not include('maximum') } |
| 182 | + end |
| 183 | + |
| 184 | + context 'when it contains values range' do |
| 185 | + let(:entity_options) { { documentation: { type: 'integer', desc: 'Count', values: 1..10 } } } |
| 186 | + |
| 187 | + it { is_expected.to include(minimum: 1, maximum: 10) } |
| 188 | + end |
| 189 | + |
| 190 | + context 'when it contains extensions' do |
| 191 | + let(:entity_options) { { documentation: { type: 'integer', desc: 'Count', x: { some: 'stuff' } } } } |
| 192 | + |
| 193 | + it { is_expected.to include('x-some' => 'stuff') } |
| 194 | + end |
| 195 | + end |
| 196 | + |
95 | 197 | context 'when it is exposed as an array' do
|
96 | 198 | let(:entity_options) { { documentation: { type: 'string', desc: 'Colors', is_array: true } } }
|
97 | 199 |
|
|
0 commit comments