spec/wcc/rubocop_exceptions_spec.rb in danger-wcc-0.0.5 vs spec/wcc/rubocop_exceptions_spec.rb in danger-wcc-0.0.6
- old
+ new
@@ -28,13 +28,13 @@
expect(@dangerfile.violation_report[:warnings])
.to eq([Violation.new('Rubocop rule Rails/SomeRule disabled in '\
'<a href="github_html_link">spec/fixtures/rubocop_exception.rb</a>'\
" \nPlease provide an explanation why this rule was disabled.",
- false,
- 'spec/fixtures/rubocop_exception.rb',
- 5)])
+ false,
+ 'spec/fixtures/rubocop_exception.rb',
+ 5)])
end
it 'Errors when rubocop exception not reenabled' do
allow(@git).to receive(:diff)
.and_return([load_diff(
@@ -50,13 +50,32 @@
'<a href="github_html_link">spec/fixtures/rubocop_exception.rb</a>'\
" \nPlease provide an explanation why this rule was disabled."\
"\n\nThe rule was not reenabled!\n"\
'Please add a `rubocop:enable` comment so the rule is disabled '\
'for the minimal scope.',
- false,
+ false,
+ 'spec/fixtures/rubocop_exception.rb',
+ 10)])
+ end
+
+ it 'does not require reenabling for inline comments' do
+ allow(@git).to receive(:diff)
+ .and_return([load_diff(
'spec/fixtures/rubocop_exception.rb',
- 10)])
+ 'exception_inline_disabled_rule'
+ )])
+
+ # act
+ @my_plugin.rubocop_exceptions
+
+ expect(@dangerfile.violation_report[:warnings])
+ .to eq([Violation.new('Rubocop rule Rails/SomeRule disabled in '\
+ '<a href="github_html_link">spec/fixtures/rubocop_exception.rb</a>'\
+ " \nPlease provide an explanation why this rule was disabled.",
+ false,
+ 'spec/fixtures/rubocop_exception.rb',
+ 40)])
end
it 'Messages when exception added with context' do
allow(@git).to receive(:diff)
.and_return([load_diff(
@@ -69,13 +88,13 @@
expect(@dangerfile.violation_report[:messages])
.to eq([Violation.new('Rubocop rule Metrics/LineLength disabled in '\
'<a href="github_html_link">spec/fixtures/rubocop_exception.rb</a>'\
" explanation:\n\t> Disabling because I want to.",
- false,
- 'spec/fixtures/rubocop_exception.rb',
- 15)])
+ false,
+ 'spec/fixtures/rubocop_exception.rb',
+ 15)])
end
it 'Messages when exception added with multiline context' do
allow(@git).to receive(:diff)
.and_return([load_diff(
@@ -90,13 +109,13 @@
.to eq([Violation.new('Rubocop rule Layout/AlignHash disabled in '\
'<a href="github_html_link">spec/fixtures/rubocop_exception.rb</a>'\
' explanation:'\
"\n\t> I want to disable this because.."\
"\n\t> I forgot the reasons.",
- false,
- 'spec/fixtures/rubocop_exception.rb',
- 30)])
+ false,
+ 'spec/fixtures/rubocop_exception.rb',
+ 30)])
end
it 'Messages when exception added in between existing comments' do
allow(@git).to receive(:diff)
.and_return([load_diff(
@@ -110,12 +129,12 @@
expect(@dangerfile.violation_report[:messages])
.to eq([Violation.new('Rubocop rule Metrics/ABC disabled in '\
'<a href="github_html_link">spec/fixtures/rubocop_exception.rb</a>'\
' explanation:'\
"\n\t> here is my comment why we are disabling ABC",
- false,
- 'spec/fixtures/rubocop_exception.rb',
- 21)])
+ false,
+ 'spec/fixtures/rubocop_exception.rb',
+ 21)])
end
it 'Does not message when no exception added' do
allow(@git).to receive(:diff)
.and_return([load_diff(