control and lib eval unit tests

Signed-off-by: Jeremy J. Miller <jm@chef.io>
This commit is contained in:
Jeremy J. Miller 2016-12-16 23:42:07 -05:00
parent f7b39d79d7
commit 72b0c0dd2e
2 changed files with 6 additions and 6 deletions

View file

@ -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