diff options
author | Robert Speicher <robert@gitlab.com> | 2017-05-18 19:42:15 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-05-18 19:42:15 +0000 |
commit | 9616027045b68a8d238ca24d3116ff6f7bf9b3dc (patch) | |
tree | 89a38b06508aa6f8caa921f9309ceaefc8e919b4 | |
parent | e4eec191565a053f687911d80865ad43241453f8 (diff) | |
parent | bdf5b6adc34ae2856bddea62ce449fa452aee761 (diff) | |
download | gitlab-ce-9616027045b68a8d238ca24d3116ff6f7bf9b3dc.tar.gz |
Merge branch 'rubocop-expect-output' into 'master'
Enable the RSpec/ExpectOutput cop
See merge request !11500
-rw-r--r-- | .rubocop.yml | 3 | ||||
-rw-r--r-- | .rubocop_todo.yml | 4 | ||||
-rw-r--r-- | spec/bin/changelog_spec.rb | 4 | ||||
-rw-r--r-- | spec/tasks/gitlab/gitaly_rake_spec.rb | 22 |
4 files changed, 15 insertions, 18 deletions
diff --git a/.rubocop.yml b/.rubocop.yml index 4e1d456d8d1..9380f65eb65 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -987,6 +987,9 @@ RSpec/ExampleWording: RSpec/ExpectActual: Enabled: true +RSpec/ExpectOutput: + Enabled: true + # Checks the file and folder naming of the spec file. RSpec/FilePath: Enabled: true diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 7582f761bcb..0ea0b1a848d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -23,10 +23,6 @@ RSpec/EmptyLineAfterFinalLet: RSpec/EmptyLineAfterSubject: Enabled: false -# Offense count: 3 -RSpec/ExpectOutput: - Enabled: false - # Offense count: 72 # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: implicit, each, example diff --git a/spec/bin/changelog_spec.rb b/spec/bin/changelog_spec.rb index 7f4298db59f..91aff0db7cc 100644 --- a/spec/bin/changelog_spec.rb +++ b/spec/bin/changelog_spec.rb @@ -46,9 +46,7 @@ describe 'bin/changelog' do it 'parses -h' do expect do - $stdout = StringIO.new - - described_class.parse(%w[foo -h bar]) + expect { described_class.parse(%w[foo -h bar]) }.to output.to_stdout end.to raise_error(SystemExit) end diff --git a/spec/tasks/gitlab/gitaly_rake_spec.rb b/spec/tasks/gitlab/gitaly_rake_spec.rb index f035504320b..4a636decafd 100644 --- a/spec/tasks/gitlab/gitaly_rake_spec.rb +++ b/spec/tasks/gitlab/gitaly_rake_spec.rb @@ -84,24 +84,24 @@ describe 'gitlab:gitaly namespace rake task' do } allow(Gitlab.config.repositories).to receive(:storages).and_return(config) - orig_stdout = $stdout - $stdout = StringIO.new - - header = '' + expected_output = '' Timecop.freeze do - header = <<~TOML + expected_output = <<~TOML # Gitaly storage configuration generated from #{Gitlab.config.source} on #{Time.current.to_s(:long)} # This is in TOML format suitable for use in Gitaly's config.toml file. + [[storage]] + name = "default" + path = "/path/to/default" + [[storage]] + name = "nfs_01" + path = "/path/to/nfs_01" TOML - run_rake_task('gitlab:gitaly:storage_config') end - output = $stdout.string - $stdout = orig_stdout - - expect(output).to include(header) + expect { run_rake_task('gitlab:gitaly:storage_config')}. + to output(expected_output).to_stdout - parsed_output = TOML.parse(output) + parsed_output = TOML.parse(expected_output) config.each do |name, params| expect(parsed_output['storage']).to include({ 'name' => name, 'path' => params['path'] }) end |