|
377 | 377 | expect(offenses).to be(:empty?) |
378 | 378 | end |
379 | 379 | end |
380 | | - |
| 380 | + |
381 | 381 | with "a heredoc with correct body indentation" do |
382 | 382 | let(:source) {"def foo\n\tputs <<~FOO\n\t\tHello\n\t\tWorld\n\tFOO\nend\n"} |
383 | 383 | it "does not register an offense for properly indented heredoc body" do |
|
388 | 388 | expect(offenses).to be(:empty?) |
389 | 389 | end |
390 | 390 | end |
391 | | - |
| 391 | + |
392 | 392 | with "a heredoc with incorrect body indentation" do |
393 | 393 | let(:source) {"def foo\n\tputs <<~FOO\n\n\t\tHello World\n\tFOO\nend\n"} |
394 | 394 | it "registers an offense for unindented heredoc body" do |
|
399 | 399 | expect(offenses).not.to be(:empty?) |
400 | 400 | end |
401 | 401 | end |
402 | | - |
| 402 | + |
403 | 403 | with "a non-squiggly heredoc with any indentation" do |
404 | 404 | let(:source) {"def foo\n\tputs <<-FOO\n\t\tHello\n\t\tWorld\n\tFOO\nend\n"} |
405 | 405 | it "does not register an offense for non-squiggly heredoc content" do |
|
410 | 410 | expect(offenses).to be(:empty?) |
411 | 411 | end |
412 | 412 | end |
413 | | - |
| 413 | + |
414 | 414 | with "a plain heredoc with any indentation" do |
415 | 415 | let(:source) {"def foo\n\tputs <<FOO\n\t\tHello\n\t\tWorld\n\tFOO\nend\n"} |
416 | 416 | it "does not register an offense for plain heredoc content" do |
|
421 | 421 | expect(offenses).to be(:empty?) |
422 | 422 | end |
423 | 423 | end |
424 | | - |
| 424 | + |
425 | 425 | with "an interpolated string" do |
426 | 426 | let(:source) {"def foo\n\tname = 'world'\n\tputs \"Hello \#{name}\"\n\t\n\tputs 'done'\nend\n"} |
427 | 427 | it "does not interfere with blank line indentation for interpolated strings" do |
|
432 | 432 | expect(offenses).to be(:empty?) |
433 | 433 | end |
434 | 434 | end |
| 435 | + |
| 436 | + with "a blank line in if/elsif/else clauses with proper indentation" do |
| 437 | + let(:source) {"if foo\n\t\n\tputs 'foo'\nelsif bar\n\t\n\tputs 'bar'\nelse\n\t\n\tputs 'else'\nend\n"} |
| 438 | + it "does not register an offense when blank lines are properly indented" do |
| 439 | + processed_source = RuboCop::ProcessedSource.new(source, RUBY_VERSION.to_f) |
| 440 | + investigator = RuboCop::Cop::Commissioner.new([cop], [], raise_error: true) |
| 441 | + report = investigator.investigate(processed_source) |
| 442 | + offenses = report.offenses |
| 443 | + expect(offenses).to be(:empty?) |
| 444 | + end |
| 445 | + end |
| 446 | + |
| 447 | + with "a blank line in if/elsif/else clauses with incorrect indentation" do |
| 448 | + let(:source) {"if foo\n\t\n\tputs 'foo'\nelsif bar\n\t\t\n\tputs 'bar'\nelse\n\t\n\tputs 'else'\nend\n"} |
| 449 | + it "registers an offense when blank line in elsif is over-indented" do |
| 450 | + processed_source = RuboCop::ProcessedSource.new(source, RUBY_VERSION.to_f) |
| 451 | + investigator = RuboCop::Cop::Commissioner.new([cop], [], raise_error: true) |
| 452 | + report = investigator.investigate(processed_source) |
| 453 | + offenses = report.offenses |
| 454 | + expect(offenses).not.to be(:empty?) |
| 455 | + end |
| 456 | + end |
435 | 457 | end |
0 commit comments