mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
rubocop
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
require "ostruct"
|
||||
require "pathname"
|
||||
require 'ostruct'
|
||||
require 'pathname'
|
||||
|
||||
class EnvironmentHelper
|
||||
|
||||
attr_writer :domain_name
|
||||
|
||||
attr_accessor :random_hostname, :name, :default_prefix
|
||||
|
||||
def [](value)
|
||||
self.send(value.to_sym)
|
||||
send(value.to_sym)
|
||||
end
|
||||
|
||||
def cpus
|
||||
@@ -34,15 +33,14 @@ class EnvironmentHelper
|
||||
end
|
||||
|
||||
def root_path
|
||||
Pathname.new("./spec/support/foo")
|
||||
Pathname.new('./spec/support/foo')
|
||||
end
|
||||
|
||||
def domain_name
|
||||
#noop
|
||||
# noop
|
||||
end
|
||||
|
||||
def libvirt_compute
|
||||
OpenStruct.new(servers: [])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
require 'fog/libvirt'
|
||||
|
||||
shared_context "libvirt" do
|
||||
include_context "unit"
|
||||
shared_context 'libvirt' do
|
||||
include_context 'unit'
|
||||
|
||||
let(:libvirt_context) { true }
|
||||
let(:id) { "dummy-vagrant_dummy" }
|
||||
let(:connection) { double("connection") }
|
||||
let(:domain) { double("domain") }
|
||||
let(:id) { 'dummy-vagrant_dummy' }
|
||||
let(:connection) { double('connection') }
|
||||
let(:domain) { double('domain') }
|
||||
|
||||
def connection_result(options={})
|
||||
def connection_result(options = {})
|
||||
result = options.fetch(:result, nil)
|
||||
double("connection_result" => result)
|
||||
double('connection_result' => result)
|
||||
end
|
||||
|
||||
before (:each) do
|
||||
# we don't want unit tests to ever run commands on the system; so we wire
|
||||
# in a double to ensure any unexpected messages raise exceptions
|
||||
stub_const("::Fog::Compute", connection)
|
||||
stub_const('::Fog::Compute', connection)
|
||||
|
||||
# drivers also call vm_exists? during init;
|
||||
allow(connection).to receive(:servers).with(kind_of(String)).
|
||||
and_return(connection_result(result: nil))
|
||||
allow(connection).to receive(:servers).with(kind_of(String))
|
||||
.and_return(connection_result(result: nil))
|
||||
|
||||
# return some information for domain when needed
|
||||
allow(domain).to receive(:mac).and_return("9C:D5:53:F1:5A:E7")
|
||||
allow(domain).to receive(:mac).and_return('9C:D5:53:F1:5A:E7')
|
||||
|
||||
machine.stub(:id => id)
|
||||
machine.stub(id: id)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
require 'spec_helper'
|
||||
|
||||
shared_context "unit" do
|
||||
shared_context 'unit' do
|
||||
include_context 'vagrant-unit'
|
||||
|
||||
let(:vagrantfile) do <<-EOF
|
||||
let(:vagrantfile) do
|
||||
<<-EOF
|
||||
Vagrant.configure('2') do |config|
|
||||
config.vm.define :test
|
||||
end
|
||||
@@ -15,20 +16,19 @@ shared_context "unit" do
|
||||
test_env
|
||||
end
|
||||
let(:env) { { env: iso_env, machine: machine, ui: ui, root_path: '/rootpath' } }
|
||||
let(:conf) { Vagrant::Config::V2::DummyConfig.new() }
|
||||
let(:ui) { Vagrant::UI::Basic.new() }
|
||||
let(:conf) { Vagrant::Config::V2::DummyConfig.new }
|
||||
let(:ui) { Vagrant::UI::Basic.new }
|
||||
let(:iso_env) { test_env.create_vagrant_env ui_class: Vagrant::UI::Basic }
|
||||
let(:machine) { iso_env.machine(:test, :libvirt) }
|
||||
# Mock the communicator to prevent SSH commands for being executed.
|
||||
let(:communicator) { double('communicator') }
|
||||
# Mock the guest operating system.
|
||||
let(:guest) { double('guest') }
|
||||
let(:app) { lambda { |env| } }
|
||||
let(:plugin) { register_plugin() }
|
||||
let(:app) { ->(env) {} }
|
||||
let(:plugin) { register_plugin }
|
||||
|
||||
before (:each) do
|
||||
machine.stub(:guest => guest)
|
||||
machine.stub(:communicator => communicator)
|
||||
machine.stub(guest: guest)
|
||||
machine.stub(communicator: communicator)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user