Sha256: 783dc4736082474dd1fbcbb8ee2941250c7b072e61f473fbd4241b12fe6f7b79

Contents?: true

Size: 1.29 KB

Versions: 6

Compression:

Stored size: 1.29 KB

Contents

require_relative "../../../base"
require_relative "../../../../../plugins/commands/validate/command"

describe VagrantPlugins::CommandValidate::Command do
  include_context "unit"
  include_context "command plugin helpers"

  let(:iso_env) do
    isolated_environment
  end

  let(:env) do
    iso_env.create_vagrant_env
  end

  let(:argv)   { [] }

  before(:all) do
    I18n.load_path << Vagrant.source_root.join("plugins/commands/port/locales/en.yml")
    I18n.reload!
  end

  subject { described_class.new(argv, env) }

  describe "#execute" do
    it "validates correct Vagrantfile" do
      iso_env.vagrantfile(<<-EOH)
        Vagrant.configure("2") do |config|
          config.vm.box = "hashicorp/precise64"
        end
      EOH

      expect(env.ui).to receive(:info).with { |message, _|
        expect(message).to include("Vagrantfile validated successfully.")
      }

      expect(subject.execute).to eq(0)
    end

    it "validates the configuration" do
      iso_env.vagrantfile <<-EOH
        Vagrant.configure("2") do |config|
          config.vm.bix = "hashicorp/precise64"
        end
      EOH

      expect { subject.execute }.to raise_error(Vagrant::Errors::ConfigInvalid) { |err|
        expect(err.message).to include("The following settings shouldn't exist: bix")
      }
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
vagrant-unbundled-1.9.7.1 test/unit/plugins/commands/validate/command_test.rb
vagrant-aws-mkubenka-0.7.2.pre.14 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/plugins/commands/validate/command_test.rb
vagrant-aws-mkubenka-0.7.2.pre.11 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/plugins/commands/validate/command_test.rb
vagrant-aws-mkubenka-0.7.2.pre.10 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/plugins/commands/validate/command_test.rb
vagrant-aws-mkubenka-0.7.2.pre.9 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/plugins/commands/validate/command_test.rb
vagrant-unbundled-1.9.5.1 test/unit/plugins/commands/validate/command_test.rb