Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable RSpec Example cops #9811

Merged
merged 10 commits into from
Jun 5, 2024
20 changes: 0 additions & 20 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ RSpec/DescribedClass:
- 'updater/spec/dependabot/api_client_spec.rb'
- 'updater/spec/dependabot/job_spec.rb'

# Offense count: 173
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowConsecutiveOneLiners.
RSpec/EmptyLineAfterExample:
Enabled: false

# Offense count: 25
# This cop supports safe autocorrection (--autocorrect).
RSpec/EmptyLineAfterExampleGroup:
Expand Down Expand Up @@ -132,20 +126,6 @@ RSpec/EmptyLineAfterSubject:
RSpec/ExampleLength:
Max: 98

# Offense count: 13
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples.
# DisallowedExamples: works
RSpec/ExampleWording:
Exclude:
- 'bundler/spec/dependabot/bundler/file_updater/requirement_replacer_spec.rb'
- 'go_modules/spec/dependabot/go_modules/version_spec.rb'
- 'nuget/spec/dependabot/nuget/version_spec.rb'
- 'python/spec/dependabot/python/version_spec.rb'
- 'swift/spec/dependabot/swift/metadata_finder_spec.rb'
- 'updater/spec/dependabot/job_spec.rb'
- 'updater/spec/dependabot/update_files_command_spec.rb'

# Offense count: 14
# This cop supports safe autocorrection (--autocorrect).
RSpec/ExcessiveDocstringSpacing:
Expand Down
124 changes: 124 additions & 0 deletions anyintance
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
Inspecting 900 files
robaiken marked this conversation as resolved.
Show resolved Hide resolved
............................C.....................................................................................C....................................................................................................................C...........C........C..................C....................................................................................................................................................................................................................C....................................................................C.......................................................................C........................................................................................................................................C...............................................................................................................C....C....................

Offenses:

bundler/helpers/v1/spec/shared_contexts.rb:32:5: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Bundler::CompactIndexClient::Updater)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bundler/spec/dependabot/bundler/update_checker_spec.rb:214:13: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::GitCommitChecker)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bundler/spec/dependabot/bundler/update_checker_spec.rb:224:13: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::GitCommitChecker)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bundler/spec/dependabot/bundler/update_checker_spec.rb:273:15: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::GitCommitChecker)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bundler/spec/dependabot/bundler/update_checker_spec.rb:287:15: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::GitCommitChecker)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bundler/spec/dependabot/bundler/update_checker_spec.rb:744:13: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::GitCommitChecker)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bundler/spec/dependabot/bundler/update_checker_spec.rb:777:13: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::GitCommitChecker)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bundler/spec/dependabot/bundler/update_checker_spec.rb:803:13: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::GitCommitChecker)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bundler/spec/dependabot/bundler/update_checker_spec.rb:846:15: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::GitCommitChecker)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bundler/spec/dependabot/bundler/update_checker_spec.rb:861:15: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::GitCommitChecker)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bundler/spec/dependabot/bundler/update_checker_spec.rb:965:17: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::GitCommitChecker)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bundler/spec/dependabot/bundler/update_checker_spec.rb:1026:13: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::GitCommitChecker)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bundler/spec/dependabot/bundler/update_checker_spec.rb:1074:13: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::GitCommitChecker)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bundler/spec/dependabot/bundler/update_checker_spec.rb:1109:13: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::GitCommitChecker)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bundler/spec/dependabot/bundler/update_checker_spec.rb:1589:11: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::GitCommitChecker)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
common/spec/dependabot/clients/codecommit_spec.rb:32:5: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of( ...
^^^^^^^^^^^^^^^^^^^^^^
common/spec/dependabot/file_fetchers/base_spec.rb:40:5: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of( ...
^^^^^^^^^^^^^^^^^^^^^^
common/spec/dependabot/git_commit_checker_spec.rb:163:11: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(DummyPackageManager::MetadataFinder)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
common/spec/dependabot/git_commit_checker_spec.rb:287:11: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(DummyPackageManager::MetadataFinder)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
common/spec/dependabot/pull_request_creator/message_builder_spec.rb:1730:11: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::MetadataFinders::Base)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
gradle/spec/dependabot/gradle/metadata_finder_spec.rb:165:13: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::FileFetchers::Base)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
gradle/spec/dependabot/gradle/metadata_finder_spec.rb:188:15: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::FileFetchers::Base)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
maven/spec/dependabot/maven/metadata_finder_spec.rb:115:13: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::FileFetchers::Base)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
maven/spec/dependabot/maven/metadata_finder_spec.rb:138:15: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::FileFetchers::Base)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
maven/spec/dependabot/maven/metadata_finder_spec.rb:155:15: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::FileFetchers::Base)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
maven/spec/dependabot/maven/metadata_finder_spec.rb:194:15: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::FileFetchers::Base)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
npm_and_yarn/spec/dependabot/npm_and_yarn/update_checker_spec.rb:325:9: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(described_class::VersionResolver)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
python/spec/dependabot/python/file_updater_spec.rb:408:9: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::Python::FileUpdater).to receive(:check_required_files).and_return(true)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
updater/spec/dependabot/dependency_change_builder_spec.rb:146:9: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::Bundler::FileUpdater).to receive(:updated_dependency_files).and_return([])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
updater/spec/dependabot/file_fetcher_command_spec.rb:61:9: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::Bundler::FileFetcher)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
updater/spec/dependabot/file_fetcher_command_spec.rb:63:9: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::Bundler::FileFetcher)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
updater/spec/dependabot/file_fetcher_command_spec.rb:65:9: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::Bundler::FileFetcher)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
updater/spec/dependabot/file_fetcher_command_spec.rb:85:9: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::Bundler::FileFetcher)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
updater/spec/dependabot/file_fetcher_command_spec.rb:109:9: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::Bundler::FileFetcher)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
updater/spec/dependabot/file_fetcher_command_spec.rb:129:9: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::Bundler::FileFetcher)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
updater/spec/dependabot/file_fetcher_command_spec.rb:177:9: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::Bundler::FileFetcher)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
updater/spec/dependabot/file_fetcher_command_spec.rb:216:9: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(Dependabot::Bundler::FileFetcher)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
updater/spec/dependabot/file_fetcher_command_spec.rb:278:11: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(DummyPackageManager::FileFetcher)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
updater/spec/dependabot/file_fetcher_command_spec.rb:298:11: C: RSpec/AnyInstance: Avoid stubbing using allow_any_instance_of.
allow_any_instance_of(DummyPackageManager::FileFetcher)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

900 files inspected, 39 offenses detected
9 changes: 9 additions & 0 deletions bundler/spec/dependabot/bundler/file_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@

it { is_expected.to be_a(Dependabot::Dependency) }
its(:requirements) { is_expected.to eq(expected_requirements) }

its(:version) do
is_expected.to eq("1530024bd6a68d36ac18e04836ce110e0d433c36")
end
Expand All @@ -205,6 +206,7 @@

it { is_expected.to be_a(Dependabot::Dependency) }
its(:requirements) { is_expected.to eq(expected_requirements) }

its(:version) do
is_expected.to eq("1530024bd6a68d36ac18e04836ce110e0d433c36")
end
Expand All @@ -228,6 +230,7 @@

it { is_expected.to be_a(Dependabot::Dependency) }
its(:requirements) { is_expected.to eq(expected_requirements) }

its(:version) do
is_expected.to eq("997d1a6ee76a1f254fd72ce16acbc8d347fcaee3")
end
Expand All @@ -253,6 +256,7 @@

it { is_expected.to be_a(Dependabot::Dependency) }
its(:requirements) { is_expected.to eq(expected_requirements) }

its(:version) do
is_expected.to eq("d31e445215b5af70c1604715d97dd953e868380e")
end
Expand All @@ -278,6 +282,7 @@

it { is_expected.to be_a(Dependabot::Dependency) }
its(:requirements) { is_expected.to eq(expected_requirements) }

its(:version) do
is_expected.to eq("d31e445215b5af70c1604715d97dd953e868380e")
end
Expand Down Expand Up @@ -362,6 +367,7 @@
let(:dependency_files) { bundler_project_dependency_files("subdependency") }

its(:length) { is_expected.to eq(2) }

it "is included" do
expect(dependencies.map(&:name)).to include("i18n")
end
Expand All @@ -371,6 +377,7 @@
let(:dependency_files) { bundler_project_dependency_files("platform_windows") }

its(:length) { is_expected.to eq(1) }

it "is not included" do
expect(dependencies.map(&:name)).to_not include("statesman")
end
Expand Down Expand Up @@ -760,6 +767,7 @@
it { is_expected.to be_a(Dependabot::Dependency) }
its(:name) { is_expected.to eq("business") }
its(:version) { is_expected.to be_nil }

its(:requirements) do
is_expected.to match_array(expected_requirements)
end
Expand Down Expand Up @@ -821,6 +829,7 @@
let(:dependency_files) { bundler_project_dependency_files("platform_windows_no_lockfile") }

its(:length) { is_expected.to eq(1) }

it "is not included" do
expect(dependencies.map(&:name)).to_not include("statesman")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
let(:updated_requirement) { ">=3.2, <5.0" }
let(:content) { %(gem "devise", "~>3.2") }

it "should include spaces between enumerated requirements" do
it "includes spaces between enumerated requirements" do
is_expected.to include(%(gem "devise", ">=3.2", "<5.0"))
end
end
Expand Down
2 changes: 2 additions & 0 deletions common/spec/dependabot/file_fetchers/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ def fetch_files
it { is_expected.to be_a(Dependabot::DependencyFile) }
its(:content) { is_expected.to include("octokit") }
its(:type) { is_expected.to include("symlink") }

its(:symlink_target) do
is_expected.to include("symlinked/requirements.txt")
end
Expand Down Expand Up @@ -1470,6 +1471,7 @@ def optional

it { is_expected.to be_a(Dependabot::DependencyFile) }
its(:type) { is_expected.to include("symlink") }

its(:symlink_target) do
is_expected.to include("symlinked/requirements.txt")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
let(:dependency_set) { described_class.new(case_sensitive: true) }

it { is_expected.to be_a(described_class) }

its(:dependencies) do
is_expected.to eq([existing_dependency, dependency])
end
Expand All @@ -111,6 +112,7 @@
end

it { is_expected.to be_a(described_class) }

its(:dependencies) do
is_expected.to match_array([existing_dependency, dependency])
end
Expand Down
2 changes: 2 additions & 0 deletions common/spec/dependabot/git_commit_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -956,9 +956,11 @@
let(:upload_pack_fixture) { "business" }

its([:tag]) { is_expected.to eq("v1.13.0") }

its([:commit_sha]) do
is_expected.to eq("7bb4e41ce5164074a0920d5b5770d196b4d90104")
end

its([:tag_sha]) do
is_expected.to eq("37f41032a0f191507903ebbae8a5c0cb945d7585")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3460,6 +3460,7 @@ def commits_details(base:, head:)
it "returns a Message" do
expect(message).to be_a(Dependabot::PullRequestCreator::Message)
end

its(:pr_name) { is_expected.to eq(pr_name) }
its(:pr_message) { is_expected.to eq(pr_message) }
its(:commit_message) { is_expected.to eq(commit_message) }
Expand Down
11 changes: 11 additions & 0 deletions composer/spec/dependabot/composer/file_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
it { is_expected.to be_a(Dependabot::Dependency) }
its(:name) { is_expected.to eq("monolog/monolog") }
its(:version) { is_expected.to eq("1.0.2") }

its(:requirements) do
is_expected.to eq(
[{
Expand Down Expand Up @@ -68,6 +69,7 @@
it { is_expected.to be_a(Dependabot::Dependency) }
its(:name) { is_expected.to eq("monolog/monolog") }
its(:version) { is_expected.to eq("1.0.2") }

its(:requirements) do
is_expected.to eq(
[{
Expand Down Expand Up @@ -96,9 +98,11 @@
subject { dependencies.first }

it { is_expected.to be_a(Dependabot::Dependency) }

its(:name) do
is_expected.to eq("wpackagist-plugin/ga-google-analytics")
end

its(:version) { is_expected.to eq("20180828") }
end
end
Expand All @@ -116,6 +120,7 @@
it { is_expected.to be_a(Dependabot::Dependency) }
its(:name) { is_expected.to eq("monolog/monolog") }
its(:version) { is_expected.to eq("1.0.1") }

its(:requirements) do
is_expected.to eq(
[{
Expand Down Expand Up @@ -196,9 +201,11 @@

it { is_expected.to be_a(Dependabot::Dependency) }
its(:name) { is_expected.to eq("monolog/monolog") }

its(:version) do
is_expected.to eq("5267b03b1e4861c4657ede17a88f13ef479db482")
end

its(:requirements) do
is_expected.to eq(
[{
Expand Down Expand Up @@ -276,6 +283,7 @@
it { is_expected.to be_a(Dependabot::Dependency) }
its(:name) { is_expected.to eq("path_dep/path_dep") }
its(:version) { is_expected.to eq("1.0.1") }

its(:requirements) do
is_expected.to eq(
[{
Expand All @@ -300,6 +308,7 @@
it { is_expected.to be_a(Dependabot::Dependency) }
its(:name) { is_expected.to eq("monolog/monolog") }
its(:version) { is_expected.to be_nil }

its(:requirements) do
is_expected.to eq(
[{
Expand All @@ -325,6 +334,7 @@
it { is_expected.to be_a(Dependabot::Dependency) }
its(:name) { is_expected.to eq("monolog/monolog") }
its(:version) { is_expected.to be_nil }

its(:requirements) do
is_expected.to eq(
[{
Expand Down Expand Up @@ -356,6 +366,7 @@
it { is_expected.to be_a(Dependabot::Dependency) }
its(:name) { is_expected.to eq("monolog/monolog") }
its(:version) { is_expected.to be_nil }

its(:requirements) do
is_expected.to eq(
[{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@
end

it { is_expected.to eq(Gem::Version.new("2.2.0")) }

it "doesn't hit the main registry (since requested not to)" do
finder.latest_version
expect(WebMock).to_not have_requested(:get, packagist_url)
Expand Down
Loading
Loading