Sha256: 3a9e81c01248771e2f31ba6bc1d958d1632a1970cd5546c580c8631a55f7090c

Contents?: true

Size: 964 Bytes

Versions: 7

Compression:

Stored size: 964 Bytes

Contents

# frozen_string_literal: true

require 'eac_git/local'
require 'eac_git/rspec/stubbed_git_local_repo/directory'
require 'eac_git/rspec/stubbed_git_local_repo/file'
require 'eac_ruby_utils/core_ext'
require 'securerandom'

module EacGit
  module Rspec
    module StubbedGitLocalRepo
      class Repository < ::EacGit::Local
        # @return [EacGit::Rspec::StubbedGitLocalRepo::Directory]
        def directory(*subpath)
          ::EacGit::Rspec::StubbedGitLocalRepo::Directory.new(self, subpath)
        end

        def file(*subpath)
          ::EacGit::Rspec::StubbedGitLocalRepo::File.new(self, subpath)
        end

        # @return [EacGit::Local::Commit
        def random_commit
          content = ::SecureRandom.hex
          file = "#{content}.txt"
          file(file).write(content)
          command('add', file).execute!
          command('commit', '-m', "Random commit: #{file}.").execute!
          head
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
eac_tools-0.86.5 sub/eac_git/lib/eac_git/rspec/stubbed_git_local_repo/repository.rb
eac_tools-0.86.4 sub/eac_git/lib/eac_git/rspec/stubbed_git_local_repo/repository.rb
eac_tools-0.86.3 sub/eac_git/lib/eac_git/rspec/stubbed_git_local_repo/repository.rb
eac_git-0.16.0 lib/eac_git/rspec/stubbed_git_local_repo/repository.rb
eac_tools-0.86.2 sub/eac_git/lib/eac_git/rspec/stubbed_git_local_repo/repository.rb
eac_git-0.15.0 lib/eac_git/rspec/stubbed_git_local_repo/repository.rb
eac_tools-0.84.2 sub/eac_git/lib/eac_git/rspec/stubbed_git_local_repo/repository.rb