Class: PolishGeeks::DevTools::Commands::RspecFilesNames
- Defined in:
- lib/polish_geeks/dev_tools/commands/rspec_files_names.rb
Overview
Validator used to check if all the rspec spec files have a proper sufix (_spec.rb)
Constant Summary collapse
- CHECKED_DIRS =
List of dirs in spec/ dir that we will check for _spec.rb naming
%w( aggregators controllers helpers lib libs models decorators presenters services workers mailers requests polishgeeks* ).freeze
- CHECK_REGEXP =
Regexp used to check names in spec files
/(\_spec\.rb)$/
Constants inherited from Base
Instance Attribute Summary collapse
-
#counter ⇒ Object
readonly
Returns the value of attribute counter.
Attributes inherited from Base
Instance Method Summary collapse
-
#error_message ⇒ String
Message that should be printed when some files have invalid name.
-
#execute ⇒ Array
Executes this command.
-
#label ⇒ String
Default label for this command.
-
#valid? ⇒ Boolean
True if all specs have a proper sufix (_spec.rb).
Methods inherited from Base
Instance Attribute Details
#counter ⇒ Object (readonly)
Returns the value of attribute counter.
9 10 11 |
# File 'lib/polish_geeks/dev_tools/commands/rspec_files_names.rb', line 9 def counter @counter end |
Instance Method Details
#error_message ⇒ String
Returns message that should be printed when some files have invalid name.
52 53 54 |
# File 'lib/polish_geeks/dev_tools/commands/rspec_files_names.rb', line 52 def "Following files have invalid name: \n #{output.join("\n")}\n" end |
#execute ⇒ Array
Executes this command
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/polish_geeks/dev_tools/commands/rspec_files_names.rb', line 24 def execute @output = [] @counter = 0 CHECKED_DIRS.each do |name| path = File.join(::PolishGeeks::DevTools.app_root, 'spec', name) files = Dir.glob("#{path}/**/*").select { |f| File.file? f } @counter += files.count files.each do |file| @output << file unless file =~ CHECK_REGEXP end end end |
#label ⇒ String
Returns default label for this command.
46 47 48 |
# File 'lib/polish_geeks/dev_tools/commands/rspec_files_names.rb', line 46 def label "Rspec files names: #{counter} files checked" end |
#valid? ⇒ Boolean
Returns true if all specs have a proper sufix (_spec.rb).
41 42 43 |
# File 'lib/polish_geeks/dev_tools/commands/rspec_files_names.rb', line 41 def valid? output.empty? end |