|
102 | 102 |
|
103 | 103 | subject { generated_block } |
104 | 104 |
|
105 | | - context 'when is not required' do |
106 | | - let(:base_param_description_options) { { required: false } } |
| 105 | + context 'when required is true' do |
| 106 | + let(:base_param_description_options) { { required: true } } |
| 107 | + |
| 108 | + it 'does not output an option without default warning' do |
| 109 | + expect { subject }.not_to output( |
| 110 | + /is optional but default value is not specified/ |
| 111 | + ).to_stderr |
| 112 | + end |
| 113 | + end |
107 | 114 |
|
108 | | - context 'and no default is given' do |
109 | | - before { param_description_options.delete(:default) } |
| 115 | + context 'when required is false' do |
| 116 | + context 'when default_value is nil' do |
| 117 | + let(:base_param_description_options) do |
| 118 | + { required: false, default_value: nil } |
| 119 | + end |
110 | 120 |
|
111 | | - it 'outputs an option without default warning' do |
112 | | - expect { subject }.to output(/is optional but default value is not specified/).to_stderr |
| 121 | + it 'will not warn' do |
| 122 | + expect { subject }.not_to output( |
| 123 | + /is optional but default value is not specified/ |
| 124 | + ).to_stderr |
113 | 125 | end |
114 | 126 | end |
115 | | - end |
116 | 127 |
|
117 | | - context 'when is required' do |
118 | | - let(:base_param_description_options) { { required: true } } |
| 128 | + context 'when default_value is 123' do |
| 129 | + let(:base_param_description_options) do |
| 130 | + { required: false, default_value: 123 } |
| 131 | + end |
119 | 132 |
|
120 | | - it 'does not output an option without default warning' do |
121 | | - expect { subject }.not_to output(/is optional but default value is not specified/).to_stderr |
| 133 | + it 'will not warn' do |
| 134 | + expect { subject }.not_to output( |
| 135 | + /is optional but default value is not specified/ |
| 136 | + ).to_stderr |
| 137 | + end |
| 138 | + end |
| 139 | + |
| 140 | + context 'default_value not given' do |
| 141 | + let(:base_param_description_options) { { required: false } } |
| 142 | + |
| 143 | + it 'warns' do |
| 144 | + expect { subject }.to output( |
| 145 | + /is optional but default value is not specified/ |
| 146 | + ).to_stderr |
| 147 | + end |
122 | 148 | end |
123 | 149 | end |
124 | 150 | end |
|
0 commit comments