Sha256: 410861d3fff7cf951868c2922cb8b4754e54a79c968a5d075b6de2041535d250

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

require_relative '../../test_helper'
require 'rubocop/git/runner'

describe RuboCop::Git::Runner do
  it 'exit with violations' do
    options = RuboCop::Git::Options.new
    options.commits = ["v0.0.4", "v0.0.5"]
    _ do
      capture_io do
        RuboCop::Git::Runner.new.run(options)
      end
    end.must_raise(SystemExit)
  end

  it 'enables cops passed via --only flag' do
    options = RuboCop::Git::Options.new
    options.commits = ["v0.0.0"]
    out, _err = capture_io do
      res = RuboCop::Git::Runner.new(exit_on_offence: false).run(options)
      res.must_equal(false)
    end
    _(out).must_match('Style/MutableConstant')
    _(out).wont_match('Style/FrozenStringLiteralComment')
    _(out).wont_match('bad_ruby.txt') # check that default `Include:` applies

    options.rubocop[:only] = ['Style/FrozenStringLiteralComment']
    out, _err = capture_io do
      res = RuboCop::Git::Runner.new(exit_on_offence: false).run(options)
      res.must_equal(false)
    end
    _(out).wont_match('Style/MutableConstant')
    _(out).must_match('Style/FrozenStringLiteralComment')
    _(out).must_match('Rakefile') # check that default `Include:` applies
  end

  it 'fail with no options' do
    _ do
      _out, _err = capture_io do
        RuboCop::Git::Runner.new.run({})
      end
    end.must_raise(RuboCop::Git::Options::Invalid)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-git2-0.1.4 test/rubocop/git/runner_test.rb