Sha256: 32058879dcf21f3480796181ced2c528d5612be8077a6f993551b45a3037fbb5

Contents?: true

Size: 1.34 KB

Versions: 2

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'

describe CodeClimate::TestReporter do

  describe '.run_on_current_branch?' do
    it 'returns true if there is no branch configured' do
      allow(CodeClimate::TestReporter).to receive(:configured_branch).and_return(nil)
      expect(CodeClimate::TestReporter.run_on_current_branch?).to be_true
    end

    it 'returns true if the current branch matches the configured branch' do
      allow(CodeClimate::TestReporter).to receive(:current_branch).and_return("master\n")
      allow(CodeClimate::TestReporter).to receive(:configured_branch).and_return(:master)

      expect(CodeClimate::TestReporter.run_on_current_branch?).to be_true
    end

    it 'returns false if the current branch and configured branch dont match' do
      allow(CodeClimate::TestReporter).to receive(:current_branch).and_return("some-branch")
      allow(CodeClimate::TestReporter).to receive(:configured_branch).and_return(:master)

      expect(CodeClimate::TestReporter.run_on_current_branch?).to be_false
    end

    it 'logs a message if false' do
      expect_any_instance_of(Logger).to receive(:info)
      allow(CodeClimate::TestReporter).to receive(:current_branch).and_return("another-branch")
      allow(CodeClimate::TestReporter).to receive(:configured_branch).and_return(:master)

      CodeClimate::TestReporter.run_on_current_branch?
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
codeclimate-test-reporter-0.3.0 spec/lib/test_reporter_spec.rb
codeclimate-test-reporter-0.2.0 spec/lib/test_reporter_spec.rb