Skip to content

Commit 840f8f9

Browse files
drwlpeterfication
authored andcommitted
Tidy spec directory (ctran#646)
In looking into ctran#563, I realized there are gaps in test coverage. For example, `bin/annotate` doesn't have any tests. Tidying the spec directory to make it easier to add tests in future work.
1 parent 369fd1e commit 840f8f9

6 files changed

+33
-62
lines changed

.rubocop_todo.yml

+27-56
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2019-06-16 12:01:03 -0700 using RuboCop version 0.68.1.
3+
# on 2019-09-02 16:23:56 -0700 using RuboCop version 0.68.1.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -49,9 +49,9 @@ Gemspec/RequiredRubyVersion:
4949
# Cop supports --auto-correct.
5050
Layout/AlignArray:
5151
Exclude:
52-
- 'spec/annotate/annotate_models_spec.rb'
52+
- 'spec/lib/annotate/annotate_models_spec.rb'
5353

54-
# Offense count: 104
54+
# Offense count: 107
5555
# Cop supports --auto-correct.
5656
# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
5757
# SupportedHashRocketStyles: key, separator, table
@@ -60,11 +60,11 @@ Layout/AlignArray:
6060
Layout/AlignHash:
6161
Exclude:
6262
- 'lib/generators/annotate/templates/auto_annotate_models.rake'
63-
- 'spec/annotate/annotate_models_spec.rb'
6463
- 'spec/integration/rails_2.3_with_bundler/config/initializers/unified_initializer.rb'
6564
- 'spec/integration/rails_4.1.1/lib/tasks/auto_annotate_models.rake'
6665
- 'spec/integration/rails_4.2.0/lib/tasks/auto_annotate_models.rake'
6766
- 'spec/integration/standalone/config/init.rb'
67+
- 'spec/lib/annotate/annotate_models_spec.rb'
6868

6969
# Offense count: 1
7070
# Cop supports --auto-correct.
@@ -78,16 +78,16 @@ Layout/BlockAlignment:
7878
# Cop supports --auto-correct.
7979
Layout/ClosingHeredocIndentation:
8080
Exclude:
81-
- 'spec/annotate/annotate_models_spec.rb'
8281
- 'spec/integration/rails_2.3_with_bundler.rb'
8382
- 'spec/integration/rails_3.2.2.rb'
8483
- 'spec/integration/rails_3.2.8.rb'
8584
- 'spec/integration/rails_3.2_autoloading_factory_girl.rb'
8685
- 'spec/integration/rails_3.2_custom_inflections.rb'
8786
- 'spec/integration/rails_3.2_with_asset_pipeline.rb'
8887
- 'spec/integration/standalone.rb'
88+
- 'spec/lib/annotate/annotate_models_spec.rb'
8989

90-
# Offense count: 14
90+
# Offense count: 13
9191
# Cop supports --auto-correct.
9292
Layout/EmptyLineAfterGuardClause:
9393
Exclude:
@@ -102,7 +102,6 @@ Layout/EmptyLineAfterGuardClause:
102102
Layout/EmptyLineAfterMagicComment:
103103
Exclude:
104104
- 'annotate.gemspec'
105-
- 'spec/annotate/annotate_models_spec.rb'
106105
- 'spec/integration/rails_3.2.2/db/schema.rb'
107106
- 'spec/integration/rails_3.2.8/db/schema.rb'
108107
- 'spec/integration/rails_3.2_autoloading_factory_girl/db/schema.rb'
@@ -111,6 +110,7 @@ Layout/EmptyLineAfterMagicComment:
111110
- 'spec/integration/rails_4.1.1/db/schema.rb'
112111
- 'spec/integration/rails_4.2.0/db/schema.rb'
113112
- 'spec/integration/standalone/db/schema.rb'
113+
- 'spec/lib/annotate/annotate_models_spec.rb'
114114

115115
# Offense count: 2
116116
# Cop supports --auto-correct.
@@ -129,7 +129,7 @@ Layout/EmptyLinesAroundAccessModifier:
129129
# Cop supports --auto-correct.
130130
Layout/EmptyLinesAroundArguments:
131131
Exclude:
132-
- 'spec/annotate/annotate_routes_spec.rb'
132+
- 'spec/lib/annotate/annotate_routes_spec.rb'
133133

134134
# Offense count: 6
135135
# Cop supports --auto-correct.
@@ -179,7 +179,6 @@ Layout/IndentFirstHashElement:
179179
# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
180180
Layout/IndentHeredoc:
181181
Exclude:
182-
- 'spec/annotate/annotate_models_spec.rb'
183182
- 'spec/integration/integration_spec.rb'
184183
- 'spec/integration/rails_2.3_with_bundler.rb'
185184
- 'spec/integration/rails_3.2.2.rb'
@@ -188,6 +187,7 @@ Layout/IndentHeredoc:
188187
- 'spec/integration/rails_3.2_custom_inflections.rb'
189188
- 'spec/integration/rails_3.2_with_asset_pipeline.rb'
190189
- 'spec/integration/standalone.rb'
190+
- 'spec/lib/annotate/annotate_models_spec.rb'
191191

192192
# Offense count: 1
193193
# Cop supports --auto-correct.
@@ -214,7 +214,7 @@ Layout/IndentationWidth:
214214
# SupportedStyles: aligned, indented, indented_relative_to_receiver
215215
Layout/MultilineMethodCallIndentation:
216216
Exclude:
217-
- 'spec/annotate/annotate_routes_spec.rb'
217+
- 'spec/lib/annotate/annotate_routes_spec.rb'
218218

219219
# Offense count: 5
220220
# Cop supports --auto-correct.
@@ -339,8 +339,8 @@ Layout/TrailingBlankLines:
339339
# Configuration parameters: AllowInHeredoc.
340340
Layout/TrailingWhitespace:
341341
Exclude:
342-
- 'spec/annotate/annotate_routes_spec.rb'
343342
- 'spec/integration/rails_2.3_with_bundler/db/schema.rb'
343+
- 'spec/lib/annotate/annotate_routes_spec.rb'
344344

345345
# Offense count: 3
346346
# Configuration parameters: AllowSafeAssignment.
@@ -349,12 +349,6 @@ Lint/AssignmentInCondition:
349349
- 'lib/annotate/annotate_models.rb'
350350
- 'spec/integration/rails_2.3_with_bundler/config/boot.rb'
351351

352-
# Offense count: 2
353-
# Cop supports --auto-correct.
354-
Lint/BigDecimalNew:
355-
Exclude:
356-
- 'spec/annotate/annotate_models_spec.rb'
357-
358352
# Offense count: 6
359353
# Cop supports --auto-correct.
360354
Lint/DeprecatedClassMethods:
@@ -412,18 +406,11 @@ Lint/ShadowingOuterLocalVariable:
412406
Exclude:
413407
- 'Rakefile'
414408

415-
# Offense count: 7
416-
# Cop supports --auto-correct.
417-
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
418-
Lint/UnusedBlockArgument:
419-
Exclude:
420-
- 'bin/annotate'
421-
422-
# Offense count: 19
409+
# Offense count: 20
423410
Metrics/AbcSize:
424411
Max: 138
425412

426-
# Offense count: 27
413+
# Offense count: 28
427414
# Configuration parameters: CountComments, ExcludedMethods.
428415
# ExcludedMethods: refine
429416
Metrics/BlockLength:
@@ -438,7 +425,7 @@ Metrics/BlockNesting:
438425
Metrics/CyclomaticComplexity:
439426
Max: 36
440427

441-
# Offense count: 29
428+
# Offense count: 30
442429
# Configuration parameters: CountComments, ExcludedMethods.
443430
Metrics/MethodLength:
444431
Max: 75
@@ -457,8 +444,8 @@ Naming/AccessorMethodName:
457444
# Blacklist: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
458445
Naming/HeredocDelimiterNaming:
459446
Exclude:
460-
- 'spec/annotate/annotate_models_spec.rb'
461-
- 'spec/annotate/annotate_routes_spec.rb'
447+
- 'spec/lib/annotate/annotate_models_spec.rb'
448+
- 'spec/lib/annotate/annotate_routes_spec.rb'
462449

463450
# Offense count: 2
464451
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
@@ -531,14 +518,6 @@ Style/ClassVars:
531518
Exclude:
532519
- 'lib/tasks/annotate_models_migrate.rake'
533520

534-
# Offense count: 1
535-
# Cop supports --auto-correct.
536-
# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
537-
# SupportedStyles: assign_to_condition, assign_inside_condition
538-
Style/ConditionalAssignment:
539-
Exclude:
540-
- 'bin/annotate'
541-
542521
# Offense count: 1
543522
# Cop supports --auto-correct.
544523
Style/Dir:
@@ -562,7 +541,6 @@ Style/Documentation:
562541
Style/Encoding:
563542
Exclude:
564543
- 'annotate.gemspec'
565-
- 'spec/annotate/annotate_models_spec.rb'
566544
- 'spec/integration/rails_3.2.2/db/schema.rb'
567545
- 'spec/integration/rails_3.2.8/db/schema.rb'
568546
- 'spec/integration/rails_3.2_autoloading_factory_girl/db/schema.rb'
@@ -571,6 +549,7 @@ Style/Encoding:
571549
- 'spec/integration/rails_4.1.1/db/schema.rb'
572550
- 'spec/integration/rails_4.2.0/db/schema.rb'
573551
- 'spec/integration/standalone/db/schema.rb'
552+
- 'spec/lib/annotate/annotate_models_spec.rb'
574553

575554
# Offense count: 48
576555
# Cop supports --auto-correct.
@@ -593,7 +572,7 @@ Style/FormatStringToken:
593572
Exclude:
594573
- 'lib/annotate/annotate_models.rb'
595574

596-
# Offense count: 184
575+
# Offense count: 186
597576
# Cop supports --auto-correct.
598577
# Configuration parameters: EnforcedStyle.
599578
# SupportedStyles: when_needed, always, never
@@ -690,26 +669,25 @@ Style/NumericPredicate:
690669
- 'lib/annotate.rb'
691670
- 'lib/annotate/annotate_models.rb'
692671

693-
# Offense count: 24
672+
# Offense count: 20
694673
# Cop supports --auto-correct.
695674
# Configuration parameters: PreferredDelimiters.
696675
Style/PercentLiteralDelimiters:
697676
Exclude:
698677
- 'annotate.gemspec'
699-
- 'bin/annotate'
700678
- 'lib/annotate/annotate_models.rb'
701679
- 'lib/annotate/annotate_routes.rb'
702680
- 'lib/tasks/annotate_models_migrate.rake'
703-
- 'spec/annotate/annotate_models_spec.rb'
704681
- 'spec/integration/rails_3.2.2/config/application.rb'
705682
- 'spec/integration/rails_3.2.8/config/application.rb'
706683
- 'spec/integration/rails_3.2_autoloading_factory_girl/config/application.rb'
707684
- 'spec/integration/rails_3.2_custom_inflections/config/application.rb'
708685
- 'spec/integration/rails_3.2_with_asset_pipeline/config/application.rb'
709686
- 'spec/integration/rails_4.1.1/app/models/task.rb'
710687
- 'spec/integration/rails_4.2.0/app/models/task.rb'
688+
- 'spec/lib/annotate/annotate_models_spec.rb'
689+
- 'spec/lib/tasks/annotate_models_migrate_spec.rb'
711690
- 'spec/spec_helper.rb'
712-
- 'spec/tasks/annotate_models_migrate_spec.rb'
713691

714692
# Offense count: 1
715693
# Cop supports --auto-correct.
@@ -730,7 +708,7 @@ Style/RaiseArgs:
730708
Style/RedundantBegin:
731709
Exclude:
732710
- 'lib/annotate/annotate_models.rb'
733-
- 'spec/annotate/annotate_models_spec.rb'
711+
- 'spec/lib/annotate/annotate_models_spec.rb'
734712

735713
# Offense count: 1
736714
# Cop supports --auto-correct.
@@ -784,12 +762,11 @@ Style/SafeNavigation:
784762
Exclude:
785763
- 'lib/annotate/annotate_models.rb'
786764

787-
# Offense count: 2
765+
# Offense count: 1
788766
# Cop supports --auto-correct.
789767
# Configuration parameters: AllowAsExpressionSeparator.
790768
Style/Semicolon:
791769
Exclude:
792-
- 'bin/annotate'
793770
- 'spec/integration/rails_2.3_with_bundler/config/initializers/unified_initializer.rb'
794771

795772
# Offense count: 18
@@ -801,7 +778,7 @@ Style/StderrPuts:
801778
- 'lib/annotate/annotate_models.rb'
802779
- 'spec/integration/rails_2.3_with_bundler/config/boot.rb'
803780

804-
# Offense count: 243
781+
# Offense count: 247
805782
# Cop supports --auto-correct.
806783
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
807784
# SupportedStyles: single_quotes, double_quotes
@@ -827,15 +804,15 @@ Style/SymbolArray:
827804
# Cop supports --auto-correct.
828805
Style/SymbolLiteral:
829806
Exclude:
830-
- 'spec/annotate/annotate_models_spec.rb'
807+
- 'spec/lib/annotate/annotate_models_spec.rb'
831808

832809
# Offense count: 1
833810
# Cop supports --auto-correct.
834811
# Configuration parameters: EnforcedStyleForMultiline.
835812
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
836813
Style/TrailingCommaInArrayLiteral:
837814
Exclude:
838-
- 'spec/annotate/annotate_models_spec.rb'
815+
- 'spec/lib/annotate/annotate_models_spec.rb'
839816

840817
# Offense count: 2
841818
# Cop supports --auto-correct.
@@ -846,20 +823,14 @@ Style/TrailingCommaInHashLiteral:
846823
- 'spec/integration/rails_4.1.1/lib/tasks/auto_annotate_models.rake'
847824
- 'spec/integration/rails_4.2.0/lib/tasks/auto_annotate_models.rake'
848825

849-
# Offense count: 2
850-
# Cop supports --auto-correct.
851-
Style/UnneededInterpolation:
852-
Exclude:
853-
- 'bin/annotate'
854-
855826
# Offense count: 4
856827
# Cop supports --auto-correct.
857828
Style/UnneededPercentQ:
858829
Exclude:
859830
- 'annotate.gemspec'
860831
- 'spec/integration/rails_2.3_with_bundler/config/boot.rb'
861832

862-
# Offense count: 431
833+
# Offense count: 465
863834
# Cop supports --auto-correct.
864835
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
865836
# URISchemes: http, https

spec/annotate/annotate_models_spec.rb renamed to spec/lib/annotate/annotate_models_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# encoding: utf-8
2-
require File.dirname(__FILE__) + '/../spec_helper.rb'
2+
require_relative '../../spec_helper'
33
require 'annotate/annotate_models'
44
require 'annotate/active_record_patch'
55
require 'active_support/core_ext/string'
@@ -1819,7 +1819,7 @@ class User < ActiveRecord::Base
18191819
end
18201820

18211821
expect(error_output).to include("Unable to annotate #{@model_dir}/user.rb: oops")
1822-
expect(error_output).to include('/spec/annotate/annotate_models_spec.rb:')
1822+
expect(error_output).to include('/spec/lib/annotate/annotate_models_spec.rb:')
18231823
end
18241824
end
18251825

spec/annotate/annotate_routes_spec.rb renamed to spec/lib/annotate/annotate_routes_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require File.dirname(__FILE__) + '/../spec_helper.rb'
1+
require_relative '../../spec_helper'
22
require 'annotate/annotate_routes'
33

44
describe AnnotateRoutes do

spec/annotate/parser_spec.rb renamed to spec/lib/annotate/parser_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require File.dirname(__FILE__) + '/../spec_helper.rb'
1+
require_relative '../../spec_helper'
22

33
module Annotate # rubocop:disable Metrics/ModuleLength
44
describe Parser do # rubocop:disable Metrics/BlockLength

spec/annotate_spec.rb renamed to spec/lib/annotate_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require File.dirname(__FILE__) + '/spec_helper.rb'
1+
require_relative '../spec_helper'
22

33
describe Annotate do
44
it 'should have a version' do

spec/tasks/annotate_models_migrate_spec.rb renamed to spec/lib/tasks/annotate_models_migrate_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require_relative '../spec_helper'
1+
require_relative '../../spec_helper'
22

33
describe 'ActiveRecord migration rake task hooks' do
44
before do

0 commit comments

Comments
 (0)