Sha256: 70f5149574ef82ef1c752a31d7fc081678a138679d7c5b445f293ce582bfef26

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require 'git_shizzle'

describe 'Track files by index' do

  let(:git) { GitShizzle::Git::Git.new(repo) }
  subject { GitShizzle::QuickGit.new(git) }

  before do
    allow($stdout).to receive(:puts)
  end

  describe 'repository with untracked files' do
    before do
      create 'untracked-1'
      create 'untracked-2'

      expect(git.status[0].work_tree_status).to eq(:untracked)
      expect(git.status[1].work_tree_status).to eq(:untracked)
    end

    context 'when a single file is tracked' do
      it 'should run git add for the file' do
        subject.track 1

        expect(git.status[0].index_status).to eq(:added)
        expect(git.status[1].index_status).to eq(:untracked)
      end
    end

    context 'when multiple files are tracked' do
      it 'should run git add for all specified files' do
        subject.track 1, 2

        git.status.each { |entry| expect(entry.index_status).to eq(:added) }
      end
    end
  end

  describe 'repository without untracked files' do
    it 'should fail' do
      expect { subject.track 1 }.to raise_error
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
git_shizzle-0.2.8 spec/git_shizzle/builtin_commands/track_spec.rb