spec/changelog_spec.rb in danger-changelog-0.2.1 vs spec/changelog_spec.rb in danger-changelog-0.3.0
- old
+ new
@@ -39,11 +39,11 @@
end
it 'complains when no CHANGELOG can be found' do
expect(subject).to be false
expect(status_report[:errors]).to eq []
- expect(status_report[:warnings]).to eq ["Unless you're refactoring existing code, please update #{filename}."]
+ expect(status_report[:warnings]).to eq ["Unless you're refactoring existing code or improving documentation, please update #{filename}."]
expect(status_report[:markdowns].map(&:message)).to eq ["Here's an example of a #{filename} entry:\n\n```markdown\n* [#123](https://github.com/dblock/danger-changelog/pull/123): Being dangerous - [@dblock](https://github.com/dblock).\n```\n"]
end
end
context 'with a new CHANGELOG' do
@@ -99,26 +99,92 @@
expect(status_report[:errors]).to eq []
expect(status_report[:warnings]).to eq []
expect(status_report[:markdowns]).to eq []
end
- context 'missing your contribution here' do
- let(:filename) { File.expand_path('../fixtures/changelogs/missing_your_contribution_here.md', __FILE__) }
- it 'complains' do
- expect(subject).to be false
- expect(status_report[:errors]).to eq ["Please put back the `* Your contribution here.` line into #{filename}."]
+ context 'customized' do
+ before do
+ Danger::Changelog.configure do |config|
+ config.placeholder_line = "* Nothing yet.\n"
+ end
+ end
+
+ let(:filename) { File.expand_path('../fixtures/changelogs/customized.md', __FILE__) }
+ it 'is ok' do
+ expect(subject).to be true
+ expect(status_report[:errors]).to eq []
expect(status_report[:warnings]).to eq []
expect(status_report[:markdowns]).to eq []
end
end
+ context 'missing your contribution here' do
+ let(:filename) { File.expand_path('../fixtures/changelogs/missing_your_contribution_here.md', __FILE__) }
+
+ context 'when placeholder line is customized' do
+ before do
+ Danger::Changelog.configure do |config|
+ config.placeholder_line = "* Nothing yet.\n"
+ end
+ end
+
+ it 'complains' do
+ expect(subject).to be false
+ expect(status_report[:errors]).to eq ["Please put back the `* Nothing yet.` line into #{filename}."]
+ expect(status_report[:warnings]).to eq []
+ expect(status_report[:markdowns]).to eq []
+ end
+ end
+
+ context 'when placeholder line is default' do
+ it 'complains' do
+ expect(subject).to be false
+ expect(status_report[:errors]).to eq ["Please put back the `* Your contribution here.` line into #{filename}."]
+ expect(status_report[:warnings]).to eq []
+ expect(status_report[:markdowns]).to eq []
+ end
+ end
+
+ context 'when placeholder line is nil' do
+ before do
+ Danger::Changelog.configure do |config|
+ config.placeholder_line = nil
+ end
+ end
+
+ it 'is ok' do
+ expect(subject).to be true
+ expect(status_report[:errors]).to eq []
+ expect(status_report[:warnings]).to eq []
+ expect(status_report[:markdowns]).to eq []
+ end
+ end
+ end
+
context 'minimal example' do
let(:filename) { File.expand_path('../fixtures/changelogs/minimal.md', __FILE__) }
it 'is ok' do
expect(subject).to be true
expect(status_report[:errors]).to eq []
expect(status_report[:warnings]).to eq []
expect(status_report[:markdowns]).to eq []
+ end
+
+ context 'when placeholder line is nil' do
+ before do
+ Danger::Changelog.configure do |config|
+ config.placeholder_line = nil
+ end
+ end
+
+ it 'complains' do
+ expect(subject).to be false
+ expect(status_report[:errors]).to eq ["One of the lines below found in #{filename} doesn't match the expected format. Please make it look like the other lines, pay attention to periods and spaces."]
+ expect(status_report[:warnings]).to eq []
+ expect(status_report[:markdowns].map(&:message)).to eq [
+ "```markdown\n* Your contribution here.\n```\n"
+ ]
+ end
end
end
context 'with bad lines' do
let(:filename) { File.expand_path('../fixtures/changelogs/with_bad_lines.md', __FILE__) }