diff options
author | Robert Speicher <rspeicher@gmail.com> | 2017-02-08 16:22:36 -0500 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2017-02-09 12:11:19 -0500 |
commit | f57989c2ed15c5d84f198ca334686f5bf7207f8e (patch) | |
tree | dc3427e8017cc146b4e24d7784edbdb177f56c60 /spec/rubocop | |
parent | 75092d9647bab00070b0b77f0fe1050d900a39a1 (diff) | |
download | gitlab-ce-f57989c2ed15c5d84f198ca334686f5bf7207f8e.tar.gz |
Add a spec for our custom GemFetcher coprs-gemfetcher-cop-spec
Diffstat (limited to 'spec/rubocop')
-rw-r--r-- | spec/rubocop/cop/gem_fetcher_spec.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/rubocop/cop/gem_fetcher_spec.rb b/spec/rubocop/cop/gem_fetcher_spec.rb new file mode 100644 index 00000000000..c07f6a831dc --- /dev/null +++ b/spec/rubocop/cop/gem_fetcher_spec.rb @@ -0,0 +1,46 @@ +require 'spec_helper' + +require 'rubocop' +require 'rubocop/rspec/support' + +require_relative '../../../rubocop/cop/gem_fetcher' + +describe RuboCop::Cop::GemFetcher do + include CopHelper + + subject(:cop) { described_class.new } + + context 'in Gemfile' do + before do + allow(cop).to receive(:gemfile?).and_return(true) + end + + it 'registers an offense when a gem uses `git`' do + inspect_source(cop, 'gem "foo", git: "https://gitlab.com/foo/bar.git"') + + aggregate_failures do + expect(cop.offenses.size).to eq(1) + expect(cop.offenses.map(&:line)).to eq([1]) + expect(cop.highlights).to eq(['git: "https://gitlab.com/foo/bar.git"']) + end + end + + it 'registers an offense when a gem uses `github`' do + inspect_source(cop, 'gem "foo", github: "foo/bar.git"') + + aggregate_failures do + expect(cop.offenses.size).to eq(1) + expect(cop.offenses.map(&:line)).to eq([1]) + expect(cop.highlights).to eq(['github: "foo/bar.git"']) + end + end + end + + context 'outside of Gemfile' do + it 'registers no offense' do + inspect_source(cop, 'gem "foo", git: "https://gitlab.com/foo/bar.git"') + + expect(cop.offenses.size).to eq(0) + end + end +end |