Sha256: 70668027ee84f4d7430d6bc5a3cbb247a3de84992aa8959d4d7db24b834377e6

Contents?: true

Size: 1.7 KB

Versions: 96

Compression:

Stored size: 1.7 KB

Contents

# ********** Copyright Viacom, Inc. Apache 2.0 **********

require_relative "test_helper.rb"

class GitTest < Minitest::Test

  def test_stashes_pop
    base = Minitest::Mock.new
    lib = Minitest::Mock.new

    index = 1
    base.expect(:lib, lib)
    lib.expect(:stash_pop, nil, [index])

    Dir.mktmpdir do |dir|
      git = Git.init(File.join(dir, "git"))
      stashes = git.branch.stashes
      stashes.instance_variable_set(:@base, base)
      stashes.pop(index)
    end

    base.verify
    lib.verify
  end

  def test_stashes_drop
    base = Minitest::Mock.new
    lib = Minitest::Mock.new

    index = 1
    base.expect(:lib, lib)
    lib.expect(:stash_drop, nil, [index])

    Dir.mktmpdir do |dir|
      git = Git.init(File.join(dir, "git"))
      stashes = git.branch.stashes
      stashes.instance_variable_set(:@base, base)
      stashes.drop(index)
    end

    base.verify
    lib.verify
  end

  def test_lib_pop
    lib = Git::Lib.new
    command = lambda{|command_sent|
      assert_equal "stash pop", command_sent
    }
    lib.stub(:command, command) do
      lib.stash_pop
    end

    lib = Git::Lib.new
    command = lambda{|command_sent, args|
      assert_equal "stash pop", command_sent
      assert_equal [1], args
    }
    lib.stub(:command, command) do
      lib.stash_pop(1)
    end
  end

  def test_lib_drop
    lib = Git::Lib.new
    command = lambda{|command_sent|
      assert_equal "stash drop", command_sent
    }
    lib.stub(:command, command) do
      lib.stash_drop
    end

    lib = Git::Lib.new
    command = lambda{|command_sent, args|
      assert_equal "stash drop", command_sent
      assert_equal [1], args
    }
    lib.stub(:command, command) do
      lib.stash_drop(1)
    end
  end
end

Version data entries

96 entries across 96 versions & 1 rubygems

Version Path
roku_builder-4.28.0 test/roku_builder/test_ruby_git.rb
roku_builder-4.27.2 test/roku_builder/test_ruby_git.rb
roku_builder-4.27.1 test/roku_builder/test_ruby_git.rb
roku_builder-4.27.0 test/roku_builder/test_ruby_git.rb
roku_builder-4.26.2 test/roku_builder/test_ruby_git.rb
roku_builder-4.26.1 test/roku_builder/test_ruby_git.rb
roku_builder-4.26.0 test/roku_builder/test_ruby_git.rb
roku_builder-4.25.6 test/roku_builder/test_ruby_git.rb
roku_builder-4.25.5 test/roku_builder/test_ruby_git.rb
roku_builder-4.25.4 test/roku_builder/test_ruby_git.rb
roku_builder-4.25.3 test/roku_builder/test_ruby_git.rb
roku_builder-4.25.1 test/roku_builder/test_ruby_git.rb
roku_builder-4.25.0 test/roku_builder/test_ruby_git.rb
roku_builder-4.24.3 test/roku_builder/test_ruby_git.rb
roku_builder-4.24.1 test/roku_builder/test_ruby_git.rb
roku_builder-4.24.0 test/roku_builder/test_ruby_git.rb
roku_builder-4.23.2 test/roku_builder/test_ruby_git.rb
roku_builder-4.23.1 test/roku_builder/test_ruby_git.rb
roku_builder-4.23.0 test/roku_builder/test_ruby_git.rb
roku_builder-4.22.9 test/roku_builder/test_ruby_git.rb