spec/changelog_spec.rb in danger-changelog-0.1.0 vs spec/changelog_spec.rb in danger-changelog-0.2.0
- old
+ new
@@ -16,15 +16,15 @@
describe 'in a PR' do
before do
# typical PR JSON looks like https://raw.githubusercontent.com/danger/danger/bffc246a11dac883d76fc6636319bd6c2acd58a3/spec/fixtures/pr_response.json
changelog.env.request_source.pr_json = {
- number: 123,
- title: 'being dangerous',
- html_url: 'https://github.com/dblock/danger-changelog/pull/123',
- user: {
- login: 'dblock'
+ 'number' => 123,
+ 'title' => 'being dangerous',
+ 'html_url' => 'https://github.com/dblock/danger-changelog/pull/123',
+ 'user' => {
+ 'login' => 'dblock'
}
}
end
context 'have_you_updated_changelog?' do
@@ -40,11 +40,11 @@
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[:markdowns]).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"]
+ 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
before do
@@ -78,10 +78,18 @@
context 'is_changelog_format_correct?' do
subject do
changelog.is_changelog_format_correct?
end
+ context 'without a CHANGELOG file' do
+ let(:filename) { 'does-not-exist' }
+ it 'complains' do
+ expect(subject).to be false
+ expect(status_report[:errors]).to eq ['The does-not-exist file does not exist.']
+ end
+ end
+
context 'with CHANGELOG changes' do
before do
allow(changelog.git).to receive(:modified_files).and_return([filename])
allow(changelog.git).to receive(:added_files).and_return([])
end
@@ -117,10 +125,10 @@
let(:filename) { File.expand_path('../fixtures/changelogs/with_bad_lines.md', __FILE__) }
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]).to eq [
+ expect(status_report[:markdowns].map(&:message)).to eq [
"```markdown\n* [#1](https://github.com/dblock/danger-changelog/pull/1) - Not a colon - [@dblock](https://github.com/dblock).\n```\n",
"```markdown\n* [#1](https://github.com/dblock/danger-changelog/pull/1): No final period - [@dblock](https://github.com/dblock)\n```\n"
]
end
end