From 7aec4fda94041256ad8ab2a103edbcdd1f0f7411 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 30 Oct 2017 21:31:59 -0400 Subject: [PATCH] Add rubocop-rspec as a dev dependency. Fix non-directory changing fixes --- .rubocop.yml | 9 +++++++++ Rakefile | 4 +++- colorls.gemspec | 1 + spec/{colorls_spec.rb => color_ls_spec.rb} | 0 spec/flags_spec.rb | 20 ++++++++++---------- 5 files changed, 23 insertions(+), 11 deletions(-) rename spec/{colorls_spec.rb => color_ls_spec.rb} (100%) diff --git a/.rubocop.yml b/.rubocop.yml index c032191..e05b2cd 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -11,6 +11,15 @@ AllCops: TargetRubyVersion: 2.1 # Preferred codebase style --------------------------------------------- + +RSpec/DescribeClass: + Exclude: + - 'spec/yaml_spec.rb' + +RSpec/FilePath: + Exclude: + - 'spec/flags_spec.rb' + Layout/ExtraSpacing: AllowForAlignment: true diff --git a/Rakefile b/Rakefile index f5bbedb..b27cbb6 100644 --- a/Rakefile +++ b/Rakefile @@ -6,6 +6,8 @@ require 'rspec/core/rake_task' RSpec::Core::RakeTask.new require 'rubocop/rake_task' -RuboCop::RakeTask.new +RuboCop::RakeTask.new do |task| + task.requires << 'rubocop-rspec' +end task default: %w[spec rubocop] diff --git a/colorls.gemspec b/colorls.gemspec index 26f6afa..44f1361 100644 --- a/colorls.gemspec +++ b/colorls.gemspec @@ -48,5 +48,6 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rspec' spec.add_development_dependency 'rspec-its' spec.add_development_dependency 'rubocop' + spec.add_development_dependency 'rubocop-rspec' spec.add_development_dependency 'rubygems-tasks' end diff --git a/spec/colorls_spec.rb b/spec/color_ls_spec.rb similarity index 100% rename from spec/colorls_spec.rb rename to spec/color_ls_spec.rb diff --git a/spec/flags_spec.rb b/spec/flags_spec.rb index 685497e..ebf64f1 100644 --- a/spec/flags_spec.rb +++ b/spec/flags_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe ColorLS::Flags do FIXTURES = 'spec/fixtures'.freeze - subject { capture_stdout { ColorLS::Flags.new(*args).process } } + subject { capture_stdout { described_class.new(*args).process } } def capture_stdout old = $stdout @@ -17,13 +17,13 @@ RSpec.describe ColorLS::Flags do context 'with no flags' do let(:args) { [FIXTURES] } - it { is_expected.to_not match(/((r|-).*(w|-).*(x|-).*){3}/) } # does not list file info - it { is_expected.to_not match(/\.hidden-file/) } # does not display hidden files - it { is_expected.to_not match(/Found \d+ contents/) } # does not show a report + it { is_expected.not_to match(/((r|-).*(w|-).*(x|-).*){3}/) } # does not list file info + it { is_expected.not_to match(/\.hidden-file/) } # does not display hidden files + it { is_expected.not_to match(/Found \d+ contents/) } # does not show a report it { is_expected.to match(/a-file.+symlinks.+z-file/) } # displays dirs & files alphabetically - it { is_expected.to_not match(/(.*\n){3}/) } # displays multiple files per line - it { is_expected.to_not match(%r(\.{1,2}/)) } # does not display ./ or ../ - it { is_expected.to_not match(/├──/) } # does not display file hierarchy + it { is_expected.not_to match(/(.*\n){3}/) } # displays multiple files per line + it { is_expected.not_to match(%r(\.{1,2}/)) } # does not display ./ or ../ + it { is_expected.not_to match(/├──/) } # does not display file hierarchy end context 'with --reverse flag' do @@ -35,7 +35,7 @@ RSpec.describe ColorLS::Flags do context 'with --long flag & file path' do let(:args) { ['--long', "#{FIXTURES}/.hidden-file"] } - it { is_expected.to_not match(/No Info/) } # lists info of a hidden file + it { is_expected.not_to match(/No Info/) } # lists info of a hidden file end context 'with --long flag' do @@ -88,13 +88,13 @@ RSpec.describe ColorLS::Flags do context 'with --dirs flag' do let(:args) { ['--dirs', FIXTURES] } - it { is_expected.to_not match(/a-file/) } # displays dirs only + it { is_expected.not_to match(/a-file/) } # displays dirs only end context 'with --files flag' do let(:args) { ['--files', FIXTURES] } - it { is_expected.to_not match(/symlinks/) } # displays files only + it { is_expected.not_to match(/symlinks/) } # displays files only end context 'with -1 flag' do