-
Notifications
You must be signed in to change notification settings - Fork 10
/
bundler_setup_in_tests_spec.rb
53 lines (43 loc) · 1.46 KB
/
bundler_setup_in_tests_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# frozen_string_literal: true
RSpec.describe RuboCop::Cop::Packaging::BundlerSetupInTests, :config do
let(:message) { RuboCop::Cop::Packaging::BundlerSetupInTests::MSG }
let(:project_root) { RuboCop::ConfigLoader.project_root }
context "when `require bundler/setup` is used in specs/" do
let(:filename) { "#{project_root}/spec/spec_helper.rb" }
let(:source) { "require 'bundler/setup'" }
it "registers an offense" do
expect_offense(<<~RUBY, filename)
#{source}
#{"^" * source.length} #{message}
RUBY
end
end
context "when `require bundler/setup` is used in test/foo" do
let(:filename) { "#{project_root}/tests/foo/test_bar.rb" }
let(:source) { "require 'bundler/setup'" }
it "registers an offense" do
expect_offense(<<~RUBY, filename)
#{source}
#{"^" * source.length} #{message}
RUBY
end
end
context "when `require bundler/setup` is used in a Rakefile" do
let(:filename) { "#{project_root}/Rakefile" }
let(:source) { "require 'bundler/setup'" }
it "does not register an offense" do
expect_no_offenses(<<~RUBY, filename)
#{source}
RUBY
end
end
context "when `require bundler/setup` is used in bin/console" do
let(:filename) { "#{project_root}/bin/console" }
let(:source) { "require 'bundler/setup'" }
it "does not register an offense" do
expect_no_offenses(<<~RUBY, filename)
#{source}
RUBY
end
end
end