mirror of
https://github.com/inspec/inspec
synced 2024-11-10 23:24:18 +00:00
Merge pull request #1717 from chef/dr/prettyprint-inspec-backend
print and prettyprint the inspec backend class
This commit is contained in:
commit
bf1d2ded6d
2 changed files with 37 additions and 0 deletions
|
@ -26,9 +26,20 @@ module Inspec
|
|||
end
|
||||
|
||||
cls = Class.new do
|
||||
# Ruby internal for printing a nice name for this class
|
||||
def to_s
|
||||
'Inspec::Backend::Class'
|
||||
end
|
||||
|
||||
# Ruby internal for pretty-printing a summary for this class
|
||||
def inspect
|
||||
"Inspec::Backend::Class @transport=#{backend.class}"
|
||||
end
|
||||
|
||||
define_method :backend do
|
||||
connection
|
||||
end
|
||||
|
||||
Inspec::Resource.registry.each do |id, r|
|
||||
define_method id.to_sym do |*args|
|
||||
r.new(self, id.to_s, *args)
|
||||
|
|
26
test/unit/dsl/other_keywords_test.rb
Normal file
26
test/unit/dsl/other_keywords_test.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
# encoding: utf-8
|
||||
# author: Dominik Richter
|
||||
# author: Christoph Hartmann
|
||||
|
||||
require 'helper'
|
||||
|
||||
describe 'inspec keyword' do
|
||||
def load(content)
|
||||
runner = Inspec::Runner.new({backend: 'mock'})
|
||||
res = runner.eval_with_virtual_profile(content)
|
||||
end
|
||||
|
||||
it 'is associated with resources' do
|
||||
i = load('os.inspec')
|
||||
i.wont_be_nil
|
||||
i.backend.must_be_kind_of Train::Transports::Mock::Connection
|
||||
end
|
||||
|
||||
it 'prints a nice to_s' do
|
||||
load('os.inspec').to_s.must_equal 'Inspec::Backend::Class'
|
||||
end
|
||||
|
||||
it 'prints a nice inspect line' do
|
||||
load('os.inspec').inspect.must_equal 'Inspec::Backend::Class @transport=Train::Transports::Mock::Connection'
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue