Files
ubicloud/spec/model/resource_methods_spec.rb
Jeremy Evans c7d6d38bff Include ubid in Model#inspect for models using ResourceMethods
If the ubid is available for the object, this includes the ubid
in the #inspect format like this:

  #<PrivateSubnet["$UBID"]

With the previous commit to allow providing ubid as argument
to Model.[], in the repl, you can easily copy and paste the
section of the inspect output to get the related object returned.
2024-10-24 08:47:49 -07:00

25 lines
819 B
Ruby

# frozen_string_literal: true
require_relative "spec_helper"
RSpec.describe ResourceMethods do
it "#inspect hides sensitive and long columns" do
[GithubRunner, PostgresResource, Vm, VmHost, MinioCluster, MinioServer, Cert].each do |klass|
inspect_output = klass.new.inspect
klass.redacted_columns.each do |column_key|
expect(inspect_output).not_to include column_key.to_s
end
end
end
it "#inspect includes ubid only if available" do
[GithubRunner, PostgresResource, Vm, VmHost, MinioCluster, MinioServer, Cert].each do |klass|
ubid = klass.generate_ubid
obj = klass.new
expect(obj.inspect).to start_with "#<#{klass} @values={"
obj.id = ubid.to_uuid.to_s
expect(obj.inspect).to start_with "#<#{klass}[\"#{ubid}\"] @values={"
end
end
end