Skip to content

Commit 25146e6

Browse files
committed
Add specs for ContinuousBuildCodeFormatter component validation
Cover the non-Integer and negative cases for major/minor/build_number added in c906a6b.
1 parent a649a64 commit 25146e6

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

spec/continuous_build_code_formatter_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,21 @@
5959
expect { described_class.new(build_digits: 0) }
6060
.to raise_error(/`build_digits` must be a positive integer, got: 0/)
6161
end
62+
63+
%w[major minor build_number].each do |component|
64+
it "rejects a non-integer #{component} with a user-friendly error" do
65+
args = { major: 26, minor: 9, build_number: 84_231 }
66+
args[component.to_sym] = '1' # e.g. an unparsed value from an env var or file read
67+
expect { described_class.new.build_code(**args) }
68+
.to raise_error(/`#{component}` must be an integer, got: String/)
69+
end
70+
71+
it "rejects a negative #{component}" do
72+
args = { major: 26, minor: 9, build_number: 84_231 }
73+
args[component.to_sym] = -1
74+
expect { described_class.new.build_code(**args) }
75+
.to raise_error(/`#{component}` must be a non-negative integer, got: -1/)
76+
end
77+
end
6278
end
6379
end

0 commit comments

Comments
 (0)