Class: PolishGeeks::DevTools::Commands::RspecFilesStructure

Inherits:
Base
  • Object
show all
Defined in:
lib/polish_geeks/dev_tools/commands/rspec_files_structure.rb

Overview

Checks if there are are rb files that don’t have corresponding rspec spec files defined This will validate that the names are the same (no typos, etc) and no file are without spec files (even just with pending)

Constant Summary collapse

FILES_CHECKED =

Files in directories that we want to check against their rspec corresponding files

%w(
  app/**/*.rb
  lib/**/*.rb
).freeze
RSPEC_FILES =

From where should we take spec files

%w(
  spec/**/*_spec.rb
).freeze

Constants inherited from Base

Base::TYPES

Instance Attribute Summary

Attributes inherited from Base

#output, #stored_output

Instance Method Summary collapse

Methods inherited from Base

#ensure_executable!

Instance Method Details

#error_messageString

Returns error message that will be displayed if something goes wrong.

Returns:

  • (String)

    error message that will be displayed if something goes wrong



46
47
48
49
# File 'lib/polish_geeks/dev_tools/commands/rspec_files_structure.rb', line 46

def error_message
  err = files_error_message + rspec_error_message
  err
end

#executeArray<String>

Executes this command

Returns:

  • (Array<String>)

    empty array if all the files have corresponding rspec files, otherwise array will contain files that doesn’t



26
27
28
29
30
31
# File 'lib/polish_geeks/dev_tools/commands/rspec_files_structure.rb', line 26

def execute
  @output = {
    app: analyzed_files - analyzed_rspec_files,
    rspec: analyzed_rspec_files - analyzed_files
  }
end

#labelString

Returns label with this validator description.

Returns:

  • (String)

    label with this validator description



40
41
42
# File 'lib/polish_geeks/dev_tools/commands/rspec_files_structure.rb', line 40

def label
  "Rspec files structure (#{analyzed_files.count} checked)"
end

#valid?Boolean

Returns true if everything is ok and all the files have rspec corresponding files.

Returns:

  • (Boolean)

    true if everything is ok and all the files have rspec corresponding files



35
36
37
# File 'lib/polish_geeks/dev_tools/commands/rspec_files_structure.rb', line 35

def valid?
  @output[:app].empty? && @output[:rspec].empty?
end