Sha256: 092bfaf4bbb29225407f798957388426a97b0c06de800607e9652438bfed46d3

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'

module CodeClimate::TestReporter
  describe Git do
    describe '.info' do
      it 'returns a hash with git information.' do
        expected_git_hash = {
          head: `git log -1 --pretty=format:'%H'`,
          committed_at: `git log -1 --pretty=format:%ct`.to_i,
          branch: Git.send(:branch_from_git)
        }

        expect(Git.info).to include expected_git_hash
      end
    end

    describe 'branch_from_git_or_ci' do
      it 'returns the branch from ci' do
        allow(Ci).to receive(:service_data).and_return({branch: 'ci-branch'})

        expect(Git.branch_from_git_or_ci).to eq 'ci-branch'
      end

      it 'returns the branch from git if there is no ci branch' do
        allow(Ci).to receive(:service_data).and_return({})

        expect(Git.branch_from_git_or_ci).to eq Git.clean_git_branch
      end

      it 'returns master otherwise' do
        allow(Ci).to receive(:service_data).and_return({})
        allow(Git).to receive(:branch_from_git).and_return(nil)

        expect(Git.branch_from_git_or_ci).to eq 'master'
      end
    end

  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
construi-0.6.0 vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.4.6/spec/lib/git_spec.rb
construi-0.5.0 vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.4.6/spec/lib/git_spec.rb
construi-0.4.0 vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.4.6/spec/lib/git_spec.rb
construi-0.2.0 vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.4.6/spec/lib/git_spec.rb
construi-0.1.0 vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.4.6/spec/lib/git_spec.rb
codeclimate-test-reporter-0.4.6 spec/lib/git_spec.rb
codeclimate-test-reporter-0.4.5 spec/lib/git_spec.rb
codeclimate-test-reporter-0.4.4 spec/lib/git_spec.rb