|
32 | 32 | expect(File.read(path)).to eq(content) |
33 | 33 | end |
34 | 34 |
|
35 | | - it 'rejects a missing placeholder during pending-note validation' do |
36 | | - content = "## 1.0.0 (Next)\n\n- Change.\n" |
| 35 | + it 'accepts notes without a placeholder during pending-note validation' do |
| 36 | + File.write(path, "## 1.0.0 (Next)\n\n- Change.\n\n## 0.9.0 (2026/01/01)\n\n- Older.\n") |
| 37 | + expect(described_class.new(path: path).pending?).to be(true) |
| 38 | + end |
| 39 | + |
| 40 | + it 'rejects a placeholder marked differently from the configured one without writing', :aggregate_failures do |
| 41 | + content = "## 1.0.0 (Next)\n\n* Your contribution here.\n" |
37 | 42 | File.write(path, content) |
38 | | - expect { described_class.new(path: path).pending? }.to raise_error(ArgumentError, /placeholder/) |
| 43 | + expect { described_class.new(path: path).pending? } |
| 44 | + .to raise_error(ArgumentError, /placeholder "\* Your contribution here\." in .*CHANGELOG.md does not match the configured "- Your contribution here\."/) |
| 45 | + expect { described_class.new(path: path).release!(release) }.to raise_error(ArgumentError, /does not match the configured/) |
39 | 46 | expect(File.read(path)).to eq(content) |
40 | 47 | end |
41 | 48 |
|
|
150 | 157 | expect(File.binread(path)).to eq(content) |
151 | 158 | end |
152 | 159 |
|
153 | | - it 'rejects a missing placeholder without modifying the file' do |
154 | | - content = "## 1.0.0 (Next)\n\n- Change.\n" |
155 | | - File.write(path, content) |
156 | | - expect { described_class.new(path: path).release!(release) } |
157 | | - .to raise_error(ArgumentError, /placeholder/) |
158 | | - expect(File.read(path)).to eq(content) |
| 160 | + it 'releases notes without a placeholder and restores it in the next section', :aggregate_failures do |
| 161 | + File.write(path, "# Changelog\n\n## 1.0.0 (Next)\n\n- Change.\n") |
| 162 | + changelog = described_class.new(path: path) |
| 163 | + changelog.release!(release) |
| 164 | + expect(File.read(path)).to include("## 1.0.0 (#{release.date.strftime('%Y/%m/%d')})\n\n- Change.\n") |
| 165 | + changelog.prepare_next!(release.with_next_version('1.0.1')) |
| 166 | + expect(File.read(path)).to start_with("# Changelog\n\n## 1.0.1 (Next)\n\n- Your contribution here.\n") |
159 | 167 | end |
160 | 168 |
|
161 | 169 | it 'writes release dates with a configured strftime format' do |
|
0 commit comments