mirror of
https://github.com/inspec/inspec
synced 2024-11-22 20:53:11 +00:00
Resource id attribute added for the resources in the base class
Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
This commit is contained in:
parent
f9914628dc
commit
8b8b4db2b2
2 changed files with 21 additions and 2 deletions
|
@ -34,6 +34,12 @@ module Inspec
|
|||
Inspec::Resource.support_registry[key].push(criteria)
|
||||
end
|
||||
|
||||
def self.resource_id(value = nil)
|
||||
return (find_class_instance_variable(:@resource_id) || "") unless value
|
||||
|
||||
@resource_id = value
|
||||
end
|
||||
|
||||
# TODO: this is pretty terrible and is only here to work around
|
||||
# the idea that we've trained resource authors to make initialize
|
||||
# methods w/o calling super.
|
||||
|
|
|
@ -44,12 +44,12 @@ describe Inspec::Resource do
|
|||
end
|
||||
|
||||
describe "#example" do
|
||||
it "will register a description" do
|
||||
it "will register a example" do
|
||||
expected = rand.to_s
|
||||
_(create { example expected }.example).must_equal expected
|
||||
end
|
||||
|
||||
it "can change the description" do
|
||||
it "can change the example" do
|
||||
c = create { example rand.to_s }
|
||||
c.example(x = rand.to_s)
|
||||
_(c.example).must_equal x
|
||||
|
@ -94,4 +94,17 @@ describe Inspec::Resource do
|
|||
Inspec::Resource.support_registry["os"] = nil
|
||||
end
|
||||
end
|
||||
|
||||
describe "resource_id" do
|
||||
it "will register a resource_id" do
|
||||
expected = rand.to_s
|
||||
_(create { resource_id expected }.resource_id).must_equal expected
|
||||
end
|
||||
|
||||
it "can change the resource_id" do
|
||||
c = create { resource_id rand.to_s }
|
||||
c.resource_id(x = rand.to_s)
|
||||
_(c.resource_id).must_equal x
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue