Ubuntu 16.04 Docker イメージの基本的なテストを作成しようとしています。私のテスト環境もUbuntu 16.04で、ruby-serverspec
パッケージをインストールしました。
require "serverspec"
require "docker_image"
describe "Dockerfile" do
before(:all) do
image = Docker::Image.build_from_dir('..')
set :os, family: :debian
set :backend, :docker
set :docker_image, image.id
end
it "installs the right version of Ubuntu" do
expect(os_version).to include("Ubuntu 14")
end
def os_version
command("lsb_release -a").stdout
end
end
これは、Ubuntu 14 をチェックするため、現時点では意図的に失敗したテストですが、失敗には至っていません。
$ rspec /test/spec/localhost/my_spec.rb
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- docker_image (LoadError)
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /test/spec/localhost/my_spec.rb:4:in `<top (required)>'
from /usr/lib/ruby/vendor_ruby/rspec/core/configuration.rb:1361:in `load'
from /usr/lib/ruby/vendor_ruby/rspec/core/configuration.rb:1361:in `block in load_spec_files'
from /usr/lib/ruby/vendor_ruby/rspec/core/configuration.rb:1359:in `each'
from /usr/lib/ruby/vendor_ruby/rspec/core/configuration.rb:1359:in `load_spec_files'
from /usr/lib/ruby/vendor_ruby/rspec/core/runner.rb:106:in `setup'
from /usr/lib/ruby/vendor_ruby/rspec/core/runner.rb:92:in `run'
from /usr/lib/ruby/vendor_ruby/rspec/core/runner.rb:78:in `run'
from /usr/lib/ruby/vendor_ruby/rspec/core/runner.rb:45:in `invoke'
from /usr/bin/rspec:4:in `<main>'
Docker::Image
クラス モジュールを正しく要求する方法がわかりません。検索パスは、私にとって依然として黒魔術です。このテストを期待どおりに失敗させるにはどうすればよいですか?