2016-12-05 5 views
0

私はInSpecでテストを作成しています。それは私のApacheのテストです: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'を探していると思います[ドキュメント](http://inspec.io/docs/reference/dsl_inspec/)を参照してください。 – Tensibai

答えて

3

まず、ChefSpecとInSpecはまったく別物なので、2つは本当に匹敵します。第2に、InSpecはあるレベルのRSpec構文互換性をサポートしていますが、完全なRSpecヘルパーライブラリであるChefSpecまたはServerSpecとほぼ同じくらい完全ではありません。 @Tensibaiが述べたように、InSpecは独自のcustom syntax for more complex testsを提供しています。 RSpec describecontextブロックシステムまたはカスタムRSpecフォーマッタを使用する場合は、ServerSpecを代わりに使用することをお勧めします。

関連する問題