Sha256: 00b066c5290e872bf25e32234530e7e989d89c13cd13ff99401d1c354c93af50

Contents?: true

Size: 1.74 KB

Versions: 13

Compression:

Stored size: 1.74 KB

Contents

require 'test_helper'

class WinSystemTest < Test::Unit::TestCase
  include Sprout::TestHelper

  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 (@user.library =~ /Application Data/).nil?, "Shouldn't use app data if it doesn't exist" 
      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

13 entries across 13 versions & 1 rubygems

Version Path
sprout-1.1.18.pre test/unit/win_system_test.rb
sprout-1.1.17.pre test/unit/win_system_test.rb
sprout-1.1.16.pre test/unit/win_system_test.rb
sprout-1.1.15.pre test/unit/win_system_test.rb
sprout-1.1.14.pre test/unit/win_system_test.rb
sprout-1.1.13.pre test/unit/win_system_test.rb
sprout-1.1.11.pre test/unit/win_system_test.rb
sprout-1.1.10.pre test/unit/win_system_test.rb
sprout-1.1.7.pre test/unit/win_system_test.rb
sprout-1.1.5.pre test/unit/win_system_test.rb
sprout-1.1.4.pre test/unit/win_system_test.rb
sprout-1.1.3.pre test/unit/win_system_test.rb
sprout-1.1.2.pre test/unit/win_system_test.rb