Sha256: 9a6d0785eb0d20a926282649af1a9394d01a087fb3f6bd2434475c102cc951cf

Contents?: true

Size: 1.76 KB

Versions: 22

Compression:

Stored size: 1.76 KB

Contents

require File.dirname(__FILE__) + '/test_helper'

class WinSystemTest < Test::Unit::TestCase
  include SproutTestCase

  context "new windows system" do

    setup do
      @user = Sprout::System::WinSystem.new
    end

    should "not accept home path with My Documents" do
      @user.stubs(:find_home).returns File.join('C:', 'foo', 'My Documents')
      assert_equal File.join('C:', 'foo'), @user.home
    end

    should "return env_path" do
      @user.stubs(:env_path).returns "a;b;c;"
      assert_equal ['a', 'b', 'c'], @user.get_paths
    end

    should "execute with correct implementation" do
      @echochamber = File.join fixtures, 'remote_file_target', 'bin', 'echochamber'
      # Don't actually call the win32 execute function:
      r = StringIO.new
      w = StringIO.new
      e = StringIO.new
      pid = nil
      Sprout::ProcessRunner.any_instance.expects(:io_popen_block).returns([pid, w, r, e])
      @user.stubs(:clean_path).returns @echochamber
      @user.execute @echochamber
    end

    context "with home already set" do

      setup do
        @user.stubs(:home).returns 'C:\Documents and Settings\Some System'
      end

      should "find library" do
        File.stubs(:exists?).returns true
        assert_matches /Local Settings\/Application Data/, @user.library
      end

      should "find library outside home" do
        File.stubs(:exists?).returns false
        assert "Shouldn't use app data if it doesn't exist", (@user.library =~ /Application Data/).nil?
      end

      should "wrap paths that have spaces with escaped quotes" do
        assert_equal "\"foo bar\"", @user.clean_path("foo bar")
      end

      should "not modify paths that have no spaced" do
        assert_equal "foobar", @user.clean_path("foobar")
      end
    end

  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
sprout-1.0.26.pre test/unit/win_system_test.rb
sprout-1.0.25.pre test/unit/win_system_test.rb
sprout-1.0.24.pre test/unit/win_system_test.rb
sprout-1.0.23.pre test/unit/win_system_test.rb
sprout-1.0.22.pre test/unit/win_system_test.rb
sprout-1.0.20.pre test/unit/win_system_test.rb
sprout-1.0.19.pre test/unit/win_system_test.rb
sprout-1.0.18.pre test/unit/win_system_test.rb
sprout-1.0.17.pre test/unit/win_system_test.rb
sprout-1.0.16.pre test/unit/win_system_test.rb
sprout-1.0.15.pre test/unit/win_system_test.rb
sprout-1.0.14.pre test/unit/win_system_test.rb
sprout-1.0.13.pre test/unit/win_system_test.rb
sprout-1.0.11.pre test/unit/win_system_test.rb
sprout-1.0.9.pre test/unit/win_system_test.rb
sprout-1.0.8.pre test/unit/win_system_test.rb
sprout-1.0.5.pre test/unit/win_system_test.rb
sprout-1.0.4.pre test/unit/win_system_test.rb
sprout-1.0.3.pre test/unit/win_system_test.rb
sprout-1.0.2.pre test/unit/win_system_test.rb