|
241 | 241 | end
|
242 | 242 | end
|
243 | 243 |
|
244 |
| - context 'with display_detail_add on' do |
245 |
| - describe '#generate' do |
246 |
| - before(:all) do |
247 |
| - diff = [ |
248 |
| - [ |
249 |
| - '+', |
250 |
| - 'File[/tmp/foo]', |
251 |
| - { |
252 |
| - 'type' => 'File', |
253 |
| - 'title' => '/tmp/foo', |
254 |
| - 'parameters' => { |
255 |
| - 'mode' => '0644', |
256 |
| - 'content' => 'x' * 150, |
257 |
| - 'owner' => 'root', |
258 |
| - 'group' => 'wheel' |
259 |
| - } |
| 244 | + context 'with display_detail_add' do |
| 245 | + before(:all) do |
| 246 | + @diff = [ |
| 247 | + [ |
| 248 | + '+', |
| 249 | + 'File[/tmp/foo]', |
| 250 | + { |
| 251 | + 'type' => 'File', |
| 252 | + 'title' => '/tmp/foo', |
| 253 | + 'parameters' => { |
| 254 | + 'mode' => '0644', |
| 255 | + 'content' => 'x' * 150, |
| 256 | + 'owner' => 'root', |
| 257 | + 'group' => 'wheel' |
260 | 258 | }
|
261 |
| - ] |
| 259 | + } |
262 | 260 | ]
|
263 |
| - @result = OctocatalogDiff::CatalogDiff::Display::Text.generate(diff, display_detail_add: true, color: false) |
264 |
| - end |
265 |
| - |
266 |
| - it 'should display parameters when display_detail_add is true' do |
267 |
| - expect(@result[1]).to match(/^\s+parameters =>/) |
268 |
| - end |
| 261 | + ] |
| 262 | + end |
269 | 263 |
|
270 |
| - it 'should truncate long strings' do |
271 |
| - expect(@result[2]).to match(/^\s+"content": /) |
272 |
| - # Desired line length is 84 because the '..."' adds 4 characters to the truncated length of 80 |
273 |
| - expect(@result[2].length).to eq(84), "Wrong line length for: '#{@result[2]}'" |
| 264 | + context 'with --no-truncate-details' do |
| 265 | + describe '#generate' do |
| 266 | + before(:all) do |
| 267 | + @result = OctocatalogDiff::CatalogDiff::Display::Text.generate( |
| 268 | + @diff, |
| 269 | + display_detail_add: true, |
| 270 | + color: false, |
| 271 | + truncate_details: false |
| 272 | + ) |
| 273 | + end |
| 274 | + |
| 275 | + it 'should not truncate long strings' do |
| 276 | + expect(@result[2]).to match(/^\s+"content": /) |
| 277 | + expect(@result[2].length).to eq(169), "Wrong line length for: '#{@result[2]}': #{@result[2].length}" |
| 278 | + end |
274 | 279 | end
|
| 280 | + end |
275 | 281 |
|
276 |
| - it 'should sort keys in parameters hash' do |
277 |
| - index_content = @result.find_index { |x| x =~ /^\s+"content": / } |
278 |
| - expect(index_content).not_to be(nil), 'Results missing "content"' |
279 |
| - index_group = @result.find_index { |x| x =~ /^\s+"group": / } |
280 |
| - expect(index_group).not_to be(nil), 'Results missing "group"' |
281 |
| - index_mode = @result.find_index { |x| x =~ /^\s+"mode": / } |
282 |
| - expect(index_mode).not_to be(nil), 'Results missing "mode"' |
283 |
| - index_owner = @result.find_index { |x| x =~ /^\s+"owner": / } |
284 |
| - expect(index_owner).not_to be(nil), 'Results missing "owner"' |
285 |
| - expect(index_content).to be < index_group |
286 |
| - expect(index_group).to be < index_mode |
287 |
| - expect(index_mode).to be < index_owner |
| 282 | + context 'without --no-truncate-details' do |
| 283 | + describe '#generate' do |
| 284 | + before(:all) do |
| 285 | + @result = OctocatalogDiff::CatalogDiff::Display::Text.generate(@diff, display_detail_add: true, color: false) |
| 286 | + end |
| 287 | + |
| 288 | + it 'should display parameters when display_detail_add is true' do |
| 289 | + expect(@result[1]).to match(/^\s+parameters =>/) |
| 290 | + end |
| 291 | + |
| 292 | + it 'should truncate long strings' do |
| 293 | + expect(@result[2]).to match(/^\s+"content": /) |
| 294 | + # Desired line length is 84 because the '..."' adds 4 characters to the truncated length of 80 |
| 295 | + expect(@result[2].length).to eq(84), "Wrong line length for: '#{@result[2]}'" |
| 296 | + end |
| 297 | + |
| 298 | + it 'should sort keys in parameters hash' do |
| 299 | + index_content = @result.find_index { |x| x =~ /^\s+"content": / } |
| 300 | + expect(index_content).not_to be(nil), 'Results missing "content"' |
| 301 | + index_group = @result.find_index { |x| x =~ /^\s+"group": / } |
| 302 | + expect(index_group).not_to be(nil), 'Results missing "group"' |
| 303 | + index_mode = @result.find_index { |x| x =~ /^\s+"mode": / } |
| 304 | + expect(index_mode).not_to be(nil), 'Results missing "mode"' |
| 305 | + index_owner = @result.find_index { |x| x =~ /^\s+"owner": / } |
| 306 | + expect(index_owner).not_to be(nil), 'Results missing "owner"' |
| 307 | + expect(index_content).to be < index_group |
| 308 | + expect(index_group).to be < index_mode |
| 309 | + expect(index_mode).to be < index_owner |
| 310 | + end |
288 | 311 | end
|
289 | 312 | end
|
290 | 313 | end
|
|
0 commit comments