Skip to content

Commit 665ed02

Browse files
committed
Add spec
1 parent 11cfdaf commit 665ed02

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Library/Homebrew/test/rubocop_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22

33
require "open3"
4+
require "yaml"
45

56
RSpec.describe "RuboCop" do
67
context "when calling `rubocop` outside of the Homebrew environment" do
@@ -23,4 +24,17 @@
2324
expect(status).to be_a_success
2425
end
2526
end
27+
28+
describe "configuration" do
29+
it "has TargetRubyVersion matching .ruby-version" do
30+
rubocop_config_path = HOMEBREW_LIBRARY_PATH.parent/".rubocop.yml"
31+
rubocop_config = YAML.unsafe_load_file(rubocop_config_path)
32+
target_ruby_version = rubocop_config.dig("AllCops", "TargetRubyVersion")
33+
34+
ruby_version_path = HOMEBREW_LIBRARY_PATH/".ruby-version"
35+
ruby_version = ruby_version_path.read.strip.to_f
36+
37+
expect(target_ruby_version).to eq(ruby_version)
38+
end
39+
end
2640
end

0 commit comments

Comments
 (0)