Skip to content

Commit 6d0f393

Browse files
authored
Fix broken specs (#476)
* Simplecov must be loaded first to monitor coverage * Require dev/test deps for specs Dev and test dependencies should be required for tests to use them. They _could_ be required manually within each individual spec file. Doing so would ensure that tests only load that which is directly necessary for that specific test file and would allow running individual files the absolute fastest. However, for expediency and because the dependency list is quite short, we can just load the entire group within the spec helper and reduce the burden on each test file to load its own dependencies. * All gems in Gemfile are dev/test deps It's unclear why byebug would have ever been listed as a 'test' dependency in the Gemfile. Virtually _all_ of the gems in the Gemfile (because this is a gem, and not an app) are going to be dev/test deps. simplecov, rspec, webmock, etc All of these gems are "test" gems. So either they should all be listed in the test group, or the test group ceases to have a role. (Indeed, because this is a gem and not an application, bundler's groups are already less useful. Nothing in this codebase was using the test group.) * Extract with_max_links to Helper module The with_max_links helper was already being used across multiple spec files, but wasn't properly being included for reuse. (It was defined _globally_ in one single spec, which only worked if that specific test just _happened_ to be loaded before the other.) Helpers like this need to be included wherever they are used (if not included globally).
1 parent b9f20a4 commit 6d0f393

File tree

12 files changed

+38
-56
lines changed

12 files changed

+38
-56
lines changed

Gemfile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ gemspec
88
gem 'appraisal', git: 'https://github.com/thoughtbot/appraisal.git'
99
gem 'aws-sdk-core'
1010
gem 'aws-sdk-s3'
11+
gem 'byebug'
1112
gem 'combustion'
1213
gem 'fog-aws'
1314
gem 'google-cloud-storage'
@@ -18,18 +19,14 @@ gem 'rspec_junit_formatter'
1819
gem 'rspec-rails'
1920
gem 'simplecov'
2021
gem 'sqlite3', '~> 2.1.0'
21-
gem 'webmock'
22+
gem 'webmock', require: 'webmock/rspec'
2223

2324
if RUBY_VERSION.match?(/2.5.*/)
2425
gem 'nokogiri', '1.12.5'
2526
else
2627
gem 'nokogiri'
2728
end
2829

29-
group :test do
30-
gem 'byebug'
31-
end
32-
3330
# Dev tools / linter
3431
gem 'rubocop', require: false
3532
gem 'rubocop-performance', require: false

gemfiles/rails_6.0.gemfile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ source "https://rubygems.org"
55
gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
66
gem "aws-sdk-core"
77
gem "aws-sdk-s3"
8+
gem "byebug"
89
gem "combustion"
910
gem "fog-aws"
1011
gem "google-cloud-storage"
@@ -15,17 +16,13 @@ gem "rspec_junit_formatter"
1516
gem "rspec-rails"
1617
gem "simplecov"
1718
gem "sqlite3", "~> 1.5.0"
18-
gem "webmock"
19+
gem "webmock", require: "webmock/rspec"
1920
gem "nokogiri"
2021
gem "rubocop", require: false
2122
gem "rubocop-performance", require: false
2223
gem "rubocop-rake", require: false
2324
gem "rubocop-rspec", require: false
2425

25-
group :test do
26-
gem "byebug"
27-
end
28-
2926
install_if -> { Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") } do
3027
gem "drb"
3128
gem "mutex_m"

gemfiles/rails_6.1.gemfile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ source "https://rubygems.org"
55
gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
66
gem "aws-sdk-core"
77
gem "aws-sdk-s3"
8+
gem "byebug"
89
gem "combustion"
910
gem "fog-aws"
1011
gem "google-cloud-storage"
@@ -15,17 +16,13 @@ gem "rspec_junit_formatter"
1516
gem "rspec-rails"
1617
gem "simplecov"
1718
gem "sqlite3", "~> 1.5.0"
18-
gem "webmock"
19+
gem "webmock", require: "webmock/rspec"
1920
gem "nokogiri"
2021
gem "rubocop", require: false
2122
gem "rubocop-performance", require: false
2223
gem "rubocop-rake", require: false
2324
gem "rubocop-rspec", require: false
2425

25-
group :test do
26-
gem "byebug"
27-
end
28-
2926
install_if -> { Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") } do
3027
gem "drb"
3128
gem "mutex_m"

gemfiles/rails_7.0.gemfile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ source "https://rubygems.org"
55
gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
66
gem "aws-sdk-core"
77
gem "aws-sdk-s3"
8+
gem "byebug"
89
gem "combustion"
910
gem "fog-aws"
1011
gem "google-cloud-storage"
@@ -15,17 +16,13 @@ gem "rspec_junit_formatter"
1516
gem "rspec-rails"
1617
gem "simplecov"
1718
gem "sqlite3", "~> 1.5.0"
18-
gem "webmock"
19+
gem "webmock", require: "webmock/rspec"
1920
gem "nokogiri"
2021
gem "rubocop", require: false
2122
gem "rubocop-performance", require: false
2223
gem "rubocop-rake", require: false
2324
gem "rubocop-rspec", require: false
2425

25-
group :test do
26-
gem "byebug"
27-
end
28-
2926
install_if -> { Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") } do
3027
gem "drb"
3128
gem "mutex_m"

gemfiles/rails_7.1.gemfile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ source "https://rubygems.org"
55
gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
66
gem "aws-sdk-core"
77
gem "aws-sdk-s3"
8+
gem "byebug"
89
gem "combustion"
910
gem "fog-aws"
1011
gem "google-cloud-storage"
@@ -15,15 +16,11 @@ gem "rspec_junit_formatter"
1516
gem "rspec-rails"
1617
gem "simplecov"
1718
gem "sqlite3", "~> 1.5.0"
18-
gem "webmock"
19+
gem "webmock", require: "webmock/rspec"
1920
gem "nokogiri"
2021
gem "rubocop", require: false
2122
gem "rubocop-performance", require: false
2223
gem "rubocop-rake", require: false
2324
gem "rubocop-rspec", require: false
2425

25-
group :test do
26-
gem "byebug"
27-
end
28-
2926
gemspec path: "../"

gemfiles/rails_7.2.gemfile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ source "https://rubygems.org"
55
gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
66
gem "aws-sdk-core"
77
gem "aws-sdk-s3"
8+
gem "byebug"
89
gem "combustion"
910
gem "fog-aws"
1011
gem "google-cloud-storage"
@@ -15,15 +16,11 @@ gem "rspec_junit_formatter"
1516
gem "rspec-rails"
1617
gem "simplecov"
1718
gem "sqlite3", "~> 1.5.0"
18-
gem "webmock"
19+
gem "webmock", require: "webmock/rspec"
1920
gem "nokogiri"
2021
gem "rubocop", require: false
2122
gem "rubocop-performance", require: false
2223
gem "rubocop-rake", require: false
2324
gem "rubocop-rspec", require: false
2425

25-
group :test do
26-
gem "byebug"
27-
end
28-
2926
gemspec path: "../"

gemfiles/rails_8.0.gemfile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ source "https://rubygems.org"
55
gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
66
gem "aws-sdk-core"
77
gem "aws-sdk-s3"
8+
gem "byebug"
89
gem "combustion"
910
gem "fog-aws"
1011
gem "google-cloud-storage"
@@ -15,15 +16,11 @@ gem "rspec_junit_formatter"
1516
gem "rspec-rails"
1617
gem "simplecov"
1718
gem "sqlite3", "~> 2.1.0"
18-
gem "webmock"
19+
gem "webmock", require: "webmock/rspec"
1920
gem "nokogiri"
2021
gem "rubocop", require: false
2122
gem "rubocop-performance", require: false
2223
gem "rubocop-rake", require: false
2324
gem "rubocop-rspec", require: false
2425

25-
group :test do
26-
gem "byebug"
27-
end
28-
2926
gemspec path: "../"

gemfiles/rails_8.1.gemfile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ source "https://rubygems.org"
55
gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
66
gem "aws-sdk-core"
77
gem "aws-sdk-s3"
8+
gem "byebug"
89
gem "combustion"
910
gem "fog-aws"
1011
gem "google-cloud-storage"
@@ -15,15 +16,11 @@ gem "rspec_junit_formatter"
1516
gem "rspec-rails"
1617
gem "simplecov"
1718
gem "sqlite3", "~> 2.1.0"
18-
gem "webmock"
19+
gem "webmock", require: "webmock/rspec"
1920
gem "nokogiri"
2021
gem "rubocop", require: false
2122
gem "rubocop-performance", require: false
2223
gem "rubocop-rake", require: false
2324
gem "rubocop-rspec", require: false
2425

25-
group :test do
26-
gem "byebug"
27-
end
28-
2926
gemspec path: "../"

spec/sitemap_generator/interpreter_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
require 'sitemap_generator/interpreter'
33

44
RSpec.describe SitemapGenerator::Interpreter do
5+
include SitemapHelpers
6+
57
let(:link_set) { SitemapGenerator::LinkSet.new }
68
let(:interpreter) { SitemapGenerator::Interpreter.new(:link_set => link_set) }
79

spec/sitemap_generator/sitemap_generator_spec.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,9 @@ class << self
77
end
88
end
99

10-
def with_max_links(num)
11-
original = SitemapGenerator::Sitemap.max_sitemap_links
12-
SitemapGenerator::Sitemap.max_sitemap_links = num
13-
yield
14-
ensure
15-
SitemapGenerator::Sitemap.max_sitemap_links = original
16-
end
17-
1810
RSpec.describe 'SitemapGenerator' do
11+
include SitemapHelpers
12+
1913
describe 'reset!' do
2014
before do
2115
SitemapGenerator::Sitemap.default_host # Force initialization of the LinkSet

0 commit comments

Comments
 (0)