Add test coverage

This commit is contained in:
Ethan Dennis
2023-05-15 12:29:15 -07:00
parent 0a01e3e141
commit b0e1adc47c
2 changed files with 17 additions and 10 deletions
+4 -5
View File
@@ -24,18 +24,17 @@ class Arguments
arguments.concat(["--custom-transformers", *@custom_transformers]) if @custom_transformers.length.positive?
# rng = ENV["CI"] ? Random.new(0) : Random.new
rng = Random.new(0)
rng = Random.new
set_output(
"args",
arguments.map do |a|
value = a.include?(" ") ? a.inspect : a
unless value.start_with?("--")
name = "variable_#{rng.rand(0..1000)}"
name = "variable_#{rng.rand(1000..9999)}"
set_environment(name, value)
value = "$#{name}"
end
+13 -5
View File
@@ -54,8 +54,8 @@ RSpec.describe Arguments do
let(:output) { ["--option", "value"] }
it "writes an output variable" do
expect(arguments).to receive(:set_output).with("args", "--option $variable_1")
expect(arguments).to receive(:set_environment).with("variable_684", "value")
expect(arguments).to receive(:set_output).with("args", /--option \$variable_\d{4}/)
expect(arguments).to receive(:set_environment).with(/variable_\d{4}/, "value")
subject
end
end
@@ -64,7 +64,8 @@ RSpec.describe Arguments do
let(:output) { ["--option", "some value"] }
it "writes an output variable" do
expect(arguments).to receive(:set_output).with("args", "--option \"some value\"")
expect(arguments).to receive(:set_output).with("args", /--option \$variable_\d{4}/)
expect(arguments).to receive(:set_environment).with(/variable_\d{4}/, "\"some value\"")
subject
end
end
@@ -74,7 +75,10 @@ RSpec.describe Arguments do
let(:options) { { "custom-transformers" => "transformers/**/*.rb" } }
it "writes an output variable" do
expect(arguments).to receive(:set_output).with("args", "--option value --custom-transformers transformers/**/*.rb")
expect(arguments).to receive(:set_output).with("args", /--option \$variable_\d{4} --custom-transformers \$variable_\d{4}/)
["value", "transformers/**/*.rb"].each do |value|
expect(arguments).to receive(:set_environment).with(/variable_\d{4}/, value)
end
subject
end
end
@@ -88,7 +92,11 @@ RSpec.describe Arguments do
end
it "writes an output variable" do
expect(arguments).to receive(:set_output).with("args", "--option value --custom-transformers transformers/jenkins/transformers.rb transformers/all.rb")
expect(arguments).to receive(:set_output).with("args", /--option \$variable_\d{4} --custom-transformers \$variable_\d{4} \$variable_\d{4}/)
["value", *files].each do |value|
expect(arguments).to receive(:set_environment).with(/variable_\d{4}/, value)
end
subject
end
end