mirror of
https://github.com/inspec/inspec
synced 2025-02-17 06:28:40 +00:00
Merge pull request #1373 from jeremymv2/jeremymv2/add_profile_unit_tests
control and lib_eval_context unit tests
This commit is contained in:
commit
32ace063e8
2 changed files with 6 additions and 6 deletions
|
@ -53,11 +53,12 @@ EOF
|
|||
end
|
||||
end
|
||||
|
||||
describe "#resource" do
|
||||
describe "#resource_class" do
|
||||
let(:resource_dsl) { Inspec::Resource.create_dsl(profile_context) }
|
||||
let(:inner_context) { Inspec::ProfileContext.new('inner-context', backend, {}) }
|
||||
let(:newfoo) { mock() }
|
||||
let(:control_content) do <<EOF
|
||||
resource('profile_a', 'foobar')
|
||||
resource_class('profile_a', 'foobar')
|
||||
EOF
|
||||
end
|
||||
|
||||
|
@ -68,10 +69,9 @@ EOF
|
|||
end
|
||||
|
||||
it "returns the resource from a subcontext" do
|
||||
profile_context.expects(:subcontext_by_name).with('profile_a').returns(inner_context)
|
||||
inner_context.expects(:resource_registry).returns({'foobar' => mock(:new => 'newfoo')})
|
||||
eval_context.instance_eval(control_content).must_equal "newfoo"
|
||||
profile_context.expects(:subcontext_by_name).at_most_once.with('profile_a').returns(inner_context)
|
||||
inner_context.expects(:resource_registry).returns({ 'foobar' => newfoo })
|
||||
eval_context.instance_eval(control_content).must_equal newfoo
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue