Skip to content

Commit

Permalink
Tidy spec directory (ctran#646)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
drwl authored and vfonic committed May 8, 2020
1 parent 6179d9f commit 3d5c268
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 62 deletions.
83 changes: 27 additions & 56 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2019-06-16 12:01:03 -0700 using RuboCop version 0.68.1.
# on 2019-09-02 16:23:56 -0700 using RuboCop version 0.68.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -49,9 +49,9 @@ Gemspec/RequiredRubyVersion:
# Cop supports --auto-correct.
Layout/AlignArray:
Exclude:
- 'spec/annotate/annotate_models_spec.rb'
- 'spec/lib/annotate/annotate_models_spec.rb'

# Offense count: 104
# Offense count: 107
# Cop supports --auto-correct.
# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
# SupportedHashRocketStyles: key, separator, table
Expand All @@ -60,11 +60,11 @@ Layout/AlignArray:
Layout/AlignHash:
Exclude:
- 'lib/generators/annotate/templates/auto_annotate_models.rake'
- 'spec/annotate/annotate_models_spec.rb'
- 'spec/integration/rails_2.3_with_bundler/config/initializers/unified_initializer.rb'
- 'spec/integration/rails_4.1.1/lib/tasks/auto_annotate_models.rake'
- 'spec/integration/rails_4.2.0/lib/tasks/auto_annotate_models.rake'
- 'spec/integration/standalone/config/init.rb'
- 'spec/lib/annotate/annotate_models_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
Expand All @@ -78,16 +78,16 @@ Layout/BlockAlignment:
# Cop supports --auto-correct.
Layout/ClosingHeredocIndentation:
Exclude:
- 'spec/annotate/annotate_models_spec.rb'
- 'spec/integration/rails_2.3_with_bundler.rb'
- 'spec/integration/rails_3.2.2.rb'
- 'spec/integration/rails_3.2.8.rb'
- 'spec/integration/rails_3.2_autoloading_factory_girl.rb'
- 'spec/integration/rails_3.2_custom_inflections.rb'
- 'spec/integration/rails_3.2_with_asset_pipeline.rb'
- 'spec/integration/standalone.rb'
- 'spec/lib/annotate/annotate_models_spec.rb'

# Offense count: 14
# Offense count: 13
# Cop supports --auto-correct.
Layout/EmptyLineAfterGuardClause:
Exclude:
Expand All @@ -102,7 +102,6 @@ Layout/EmptyLineAfterGuardClause:
Layout/EmptyLineAfterMagicComment:
Exclude:
- 'annotate.gemspec'
- 'spec/annotate/annotate_models_spec.rb'
- 'spec/integration/rails_3.2.2/db/schema.rb'
- 'spec/integration/rails_3.2.8/db/schema.rb'
- 'spec/integration/rails_3.2_autoloading_factory_girl/db/schema.rb'
Expand All @@ -111,6 +110,7 @@ Layout/EmptyLineAfterMagicComment:
- 'spec/integration/rails_4.1.1/db/schema.rb'
- 'spec/integration/rails_4.2.0/db/schema.rb'
- 'spec/integration/standalone/db/schema.rb'
- 'spec/lib/annotate/annotate_models_spec.rb'

# Offense count: 2
# Cop supports --auto-correct.
Expand All @@ -129,7 +129,7 @@ Layout/EmptyLinesAroundAccessModifier:
# Cop supports --auto-correct.
Layout/EmptyLinesAroundArguments:
Exclude:
- 'spec/annotate/annotate_routes_spec.rb'
- 'spec/lib/annotate/annotate_routes_spec.rb'

# Offense count: 6
# Cop supports --auto-correct.
Expand Down Expand Up @@ -179,7 +179,6 @@ Layout/IndentFirstHashElement:
# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
Layout/IndentHeredoc:
Exclude:
- 'spec/annotate/annotate_models_spec.rb'
- 'spec/integration/integration_spec.rb'
- 'spec/integration/rails_2.3_with_bundler.rb'
- 'spec/integration/rails_3.2.2.rb'
Expand All @@ -188,6 +187,7 @@ Layout/IndentHeredoc:
- 'spec/integration/rails_3.2_custom_inflections.rb'
- 'spec/integration/rails_3.2_with_asset_pipeline.rb'
- 'spec/integration/standalone.rb'
- 'spec/lib/annotate/annotate_models_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
Expand All @@ -214,7 +214,7 @@ Layout/IndentationWidth:
# SupportedStyles: aligned, indented, indented_relative_to_receiver
Layout/MultilineMethodCallIndentation:
Exclude:
- 'spec/annotate/annotate_routes_spec.rb'
- 'spec/lib/annotate/annotate_routes_spec.rb'

# Offense count: 5
# Cop supports --auto-correct.
Expand Down Expand Up @@ -339,8 +339,8 @@ Layout/TrailingBlankLines:
# Configuration parameters: AllowInHeredoc.
Layout/TrailingWhitespace:
Exclude:
- 'spec/annotate/annotate_routes_spec.rb'
- 'spec/integration/rails_2.3_with_bundler/db/schema.rb'
- 'spec/lib/annotate/annotate_routes_spec.rb'

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

# Offense count: 2
# Cop supports --auto-correct.
Lint/BigDecimalNew:
Exclude:
- 'spec/annotate/annotate_models_spec.rb'

# Offense count: 6
# Cop supports --auto-correct.
Lint/DeprecatedClassMethods:
Expand Down Expand Up @@ -412,18 +406,11 @@ Lint/ShadowingOuterLocalVariable:
Exclude:
- 'Rakefile'

# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
Lint/UnusedBlockArgument:
Exclude:
- 'bin/annotate'

# Offense count: 19
# Offense count: 20
Metrics/AbcSize:
Max: 138

# Offense count: 27
# Offense count: 28
# Configuration parameters: CountComments, ExcludedMethods.
# ExcludedMethods: refine
Metrics/BlockLength:
Expand All @@ -438,7 +425,7 @@ Metrics/BlockNesting:
Metrics/CyclomaticComplexity:
Max: 36

# Offense count: 29
# Offense count: 30
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/MethodLength:
Max: 75
Expand All @@ -457,8 +444,8 @@ Naming/AccessorMethodName:
# Blacklist: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
Naming/HeredocDelimiterNaming:
Exclude:
- 'spec/annotate/annotate_models_spec.rb'
- 'spec/annotate/annotate_routes_spec.rb'
- 'spec/lib/annotate/annotate_models_spec.rb'
- 'spec/lib/annotate/annotate_routes_spec.rb'

# Offense count: 2
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
Expand Down Expand Up @@ -531,14 +518,6 @@ Style/ClassVars:
Exclude:
- 'lib/tasks/annotate_models_migrate.rake'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
# SupportedStyles: assign_to_condition, assign_inside_condition
Style/ConditionalAssignment:
Exclude:
- 'bin/annotate'

# Offense count: 1
# Cop supports --auto-correct.
Style/Dir:
Expand All @@ -562,7 +541,6 @@ Style/Documentation:
Style/Encoding:
Exclude:
- 'annotate.gemspec'
- 'spec/annotate/annotate_models_spec.rb'
- 'spec/integration/rails_3.2.2/db/schema.rb'
- 'spec/integration/rails_3.2.8/db/schema.rb'
- 'spec/integration/rails_3.2_autoloading_factory_girl/db/schema.rb'
Expand All @@ -571,6 +549,7 @@ Style/Encoding:
- 'spec/integration/rails_4.1.1/db/schema.rb'
- 'spec/integration/rails_4.2.0/db/schema.rb'
- 'spec/integration/standalone/db/schema.rb'
- 'spec/lib/annotate/annotate_models_spec.rb'

# Offense count: 48
# Cop supports --auto-correct.
Expand All @@ -593,7 +572,7 @@ Style/FormatStringToken:
Exclude:
- 'lib/annotate/annotate_models.rb'

# Offense count: 184
# Offense count: 186
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: when_needed, always, never
Expand Down Expand Up @@ -690,26 +669,25 @@ Style/NumericPredicate:
- 'lib/annotate.rb'
- 'lib/annotate/annotate_models.rb'

# Offense count: 24
# Offense count: 20
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Exclude:
- 'annotate.gemspec'
- 'bin/annotate'
- 'lib/annotate/annotate_models.rb'
- 'lib/annotate/annotate_routes.rb'
- 'lib/tasks/annotate_models_migrate.rake'
- 'spec/annotate/annotate_models_spec.rb'
- 'spec/integration/rails_3.2.2/config/application.rb'
- 'spec/integration/rails_3.2.8/config/application.rb'
- 'spec/integration/rails_3.2_autoloading_factory_girl/config/application.rb'
- 'spec/integration/rails_3.2_custom_inflections/config/application.rb'
- 'spec/integration/rails_3.2_with_asset_pipeline/config/application.rb'
- 'spec/integration/rails_4.1.1/app/models/task.rb'
- 'spec/integration/rails_4.2.0/app/models/task.rb'
- 'spec/lib/annotate/annotate_models_spec.rb'
- 'spec/lib/tasks/annotate_models_migrate_spec.rb'
- 'spec/spec_helper.rb'
- 'spec/tasks/annotate_models_migrate_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
Expand All @@ -730,7 +708,7 @@ Style/RaiseArgs:
Style/RedundantBegin:
Exclude:
- 'lib/annotate/annotate_models.rb'
- 'spec/annotate/annotate_models_spec.rb'
- 'spec/lib/annotate/annotate_models_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
Expand Down Expand Up @@ -784,12 +762,11 @@ Style/SafeNavigation:
Exclude:
- 'lib/annotate/annotate_models.rb'

# Offense count: 2
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowAsExpressionSeparator.
Style/Semicolon:
Exclude:
- 'bin/annotate'
- 'spec/integration/rails_2.3_with_bundler/config/initializers/unified_initializer.rb'

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

# Offense count: 243
# Offense count: 247
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Expand All @@ -827,15 +804,15 @@ Style/SymbolArray:
# Cop supports --auto-correct.
Style/SymbolLiteral:
Exclude:
- 'spec/annotate/annotate_models_spec.rb'
- 'spec/lib/annotate/annotate_models_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInArrayLiteral:
Exclude:
- 'spec/annotate/annotate_models_spec.rb'
- 'spec/lib/annotate/annotate_models_spec.rb'

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

# Offense count: 2
# Cop supports --auto-correct.
Style/UnneededInterpolation:
Exclude:
- 'bin/annotate'

# Offense count: 4
# Cop supports --auto-correct.
Style/UnneededPercentQ:
Exclude:
- 'annotate.gemspec'
- 'spec/integration/rails_2.3_with_bundler/config/boot.rb'

# Offense count: 431
# Offense count: 465
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# encoding: utf-8
require File.dirname(__FILE__) + '/../spec_helper.rb'
require_relative '../../spec_helper'
require 'annotate/annotate_models'
require 'annotate/active_record_patch'
require 'active_support/core_ext/string'
Expand Down Expand Up @@ -1819,7 +1819,7 @@ class User < ActiveRecord::Base
end

expect(error_output).to include("Unable to annotate #{@model_dir}/user.rb: oops")
expect(error_output).to include('/spec/annotate/annotate_models_spec.rb:')
expect(error_output).to include('/spec/lib/annotate/annotate_models_spec.rb:')
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../spec_helper.rb'
require_relative '../../spec_helper'
require 'annotate/annotate_routes'

describe AnnotateRoutes do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../spec_helper.rb'
require_relative '../../spec_helper'

module Annotate # rubocop:disable Metrics/ModuleLength
describe Parser do # rubocop:disable Metrics/BlockLength
Expand Down
2 changes: 1 addition & 1 deletion spec/annotate_spec.rb → spec/lib/annotate_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/spec_helper.rb'
require_relative '../spec_helper'

describe Annotate do
it 'should have a version' do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require_relative '../spec_helper'
require_relative '../../spec_helper'

describe 'ActiveRecord migration rake task hooks' do
before do
Expand Down

0 comments on commit 3d5c268

Please sign in to comment.