Add rubocop-rspec as a dev dependency. Fix non-directory changing fixes

This commit is contained in:
Alex 2017-10-30 21:31:59 -04:00
parent 015b5c0467
commit 7aec4fda94
5 changed files with 23 additions and 11 deletions

View file

@ -11,6 +11,15 @@ AllCops:
TargetRubyVersion: 2.1 TargetRubyVersion: 2.1
# Preferred codebase style --------------------------------------------- # Preferred codebase style ---------------------------------------------
RSpec/DescribeClass:
Exclude:
- 'spec/yaml_spec.rb'
RSpec/FilePath:
Exclude:
- 'spec/flags_spec.rb'
Layout/ExtraSpacing: Layout/ExtraSpacing:
AllowForAlignment: true AllowForAlignment: true

View file

@ -6,6 +6,8 @@ require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new RSpec::Core::RakeTask.new
require 'rubocop/rake_task' require 'rubocop/rake_task'
RuboCop::RakeTask.new RuboCop::RakeTask.new do |task|
task.requires << 'rubocop-rspec'
end
task default: %w[spec rubocop] task default: %w[spec rubocop]

View file

@ -48,5 +48,6 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rspec' spec.add_development_dependency 'rspec'
spec.add_development_dependency 'rspec-its' spec.add_development_dependency 'rspec-its'
spec.add_development_dependency 'rubocop' spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rubocop-rspec'
spec.add_development_dependency 'rubygems-tasks' spec.add_development_dependency 'rubygems-tasks'
end end

View file

@ -3,7 +3,7 @@ require 'spec_helper'
RSpec.describe ColorLS::Flags do RSpec.describe ColorLS::Flags do
FIXTURES = 'spec/fixtures'.freeze FIXTURES = 'spec/fixtures'.freeze
subject { capture_stdout { ColorLS::Flags.new(*args).process } } subject { capture_stdout { described_class.new(*args).process } }
def capture_stdout def capture_stdout
old = $stdout old = $stdout
@ -17,13 +17,13 @@ RSpec.describe ColorLS::Flags do
context 'with no flags' do context 'with no flags' do
let(:args) { [FIXTURES] } let(:args) { [FIXTURES] }
it { is_expected.to_not match(/((r|-).*(w|-).*(x|-).*){3}/) } # does not list file info it { is_expected.not_to 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.not_to 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(/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 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.not_to match(/(.*\n){3}/) } # displays multiple files per line
it { is_expected.to_not match(%r(\.{1,2}/)) } # does not display ./ or ../ it { is_expected.not_to 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(/├──/) } # does not display file hierarchy
end end
context 'with --reverse flag' do context 'with --reverse flag' do
@ -35,7 +35,7 @@ RSpec.describe ColorLS::Flags do
context 'with --long flag & file path' do context 'with --long flag & file path' do
let(:args) { ['--long', "#{FIXTURES}/.hidden-file"] } 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 end
context 'with --long flag' do context 'with --long flag' do
@ -88,13 +88,13 @@ RSpec.describe ColorLS::Flags do
context 'with --dirs flag' do context 'with --dirs flag' do
let(:args) { ['--dirs', FIXTURES] } 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 end
context 'with --files flag' do context 'with --files flag' do
let(:args) { ['--files', FIXTURES] } 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 end
context 'with -1 flag' do context 'with -1 flag' do