brew/Library/Homebrew/test/rubocop_spec.rb

27 lines
768 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2018-09-05 00:58:28 +02:00
require "open3"
RSpec.describe "RuboCop" do
2018-09-05 00:58:28 +02:00
context "when calling `rubocop` outside of the Homebrew environment" do
before do
2020-02-19 11:18:40 +00:00
ENV.each_key do |key|
2023-09-29 01:58:41 +01:00
allowlist = %w[
HOMEBREW_TESTS
HOMEBREW_USE_RUBY_FROM_PATH
]
ENV.delete(key) if key.start_with?("HOMEBREW_") && allowlist.exclude?(key)
2018-09-05 00:58:28 +02:00
end
2020-10-20 12:03:48 +02:00
ENV["XDG_CACHE_HOME"] = (HOMEBREW_CACHE.realpath/"style").to_s
2018-09-05 00:58:28 +02:00
end
it "loads all Formula cops without errors" do
2020-12-02 10:38:12 +01:00
stdout, stderr, status = Open3.capture3(RUBY_PATH, "-W0", "-S", "rubocop", TEST_FIXTURE_DIR/"testball.rb")
2020-10-20 12:03:48 +02:00
expect(stderr).to be_empty
expect(stdout).to include("no offenses detected")
2018-09-05 00:58:28 +02:00
expect(status).to be_a_success
end
end
end