mock/stub -> double

This commit is contained in:
Fabio Rehm 2013-07-13 13:41:39 -03:00
parent c14ca57d17
commit 09208a0d28
5 changed files with 14 additions and 14 deletions

View file

@ -3,9 +3,9 @@ require 'unit_helper'
require 'vagrant-lxc/action/clear_forwarded_ports' require 'vagrant-lxc/action/clear_forwarded_ports'
describe Vagrant::LXC::Action::ClearForwardedPorts do describe Vagrant::LXC::Action::ClearForwardedPorts do
let(:app) { mock(:app, call: true) } let(:app) { double(:app, call: true) }
let(:env) { {machine: machine, ui: stub(info: true)} } let(:env) { {machine: machine, ui: double(info: true)} }
let(:machine) { mock(:machine, data_dir: data_dir) } let(:machine) { double(:machine, data_dir: data_dir) }
let!(:data_dir) { Pathname.new(Dir.mktmpdir) } let!(:data_dir) { Pathname.new(Dir.mktmpdir) }
let(:pids_dir) { data_dir.join('pids') } let(:pids_dir) { data_dir.join('pids') }
let(:pid) { 'a-pid' } let(:pid) { 'a-pid' }

View file

@ -3,8 +3,8 @@ require 'unit_helper'
require 'vagrant-lxc/action/compress_rootfs' require 'vagrant-lxc/action/compress_rootfs'
describe Vagrant::LXC::Action::CompressRootFS do describe Vagrant::LXC::Action::CompressRootFS do
let(:app) { mock(:app, call: true) } let(:app) { double(:app, call: true) }
let(:env) { {machine: machine, ui: stub(info: true)} } let(:env) { {machine: machine, ui: double(info: true)} }
let(:machine) { instance_double('Vagrant::Machine', provider: provider) } let(:machine) { instance_double('Vagrant::Machine', provider: provider) }
let(:provider) { instance_double('Vagrant::LXC::Provider', driver: driver) } let(:provider) { instance_double('Vagrant::LXC::Provider', driver: driver) }
let(:driver) { instance_double('Vagrant::LXC::Driver', compress_rootfs: compressed_rootfs_path) } let(:driver) { instance_double('Vagrant::LXC::Driver', compress_rootfs: compressed_rootfs_path) }

View file

@ -3,9 +3,9 @@ require 'unit_helper'
require 'vagrant-lxc/action/forward_ports' require 'vagrant-lxc/action/forward_ports'
describe Vagrant::LXC::Action::ForwardPorts do describe Vagrant::LXC::Action::ForwardPorts do
let(:app) { mock(:app, call: true) } let(:app) { double(:app, call: true) }
let(:env) { {machine: machine, ui: stub(info: true)} } let(:env) { {machine: machine, ui: double(info: true)} }
let(:machine) { mock(:machine) } let(:machine) { double(:machine) }
let!(:data_dir) { Pathname.new(Dir.mktmpdir) } let!(:data_dir) { Pathname.new(Dir.mktmpdir) }
let(:networks) { [[:other_config, {}], [:forwarded_port, {guest: guest_port, host: host_port}]] } let(:networks) { [[:other_config, {}], [:forwarded_port, {guest: guest_port, host: host_port}]] }
let(:host_port) { 8080 } let(:host_port) { 8080 }

View file

@ -5,10 +5,10 @@ require 'vagrant-lxc/errors'
require 'vagrant-lxc/action/handle_box_metadata' require 'vagrant-lxc/action/handle_box_metadata'
describe Vagrant::LXC::Action::HandleBoxMetadata do describe Vagrant::LXC::Action::HandleBoxMetadata do
let(:app) { mock(:app, call: true) } let(:app) { double(:app, call: true) }
let(:env) { {machine: machine, ui: stub(info: true)} } let(:env) { {machine: machine, ui: double(info: true)} }
let(:machine) { mock(:machine, box: box) } let(:machine) { double(:machine, box: box) }
let(:box) { mock(:box, name: 'box-name', metadata: metadata, directory: box_directory) } let(:box) { double(:box, name: 'box-name', metadata: metadata, directory: box_directory) }
let(:box_directory) { Pathname.new('/path/to/box') } let(:box_directory) { Pathname.new('/path/to/box') }
let(:version) { '2' } let(:version) { '2' }
let(:metadata) { {'template-opts' => {'--foo' => 'bar'}, 'version' => version} } let(:metadata) { {'template-opts' => {'--foo' => 'bar'}, 'version' => version} }

View file

@ -3,8 +3,8 @@ require 'unit_helper'
require 'vagrant-lxc/action/setup_package_files' require 'vagrant-lxc/action/setup_package_files'
describe Vagrant::LXC::Action::SetupPackageFiles do describe Vagrant::LXC::Action::SetupPackageFiles do
let(:app) { mock(:app, call: true) } let(:app) { double(:app, call: true) }
let(:env) { {machine: machine, tmp_path: tmp_path, ui: stub(info: true), 'package.rootfs' => rootfs_path} } let(:env) { {machine: machine, tmp_path: tmp_path, ui: double(info: true), 'package.rootfs' => rootfs_path} }
let(:machine) { instance_double('Vagrant::Machine', box: box) } let(:machine) { instance_double('Vagrant::Machine', box: box) }
let!(:tmp_path) { Pathname.new(Dir.mktmpdir) } let!(:tmp_path) { Pathname.new(Dir.mktmpdir) }
let(:box) { instance_double('Vagrant::Box', directory: tmp_path.join('box')) } let(:box) { instance_double('Vagrant::Box', directory: tmp_path.join('box')) }