Skip to content

Commit

Permalink
formatter/formatter_set_spec.rb - remove references to file IO on Win…
Browse files Browse the repository at this point in the history
…dows
  • Loading branch information
MSP-Greg committed Aug 25, 2022
1 parent bd42ff6 commit bc55776
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions spec/rubocop/formatter/formatter_set_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
RSpec.describe RuboCop::Formatter::FormatterSet do
subject(:formatter_set) { described_class.new }

win_close = lambda do |fset|
fset.close_output_files
fset.each { |f| f.instance_variable_set :@output, nil }
end

it 'responds to all formatter API methods' do
%i[started file_started file_finished finished].each do |method|
expect(formatter_set).to respond_to(method)
Expand Down Expand Up @@ -52,6 +57,7 @@
formatter_set.add_formatter('simple', output_path)
expect(formatter_set.first.output.class).to eq(File)
expect(formatter_set.first.output.path).to eq(output_path)
win_close.call(formatter_set) if RuboCop::Platform.windows?
end

context "when parent directories don't exist" do
Expand All @@ -60,13 +66,11 @@
after { FileUtils.rm_rf(tmpdir) }

it 'creates them' do
# FIXME: Skips this spec to prevent `Errno::EACCES` error in mingw CI matrix.
skip if ENV['GITHUB_JOB'] == 'main' && ENV['MSYSTEM'] == 'MINGW64'

output_path = File.join(tmpdir, 'path/does/not/exist')
formatter_set.add_formatter('simple', output_path)
expect(formatter_set.first.output.class).to eq(File)
expect(formatter_set.first.output.path).to eq(output_path)
win_close.call(formatter_set) if RuboCop::Platform.windows?
end
end
end
Expand All @@ -91,10 +95,12 @@
it 'closes all output files' do
formatter_set.close_output_files
formatter_set[0..1].each { |formatter| expect(formatter.output.closed?).to be(true) }
win_close.call(formatter_set) if RuboCop::Platform.windows?
end

it 'does not close non file output' do
expect(formatter_set[2].output.closed?).to be(false)
win_close.call(formatter_set) if RuboCop::Platform.windows?
end
end

Expand Down

0 comments on commit bc55776

Please sign in to comment.