From 4c1ac8d2c1fbb5fa3982303582c59d25aafabb1f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 19 Jun 2010 11:44:13 -0700 Subject: [PATCH] More SF tests passing... --- .../vagrant/actions/vm/shared_folders_test.rb | 55 +++++++++++-------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/test/vagrant/actions/vm/shared_folders_test.rb b/test/vagrant/actions/vm/shared_folders_test.rb index dfe50c1b5..16ec88f03 100644 --- a/test/vagrant/actions/vm/shared_folders_test.rb +++ b/test/vagrant/actions/vm/shared_folders_test.rb @@ -7,9 +7,20 @@ class SharedFoldersActionTest < Test::Unit::TestCase end def stub_shared_folders - folders = [%w{foo from to}, %w{bar bfrom bto}] - @action.expects(:shared_folders).returns(folders) - folders + env = mock_environment do |config| + config.vm.shared_folders.clear + + if block_given? + yield config + else + folders = [%w{foo fooguest foohost}, %w{bar barguest barhost}] + folders.each do |data| + config.vm.share_folder(*data) + end + end + end + + @runner.stubs(:env).returns(env) end context "before boot" do @@ -32,7 +43,7 @@ class SharedFoldersActionTest < Test::Unit::TestCase "bar" => %W[foo baz] } - mock_env do |config| + stub_shared_folders do |config| data.each do |name, value| config.vm.share_folder(name, *value) end @@ -52,7 +63,7 @@ class SharedFoldersActionTest < Test::Unit::TestCase guest = "bar" host = "baz" - mock_env do |config| + stub_shared_folders do |config| config.vm.share_folder(name, guest, host, :sync => true) end @@ -60,15 +71,6 @@ class SharedFoldersActionTest < Test::Unit::TestCase assert_equal "#{guest}#{@runner.env.config.unison.folder_suffix}", result[name][:guestpath] assert_equal guest, result[name][:original][:guestpath] end - - def mock_env - env = mock_environment do |config| - config.vm.shared_folders.clear - yield config - end - - @runner.expects(:env).returns(env) - end end context "clearing shared folders" do @@ -97,19 +99,24 @@ class SharedFoldersActionTest < Test::Unit::TestCase context "setting up shared folder metadata" do setup do - @folders = stub_shared_folders + stub_shared_folders end - # should "add all shared folders to the VM" do - # share_seq = sequence("share_seq") - # shared_folders = mock("shared_folders") - # shared_folders.expects(:<<).in_sequence(share_seq).with() { |sf| sf.name == "foo" && sf.host_path == "from" } - # shared_folders.expects(:<<).in_sequence(share_seq).with() { |sf| sf.name == "bar" && sf.host_path == "bfrom" } - # @vm.stubs(:shared_folders).returns(shared_folders) - # @vm.expects(:save).once + should "add all shared folders to the VM" do + shared_folders = [] + data = %W[foo bar] + shared_folders.expects(:<<).times(data.length).with() do |sf| + hostpath = File.expand_path("#{sf.name}host", @runner.env.root_path) + assert data.include?(sf.name) + assert_equal hostpath, sf.host_path + true + end - # @action.create_metadata - # end + @vm.stubs(:shared_folders).returns(shared_folders) + @vm.expects(:save).once + + @action.create_metadata + end end # context "mounting the shared folders" do