2016-12-05 8 views
0

InSpec으로 테스트를 만들고 있습니다. 그것은 아파치에 대한 나의 시험이다 :InSpec으로 컨텍스트를 만드는 방법은 무엇입니까?

require 'inspec' 

if os[:family] == 'redhat' 

    describe package 'httpd' do 
    it { should be_installed } 
    end 

    describe service 'httpd' do 
    it { should be_enabled } 
    it { should be_running } 
    end 

    describe file '/etc/httpd/conf/httpd.conf' do 
    it { should be_file } 
    end 
end 
describe port(80) do 
    it { should_not be_listening } 
end 

describe port(9000) do 
    it { should be_listening } 
end 

내 질문은 문맥과 관련있다. InSpec을 사용하기 전에 ChefSpec을 사용했고 컨텍스트를 만드는 방법과 출력이 컨텍스트를 표시하는 방법을 좋아합니다. 출력 위의 예를 들어 이것이다 :

System Package 
    ✔ httpd should be installed 
    Service httpd 
    ✔ should be enabled 
    ✔ should be running 
    File /etc/httpd/conf/httpd.conf 
    ✔ should be file 
    Port 80 
    ✔ should not be listening 
    Port 9000 
    ✔ should be listening 

내가 알고 내 테스트에 대한보다 명확한 결과를 얻기 위해 출력에 가족의 맛 또는 버전 또는 아치를 포함 할 것입니다.

의견이 있으십니까?

+1

나는 당신이'control'을 찾고 있다고 생각한다. [documentation] (http://inspec.io/docs/reference/dsl_inspec/)를 보라. – Tensibai

답변

3

먼저 ChefSpec과 InSpec이 완전히 다른 작업을 수행하므로이 둘은 실제로 비교할 수 있습니다. 둘째로, InSpec은 어느 수준의 RSpec 구문 호환성을 지원하지만, 전체 RSpec 도우미 라이브러리 인 ChefSpec 또는 ServerSpec만큼 완벽하지는 않습니다. @Tensibai가 언급했듯이 InSpec은 custom syntax for more complex tests을 제공합니다. RSpec describecontext 블록 시스템 또는 사용자 지정 RSpec 포맷터를 사용하려면 ServerSpec 대신 사용하는 것이 좋습니다.

관련 문제