danger-changelog 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 581ec6b4b9c3833ce61d201ec1337a6b232a2fa2e0282eaea52aec6b4c313381
4
- data.tar.gz: 5b0fe3313f22e010b1213eab4aaf3c6c6ba73d22702646b4d66f1bb8051975b7
3
+ metadata.gz: 5dda179f0ffebc733fa943723d9b16c6db3720beab1e5c43ee57746cb6f20577
4
+ data.tar.gz: b1797cb0bd4d0eef3aead4e9a0409c057205d995efc3d56f200f106055900fe9
5
5
  SHA512:
6
- metadata.gz: 671e4065da9320cc167b2e96332127f492098c1e41230ec7b78a6adf7f21cabb9da0fb49f343a95d35a8eaab637bceb1a99d13621f5757212b1ec2cf331c1ca2
7
- data.tar.gz: d8a16a3aa427a157266f02a26687bc2ac3c9dc51ab7914c4a301b6b60cbc23587a72794644b5666fb0dca6624ee78481fb1852ca343a51248793525a12a5a5ed
6
+ metadata.gz: 897e573a11db0076fd9c7bb745b5c8f39d47d94f4d2b69b298a1565cade582a9aaadf17d0667b48a1d9569bc0566558000e9baaec7bf9a6054d4818ed5475f1d
7
+ data.tar.gz: c92f5ae706ada26bb3006adffae2df8aef0b79de05d1f6464257918004511a7bdc926a2430c6386d32961df4011c3e48b29162dea763a98865087e6df8fd4375
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-12-20 16:02:35 -0500 using RuboCop version 0.61.1.
3
+ # on 2019-07-28 16:00:45 -0400 using RuboCop version 0.61.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -14,11 +14,6 @@ Layout/IndentHeredoc:
14
14
  Exclude:
15
15
  - 'lib/changelog/plugin.rb'
16
16
 
17
- # Offense count: 1
18
- Lint/DuplicateMethods:
19
- Exclude:
20
- - 'lib/changelog/config.rb'
21
-
22
17
  # Offense count: 1
23
18
  # Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
24
19
  Lint/UselessAccessModifier:
@@ -36,7 +31,7 @@ Naming/PredicateName:
36
31
  - 'spec/**/*'
37
32
  - 'lib/changelog/plugin.rb'
38
33
 
39
- # Offense count: 3
34
+ # Offense count: 1
40
35
  Style/DoubleNegation:
41
36
  Exclude:
42
37
  - 'lib/changelog/changelog_file.rb'
@@ -1,5 +1,12 @@
1
1
  ## Changelog
2
2
 
3
+ ### 0.6.0 (2019/07/28)
4
+
5
+ * [#47](https://github.com/dblock/danger-changelog/pull/47): Configure `Config#placeholder_line` at plugin level - [@dblock](https://github.com/dblock).
6
+ * [#47](https://github.com/dblock/danger-changelog/pull/47): Deprecate `Danger::Changelog.configure` - [@dblock](https://github.com/dblock).
7
+ * [#48](https://github.com/dblock/danger-changelog/pull/48): Deprecate `check` in favor of `check!` and configure `format` separately - [@dblock](https://github.com/dblock).
8
+ * [#49](https://github.com/dblock/danger-changelog/pull/48): Added `Config#ignore_files` with filename and regex support - [@dblock](https://github.com/dblock).
9
+
3
10
  ### 0.5.0 (2019/05/31)
4
11
 
5
12
  * [#41](https://github.com/dblock/danger-changelog/pull/41): Document what's a correctly-formatted CHANGELOG - [@ivoanjo](https://github.com/ivoanjo).
data/Dangerfile CHANGED
@@ -1,3 +1,3 @@
1
1
  # danger.systems
2
2
 
3
- changelog.check
3
+ changelog.check!
data/README.md CHANGED
@@ -8,50 +8,69 @@ It can make sure, for example, that changes are attributed properly, have a vali
8
8
 
9
9
  ## What's a correctly formatted CHANGELOG file?
10
10
 
11
- By design, `danger-changelog` is quite strict with what it allows as a valid changelog file. However, there are more than one format that it supports.
12
-
13
- * By default, it uses the [Intridea style](doc/intridea.md)
14
- * Optionally, you can enable the [Keep a Changelog style](doc/keep_a_changelog.md)
11
+ By design, `danger-changelog` is quite strict with what it allows as a valid changelog file, using the [Intridea style](doc/intridea.md), [used by this library itself](CHANGELOG.md). It also supports the [Keep a Changelog](doc/keep_a_changelog.md) format.
15
12
 
16
13
  ## Installation
17
14
 
18
15
  Add `danger-changelog` to your Gemfile.
19
16
 
20
17
  ```
21
- gem 'danger-changelog', '~> 0.3.0'
18
+ gem 'danger-changelog', '~> 0.6.0'
22
19
  ```
23
20
 
24
- Add `changelog.check` to your `Dangerfile`. Make a pull request and see this plugin in action.
21
+ Call `changelog.check!` from your `Dangerfile`. Make a pull request and see this plugin in action.
25
22
 
26
23
  ## Usage
27
24
 
28
25
  Methods and attributes from this plugin are available in your `Dangerfile` under the `changelog` namespace.
29
26
 
30
- ### Configuration
27
+ ## Configuration
28
+
29
+ The following options and checks are supported.
30
+
31
+ ### changelog.filename
32
+
33
+ Set the CHANGELOG file name, defaults to `CHANGELOG.md`.
34
+
35
+ ```ruby
36
+ changelog.filename = 'CHANGES.md'
37
+ ```
38
+
39
+ ### changelog.format
31
40
 
32
- You can configure the plugin in `Dangerfile`.
41
+ Set the format of the CHANGELOG file.
33
42
 
34
43
  ```ruby
35
- Danger::Changelog.configure do |config|
36
- config.placeholder_line = "Nothing yet."
37
- end
44
+ changelog.format = :keep_a_changelog
38
45
  ```
39
46
 
40
- The following options are supported.
47
+ Available formats are [Intridea](doc/intridea.md) (default) and [Keep a Changelog](doc/keep_a_changelog.md).
41
48
 
42
- #### placeholder_line
49
+ ### changelog.placeholder_line
43
50
 
44
51
  Customize the `* Your contribution here.` line. Set the value to `nil` to stop checking for one.
45
52
 
46
- ### changelog.filename
53
+ ```ruby
54
+ changelog.placeholder_line = "* Your change here.\n"
55
+ ```
47
56
 
48
- Set the CHANGELOG file name, defaults to `CHANGELOG.md`.
57
+ ### changelog.ignore_files
58
+
59
+ Ignore additions and changes with a certain name or expression, default is to ignore `README.md` changes.
60
+
61
+ For example, ignore `UPGRADING.md` and all `.txt` files.
62
+
63
+ ```ruby
64
+ changelog.ignore_files = ['README.md', 'UPGRADING.md', /\.txt$/]
65
+ ```
66
+
67
+ ## Checks
49
68
 
50
- ### changelog.check
69
+ Invoke check methods.
51
70
 
52
- Run all checks with defaults.
71
+ ### changelog.check!
53
72
 
54
- You can pass a different format to this method, such as `changelog.check(:keep_a_changelog)`.
73
+ Run all checks with defaults, including `have_you_updated_changelog?` and `is_changelog_format_correct?`.
55
74
 
56
75
  #### changelog.have_you_updated_changelog?
57
76
 
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
21
21
 
22
22
  spec.add_development_dependency 'activesupport'
23
- spec.add_development_dependency 'bundler', '~> 1.3'
23
+ spec.add_development_dependency 'bundler'
24
24
  spec.add_development_dependency 'guard', '~> 2.14'
25
25
  spec.add_development_dependency 'guard-rspec', '~> 4.7'
26
26
  spec.add_development_dependency 'listen', '3.0.7'
@@ -3,7 +3,18 @@ module Danger
3
3
  module Config
4
4
  extend self
5
5
 
6
- attr_accessor :placeholder_line
6
+ ATTRIBUTES = %i[
7
+ placeholder_line
8
+ filename
9
+ format
10
+ ignore_files
11
+ ].freeze
12
+
13
+ ACCESSORS = ATTRIBUTES.map { |name| "#{name}=".to_sym }
14
+
15
+ DELEGATORS = ATTRIBUTES + ACCESSORS
16
+
17
+ attr_accessor(*Config::ATTRIBUTES)
7
18
 
8
19
  def placeholder_line=(value)
9
20
  if value
@@ -16,12 +27,29 @@ module Danger
16
27
  end
17
28
  end
18
29
 
30
+ def format=(value)
31
+ raise ArgumentError, "Invalid format: #{value}" unless Danger::Changelog::Parsers.valid?(value)
32
+
33
+ @format = value
34
+ end
35
+
19
36
  def placeholder_line?
20
37
  !@placeholder_line.nil?
21
38
  end
22
39
 
40
+ def ignore_files=(value)
41
+ @ignore_files = Array(value)
42
+ end
43
+
44
+ def parser
45
+ Danger::Changelog::Parsers.lookup(format)
46
+ end
47
+
23
48
  def reset
24
49
  self.placeholder_line = "* Your contribution here.\n"
50
+ self.filename = 'CHANGELOG.md'
51
+ self.format = Danger::Changelog::Parsers.default_format
52
+ self.ignore_files = ['README.md']
25
53
  end
26
54
 
27
55
  reset
@@ -29,6 +57,7 @@ module Danger
29
57
 
30
58
  class << self
31
59
  def configure
60
+ warn '[DEPRECATION] `configure` is deprecated. Please directly configure the Danger plugin via `changelog.xyz=` instead.'
32
61
  block_given? ? yield(Config) : Config
33
62
  end
34
63
 
@@ -1,3 +1,3 @@
1
1
  module Changelog
2
- VERSION = '0.5.0'.freeze
2
+ VERSION = '0.6.0'.freeze
3
3
  end
@@ -5,14 +5,22 @@ require 'changelog/parsers/keep_a_changelog'
5
5
  module Danger
6
6
  module Changelog
7
7
  module Parsers
8
- def self.default_format
9
- :intridea
10
- end
8
+ FORMATS = { intridea: IntrideaFormat, keep_a_changelog: KeepAChangelog }.freeze
9
+
10
+ class << self
11
+ def default_format
12
+ :intridea
13
+ end
14
+
15
+ def valid?(format)
16
+ FORMATS.keys.map(&:to_s).include?(format.to_s)
17
+ end
11
18
 
12
- def self.lookup(format)
13
- { intridea: IntrideaFormat, keep_a_changelog: KeepAChangelog }
14
- .fetch(format, IntrideaFormat)
15
- .new
19
+ def lookup(format)
20
+ FORMATS
21
+ .fetch(format, IntrideaFormat)
22
+ .new
23
+ end
16
24
  end
17
25
  end
18
26
  end
@@ -5,31 +5,35 @@ module Danger
5
5
  #
6
6
  # @example Run all checks on the default CHANGELOG.md.
7
7
  #
8
- # changelog.check
8
+ # changelog.check!
9
9
  #
10
10
  # @example Customize the CHANGELOG file name and remind the requester to update it when necessary.
11
11
  #
12
12
  # changelog.filename = 'CHANGES.md'
13
+ # changelog.placeholder_line = "* Your contribution here.\n"
13
14
  # changelog.have_you_updated_changelog?
14
15
  #
15
16
  # @see dblock/danger-changelog
16
17
  # @tags changelog
17
18
 
18
19
  class DangerChangelog < Plugin
19
- # The changelog file name, defaults to `CHANGELOG.md`.
20
- # @return [String]
21
- attr_accessor :filename
20
+ extend Forwardable
22
21
 
23
- def initialize(dangerfile)
24
- @filename = 'CHANGELOG.md'
25
- super
22
+ def_delegators Danger::Changelog.config, *Danger::Changelog::Config::DELEGATORS
23
+
24
+ # Run all checks.
25
+ # @return [Boolean] true when the check passes
26
+ def check!
27
+ have_you_updated_changelog? && is_changelog_format_correct?
26
28
  end
27
29
 
28
30
  # Run all checks.
29
31
  # @param format [Symbol] the format to check against
30
32
  # @return [Boolean] true when the check passes
31
- def check(format = Danger::Changelog::Parsers.default_format)
32
- have_you_updated_changelog? && is_changelog_format_correct?(format)
33
+ def check(parser = Danger::Changelog::Config.format)
34
+ warn '[DEPRECATION] `check` is deprecated. Set format with `.format` and use `check!` instead.'
35
+ config.format = parser
36
+ check!
33
37
  end
34
38
 
35
39
  # Has the CHANGELOG file been modified?
@@ -38,28 +42,34 @@ module Danger
38
42
  git.modified_files.include?(filename) || git.added_files.include?(filename)
39
43
  end
40
44
 
45
+ # Are any files CHANGELOG cares about modified?
46
+ # @return [boolean]
47
+ def file_changes?
48
+ all_files = git.modified_files + git.added_files
49
+ Danger::Changelog::Config.ignore_files.each do |f|
50
+ all_files.reject! { |modified_file| f.is_a?(Regexp) ? f.match?(modified_file) : f == modified_file }
51
+ break if all_files.empty?
52
+ end
53
+ all_files.any?
54
+ end
55
+
41
56
  # Have you updated CHANGELOG.md?
42
57
  # @return [boolean]
43
58
  def have_you_updated_changelog?
44
59
  if changelog_changes?
45
60
  true
46
- else
47
- markdown <<-MARKDOWN
48
- Here's an example of a #{filename} entry:
49
-
50
- ```markdown
51
- #{Danger::Changelog::ChangelogEntryLine.example(github)}
52
- ```
53
- MARKDOWN
54
- warn "Unless you're refactoring existing code or improving documentation, please update #{filename}.", sticky: false
61
+ elsif file_changes?
62
+ warn_update_changelog
55
63
  false
64
+ else
65
+ true
56
66
  end
57
67
  end
58
68
 
59
69
  # Is the CHANGELOG.md format correct?
60
70
  # @return [boolean]
61
- def is_changelog_format_correct?(format)
62
- parser = Danger::Changelog::Parsers.lookup(format)
71
+ def is_changelog_format_correct?
72
+ parser = Danger::Changelog::Config.parser
63
73
  changelog_file = Danger::Changelog::ChangelogFile.new(filename, parser: parser)
64
74
 
65
75
  if changelog_file.exists?
@@ -82,5 +92,18 @@ Here's an example of a #{filename} entry:
82
92
  false
83
93
  end
84
94
  end
95
+
96
+ private
97
+
98
+ def warn_update_changelog
99
+ markdown <<-MARKDOWN
100
+ Here's an example of a #{filename} entry:
101
+
102
+ ```markdown
103
+ #{Danger::Changelog::ChangelogEntryLine.example(github)}
104
+ ```
105
+ MARKDOWN
106
+ warn "Unless you're refactoring existing code or improving documentation, please update #{filename}.", sticky: false
107
+ end
85
108
  end
86
109
  end
@@ -4,6 +4,6 @@ require 'changelog/changelog_line/changelog_line_parser'
4
4
  require 'changelog/changelog_line/changelog_placeholder_line'
5
5
  require 'changelog/changelog_line/changelog_line'
6
6
  require 'changelog/changelog_file'
7
- require 'changelog/config'
8
7
  require 'changelog/parsers'
8
+ require 'changelog/config'
9
9
  require 'changelog/plugin'
@@ -3,9 +3,7 @@ require File.expand_path('spec_helper', __dir__)
3
3
  describe Danger::Changelog::ChangelogPlaceholderLine do
4
4
  context 'with a custom placeholder line' do
5
5
  before do
6
- Danger::Changelog.configure do |config|
7
- config.placeholder_line = "* Nothing yet here.\n"
8
- end
6
+ Danger::Changelog.config.placeholder_line = "* Nothing yet here.\n"
9
7
  end
10
8
 
11
9
  context 'when line is equal to placeholder_line from config' do
@@ -21,9 +19,7 @@ describe Danger::Changelog::ChangelogPlaceholderLine do
21
19
 
22
20
  context 'with a blank placeholder line' do
23
21
  before do
24
- Danger::Changelog.configure do |config|
25
- config.placeholder_line = nil
26
- end
22
+ Danger::Changelog.config.placeholder_line = nil
27
23
  end
28
24
 
29
25
  context 'when line is not blank' do
@@ -14,6 +14,12 @@ describe Danger::Changelog do
14
14
  end
15
15
  let(:status_report) { changelog.status_report }
16
16
 
17
+ describe 'config' do
18
+ it 'placeholder_line' do
19
+ expect(changelog.placeholder_line).to eq "* Your contribution here.\n"
20
+ end
21
+ end
22
+
17
23
  describe 'in a PR' do
18
24
  before do
19
25
  # typical PR JSON looks like https://raw.githubusercontent.com/danger/danger/bffc246a11dac883d76fc6636319bd6c2acd58a3/spec/fixtures/pr_response.json
@@ -33,16 +39,62 @@ describe Danger::Changelog do
33
39
  end
34
40
 
35
41
  context 'without CHANGELOG changes' do
36
- before do
37
- allow(changelog.git).to receive(:modified_files).and_return([])
38
- allow(changelog.git).to receive(:added_files).and_return([])
42
+ context 'when something was modified' do
43
+ before do
44
+ allow(changelog.git).to receive(:modified_files).and_return(['some-file.txt'])
45
+ allow(changelog.git).to receive(:added_files).and_return(['another-file.txt'])
46
+ end
47
+
48
+ it 'complains when no CHANGELOG can be found' do
49
+ expect(subject).to be false
50
+ expect(status_report[:errors]).to eq []
51
+ expect(status_report[:warnings]).to eq ["Unless you're refactoring existing code or improving documentation, please update #{filename}."]
52
+ 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"]
53
+ end
39
54
  end
40
55
 
41
- it 'complains when no CHANGELOG can be found' do
42
- expect(subject).to be false
43
- expect(status_report[:errors]).to eq []
44
- expect(status_report[:warnings]).to eq ["Unless you're refactoring existing code or improving documentation, please update #{filename}."]
45
- 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"]
56
+ context 'with a README.md' do
57
+ before do
58
+ allow(changelog.git).to receive(:modified_files).and_return(['README.md'])
59
+ allow(changelog.git).to receive(:added_files).and_return([])
60
+ end
61
+ it 'has no complaints' do
62
+ expect(subject).to be true
63
+ expect(status_report[:errors]).to eq []
64
+ expect(status_report[:warnings]).to eq []
65
+ expect(status_report[:markdowns]).to eq []
66
+ end
67
+ end
68
+
69
+ context 'with files being ignored' do
70
+ context 'name' do
71
+ before do
72
+ changelog.ignore_files = ['WHATEVER.md']
73
+ allow(changelog.git).to receive(:modified_files).and_return(['WHATEVER.md'])
74
+ allow(changelog.git).to receive(:added_files).and_return([])
75
+ end
76
+
77
+ it 'has no complaints' do
78
+ expect(subject).to be true
79
+ expect(status_report[:errors]).to eq []
80
+ expect(status_report[:warnings]).to eq []
81
+ expect(status_report[:markdowns]).to eq []
82
+ end
83
+ end
84
+ context 'mixed' do
85
+ before do
86
+ changelog.ignore_files = ['WHATEVER.md', /\.txt$/]
87
+ allow(changelog.git).to receive(:modified_files).and_return(['WHATEVER.md'])
88
+ allow(changelog.git).to receive(:added_files).and_return(['one.txt', 'two.txt'])
89
+ end
90
+
91
+ it 'has no complaints' do
92
+ expect(subject).to be true
93
+ expect(status_report[:errors]).to eq []
94
+ expect(status_report[:warnings]).to eq []
95
+ expect(status_report[:markdowns]).to eq []
96
+ end
97
+ end
46
98
  end
47
99
  end
48
100
 
@@ -77,7 +129,8 @@ describe Danger::Changelog do
77
129
 
78
130
  context 'is_changelog_format_correct?' do
79
131
  subject do
80
- changelog.is_changelog_format_correct?(Danger::Changelog::Parsers.default_format)
132
+ changelog.format = Danger::Changelog::Parsers.default_format
133
+ changelog.is_changelog_format_correct?
81
134
  end
82
135
 
83
136
  context 'without a CHANGELOG file' do
@@ -103,9 +156,7 @@ describe Danger::Changelog do
103
156
 
104
157
  context 'customized' do
105
158
  before do
106
- Danger::Changelog.configure do |config|
107
- config.placeholder_line = "* Nothing yet.\n"
108
- end
159
+ changelog.placeholder_line = "* Nothing yet.\n"
109
160
  end
110
161
 
111
162
  let(:filename) { File.expand_path('fixtures/changelogs/customized.md', __dir__) }
@@ -122,9 +173,7 @@ describe Danger::Changelog do
122
173
 
123
174
  context 'when placeholder line is customized' do
124
175
  before do
125
- Danger::Changelog.configure do |config|
126
- config.placeholder_line = "* Nothing yet.\n"
127
- end
176
+ changelog.placeholder_line = "* Nothing yet.\n"
128
177
  end
129
178
 
130
179
  it 'complains' do
@@ -146,9 +195,7 @@ describe Danger::Changelog do
146
195
 
147
196
  context 'when placeholder line is nil' do
148
197
  before do
149
- Danger::Changelog.configure do |config|
150
- config.placeholder_line = nil
151
- end
198
+ changelog.placeholder_line = nil
152
199
  end
153
200
 
154
201
  it 'is ok' do
@@ -171,9 +218,7 @@ describe Danger::Changelog do
171
218
 
172
219
  context 'when placeholder line is nil' do
173
220
  before do
174
- Danger::Changelog.configure do |config|
175
- config.placeholder_line = nil
176
- end
221
+ changelog.placeholder_line = nil
177
222
  end
178
223
 
179
224
  it 'complains' do
@@ -213,6 +258,7 @@ describe Danger::Changelog do
213
258
  let(:filename) { File.expand_path('fixtures/changelogs/keep_a_changelog.md', __dir__) }
214
259
  let(:dangerfile) { testing_dangerfile }
215
260
  let(:changelog) do
261
+ dangerfile.changelog.format = :keep_a_changelog
216
262
  dangerfile.changelog.filename = filename
217
263
  dangerfile.changelog
218
264
  end
@@ -230,13 +276,15 @@ describe Danger::Changelog do
230
276
  }
231
277
  end
232
278
 
233
- context '#check(:keep_a_changelog)' do
234
- subject { changelog.check(:keep_a_changelog) }
279
+ context '#check!' do
280
+ subject do
281
+ changelog.check!
282
+ end
235
283
 
236
284
  context 'without CHANGELOG changes' do
237
285
  before do
238
- allow(changelog.git).to receive(:modified_files).and_return([])
239
- allow(changelog.git).to receive(:added_files).and_return([])
286
+ allow(changelog.git).to receive(:modified_files).and_return(['some-file.txt'])
287
+ allow(changelog.git).to receive(:added_files).and_return(['some-file.txt'])
240
288
  end
241
289
 
242
290
  it 'complains when no CHANGELOG can be found' do
@@ -254,8 +302,7 @@ describe Danger::Changelog do
254
302
  end
255
303
 
256
304
  it 'has no complaints' do
257
- subject
258
- # expect(subject).to be true
305
+ expect(subject).to be true
259
306
  expect(status_report[:errors]).to eq []
260
307
  expect(status_report[:warnings]).to eq []
261
308
  expect(status_report[:markdowns]).to eq []
@@ -1,43 +1,83 @@
1
1
  require File.expand_path('spec_helper', __dir__)
2
2
 
3
3
  describe Danger::Changelog::Config do
4
- describe 'configure' do
5
- describe 'placeholder_line' do
6
- context 'when without markdown star' do
7
- before do
8
- Danger::Changelog.configure do |config|
9
- config.placeholder_line = "Nothing yet.\n"
10
- end
11
- end
4
+ describe 'placeholder_line' do
5
+ context 'when without markdown star' do
6
+ before do
7
+ Danger::Changelog.config.placeholder_line = "Nothing yet.\n"
8
+ end
12
9
 
13
- it 'ads missing star and saves configuration' do
14
- expect(Danger::Changelog.config.placeholder_line).to eq "* Nothing yet.\n"
15
- end
10
+ it 'ads missing star and saves configuration' do
11
+ expect(Danger::Changelog.config.placeholder_line).to eq "* Nothing yet.\n"
16
12
  end
13
+ end
17
14
 
18
- context 'when without trailing newline' do
19
- before do
20
- Danger::Changelog.configure do |config|
21
- config.placeholder_line = '* Nothing yet.'
22
- end
23
- end
15
+ context 'when without trailing newline' do
16
+ before do
17
+ Danger::Changelog.config.placeholder_line = '* Nothing yet.'
18
+ end
24
19
 
25
- it 'ads missing trailing newline and saves configuration' do
26
- expect(Danger::Changelog.config.placeholder_line).to eq "* Nothing yet.\n"
27
- end
20
+ it 'ads missing trailing newline and saves configuration' do
21
+ expect(Danger::Changelog.config.placeholder_line).to eq "* Nothing yet.\n"
22
+ end
23
+ end
24
+
25
+ context 'when valid' do
26
+ before do
27
+ Danger::Changelog.config.placeholder_line = "* Nothing yet.\n"
28
28
  end
29
29
 
30
- context 'when valid' do
30
+ it 'saves configuration' do
31
+ expect(Danger::Changelog.config.placeholder_line).to eq "* Nothing yet.\n"
32
+ end
33
+ end
34
+ end
35
+ describe 'format' do
36
+ it 'default' do
37
+ expect(Danger::Changelog.config.format).to eq :intridea
38
+ end
39
+ it 'with an invalid format' do
40
+ expect { Danger::Changelog.config.format = :foobar }.to raise_error ArgumentError, 'Invalid format: foobar'
41
+ end
42
+ it 'with a string' do
43
+ expect { Danger::Changelog.config.format = 'intridea' }.to_not raise_error
44
+ end
45
+ it 'with a symbol' do
46
+ expect { Danger::Changelog.config.format = :intridea }.to_not raise_error
47
+ end
48
+ Danger::Changelog::Parsers::FORMATS.each_pair do |format, parser|
49
+ context format do
31
50
  before do
32
- Danger::Changelog.configure do |config|
33
- config.placeholder_line = "* Nothing yet.\n"
34
- end
51
+ Danger::Changelog.config.format = format
35
52
  end
36
-
37
- it 'saves configuration' do
38
- expect(Danger::Changelog.config.placeholder_line).to eq "* Nothing yet.\n"
53
+ it 'sets format' do
54
+ expect(Danger::Changelog.config.format).to eq format
55
+ end
56
+ it 'creates parser' do
57
+ expect(Danger::Changelog.config.parser).to be_a parser
39
58
  end
40
59
  end
41
60
  end
42
61
  end
62
+ describe 'ignore_files' do
63
+ it 'default' do
64
+ expect(Danger::Changelog.config.ignore_files).to eq(['README.md'])
65
+ end
66
+ context 'with a file name' do
67
+ before do
68
+ Danger::Changelog.config.ignore_files = 'WHATEVER.md'
69
+ end
70
+ it 'transforms it into an array' do
71
+ expect(Danger::Changelog.config.ignore_files).to eq(['WHATEVER.md'])
72
+ end
73
+ end
74
+ context 'with multiple names' do
75
+ before do
76
+ Danger::Changelog.config.ignore_files = ['WHATEVER.md', /\*.md$/]
77
+ end
78
+ it 'transforms it into an array' do
79
+ expect(Danger::Changelog.config.ignore_files).to eq(['WHATEVER.md', /\*.md$/])
80
+ end
81
+ end
82
+ end
43
83
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-changelog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - dblock
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-31 00:00:00.000000000 Z
11
+ date: 2019-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-plugin-api
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '1.3'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '1.3'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: guard
57
57
  requirement: !ruby/object:Gem::Requirement