Skip to content

Commit 98d55d3

Browse files
committed
🧪 Restore optional ORM spec gating
1 parent ca7d466 commit 98d55d3

12 files changed

Lines changed: 732 additions & 615 deletions

.rubocop_gradual.lock

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,12 @@
1616
"lib/omniauth/strategies/identity.rb:2260468599": [
1717
[232, 29, 1, "Style/TrailingCommaInArguments: Avoid comma after the last parameter of a method call.", 177545]
1818
],
19-
"spec/omniauth/identity/models/couch_potato_module_spec.rb:4058643040": [
20-
[42, 37, 1, "Style/TrailingCommaInHashLiteral: Avoid comma after the last item of a hash.", 177545]
19+
"spec/omniauth/strategies/identity_spec.rb:4035457592": [
20+
[53, 9, 63, "RSpec/LeakyLocalVariable: Do not use local variables defined outside of examples inside of them.", 4024977967],
21+
[54, 9, 47, "RSpec/LeakyLocalVariable: Do not use local variables defined outside of examples inside of them.", 2937627495],
22+
[55, 9, 47, "RSpec/LeakyLocalVariable: Do not use local variables defined outside of examples inside of them.", 359943335]
2123
],
22-
"spec/omniauth/identity/models/mongoid_spec.rb:1626561410": [
23-
[34, 37, 1, "Style/TrailingCommaInHashLiteral: Avoid comma after the last item of a hash.", 177545]
24-
],
25-
"spec/omniauth/identity/models/no_brainer_spec.rb:2371136555": [
26-
[34, 32, 1, "Style/TrailingCommaInHashLiteral: Avoid comma after the last item of a hash.", 177545],
27-
[62, 39, 1, "Style/TrailingCommaInHashLiteral: Avoid comma after the last item of a hash.", 177545]
28-
],
29-
"spec/omniauth/strategies/identity_spec.rb:654570549": [
30-
[19, 128, 1, "Style/TrailingCommaInArguments: Avoid comma after the last parameter of a method call.", 177545],
31-
[52, 7, 63, "RSpec/LeakyLocalVariable: Do not use local variables defined outside of examples inside of them.", 4024977967],
32-
[53, 7, 47, "RSpec/LeakyLocalVariable: Do not use local variables defined outside of examples inside of them.", 2937627495],
33-
[54, 7, 47, "RSpec/LeakyLocalVariable: Do not use local variables defined outside of examples inside of them.", 359943335],
34-
[213, 12, 1, "Style/TrailingCommaInHashLiteral: Avoid comma after the last item of a hash.", 177545],
35-
[221, 20, 1, "Style/TrailingCommaInArguments: Avoid comma after the last parameter of a method call.", 177545],
36-
[226, 20, 1, "Style/TrailingCommaInArguments: Avoid comma after the last parameter of a method call.", 177545],
37-
[272, 31, 1, "Style/TrailingCommaInHashLiteral: Avoid comma after the last item of a hash.", 177545],
38-
[347, 31, 1, "Style/TrailingCommaInHashLiteral: Avoid comma after the last item of a hash.", 177545],
39-
[370, 14, 1, "Style/TrailingCommaInHashLiteral: Avoid comma after the last item of a hash.", 177545]
40-
],
41-
"spec/spec_helper.rb:1331183603": [
24+
"spec/spec_helper.rb:3214074318": [
4225
[39, 4, 52, "Style/YodaCondition: Reverse the order of the operands `VersionGem::Ruby::RUBY_VER < Gem::Version.new(\"2.5\")`.", 3054081885]
4326
],
4427
"spec/support/shared_contexts/instance_with_instance_methods.rb:540999892": [

.simplecov

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,42 @@
66

77
require "kettle/soup/cover/config"
88

9+
omniauth_identity_bundled_gem = lambda do |*names|
10+
specs = if defined?(Bundler)
11+
Bundler.load.specs
12+
else
13+
Gem::Specification
14+
end
15+
16+
names.any? do |name|
17+
begin
18+
if specs.respond_to?(:find_by_name)
19+
specs.find_by_name(name)
20+
else
21+
specs.any? { |spec| spec.name == name }
22+
end
23+
rescue Gem::LoadError
24+
false
25+
end
26+
end
27+
end
28+
929
omniauth_identity_service_adapter_enabled = lambda do |adapter|
1030
enabled_values = %w[true 1 yes on]
1131
enabled_values.include?(ENV.fetch("OMNIAUTH_IDENTITY_ENABLE_SERVICE_ADAPTERS", "false").downcase) ||
1232
enabled_values.include?(ENV.fetch("OMNIAUTH_IDENTITY_ENABLE_#{adapter}", "false").downcase)
1333
end
1434

35+
omniauth_identity_sqlite3_enabled = lambda do
36+
return true if %w[true 1 yes on].include?(ENV.fetch("OMNIAUTH_IDENTITY_ENABLE_SQLITE3", "false").downcase)
37+
38+
if RUBY_ENGINE == "jruby"
39+
omniauth_identity_bundled_gem.call("jdbc-sqlite3", "activerecord-jdbcsqlite3-adapter")
40+
else
41+
omniauth_identity_bundled_gem.call("sqlite3")
42+
end
43+
end
44+
1545
# Minimum coverage thresholds are set by kettle-soup-cover.
1646
# They are controlled by ENV variables loaded by `mise` from `mise.toml`
1747
# (with optional machine-local overrides in `.env.local`).
@@ -25,4 +55,7 @@ SimpleCov.start do
2555
add_filter "lib/omniauth/identity/models/couch_potato.rb" unless omniauth_identity_service_adapter_enabled.call("COUCHDB")
2656
add_filter "lib/omniauth/identity/models/mongoid.rb" unless omniauth_identity_service_adapter_enabled.call("MONGODB")
2757
add_filter "lib/omniauth/identity/models/nobrainer.rb" unless omniauth_identity_service_adapter_enabled.call("RETHINKDB")
58+
add_filter "lib/omniauth/identity/models/active_record.rb" unless omniauth_identity_sqlite3_enabled.call
59+
add_filter "lib/omniauth/identity/models/rom.rb" unless omniauth_identity_sqlite3_enabled.call
60+
add_filter "lib/omniauth/identity/models/sequel.rb" unless omniauth_identity_sqlite3_enabled.call
2861
end

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ Please file a bug if you notice a violation of semantic versioning.
2828

2929
### Fixed
3030

31+
- Restored ORM-specific spec rake tasks and made optional ORM spec files avoid
32+
loading unavailable adapter gems when the matching appraisal does not include them.
33+
3134
### Security
3235

3336
## [3.2.0] - 2026-06-05

Rakefile

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,64 @@ rescue LoadError
131131
warn("NOTE: kettle-dev isn't installed, or is disabled for #{RUBY_VERSION} in the current environment")
132132
end
133133

134+
### ORM SPEC TASKS
135+
def run_omniauth_identity_specs(env, *paths)
136+
sh(env, "bundle", "exec", "rspec", *paths)
137+
end
138+
139+
namespace :spec do
140+
namespace :orm do
141+
desc "Run ActiveRecord-backed ORM and strategy specs"
142+
task :active_record do
143+
run_omniauth_identity_specs(
144+
{"OMNIAUTH_IDENTITY_ENABLE_SQLITE3" => "true"},
145+
"spec/omniauth/identity/models/active_record_spec.rb",
146+
"spec/omniauth/strategies/identity_spec.rb"
147+
)
148+
end
149+
150+
desc "Run CouchPotato-backed ORM specs"
151+
task :couch_potato do
152+
run_omniauth_identity_specs(
153+
{"OMNIAUTH_IDENTITY_ENABLE_COUCHDB" => "true"},
154+
"spec/omniauth/identity/models/couch_potato_module_spec.rb"
155+
)
156+
end
157+
158+
desc "Run Mongoid-backed ORM specs"
159+
task :mongoid do
160+
run_omniauth_identity_specs(
161+
{"OMNIAUTH_IDENTITY_ENABLE_MONGODB" => "true"},
162+
"spec/omniauth/identity/models/mongoid_spec.rb"
163+
)
164+
end
165+
166+
desc "Run NoBrainer-backed ORM specs"
167+
task :nobrainer do
168+
run_omniauth_identity_specs(
169+
{"OMNIAUTH_IDENTITY_ENABLE_RETHINKDB" => "true"},
170+
"spec/omniauth/identity/models/no_brainer_spec.rb"
171+
)
172+
end
173+
174+
desc "Run ROM-backed ORM specs"
175+
task :rom do
176+
run_omniauth_identity_specs(
177+
{"OMNIAUTH_IDENTITY_ENABLE_SQLITE3" => "true"},
178+
"spec/omniauth/identity/models/rom_spec.rb"
179+
)
180+
end
181+
182+
desc "Run Sequel-backed ORM specs"
183+
task :sequel do
184+
run_omniauth_identity_specs(
185+
{"OMNIAUTH_IDENTITY_ENABLE_SQLITE3" => "true"},
186+
"spec/omniauth/identity/models/sequel_spec.rb"
187+
)
188+
end
189+
end
190+
end
191+
134192
### DUPLICATE DRIFT TASKS
135193
begin
136194
require "kettle/drift"

spec/omniauth/identity/models/active_record_spec.rb

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,67 @@
11
# frozen_string_literal: true
22

3-
# Bugfixes
4-
# JRuby needed an explicit "require 'logger'" for Rails < 7.1
5-
# See: https://github.com/rails/rails/issues/54260#issuecomment-2594650047
6-
# Placing above omniauth because it is a dependency of omniauth,
7-
# which is undeclared in older versions.
8-
require "logger"
3+
if omniauth_identity_sqlite3_enabled? && omniauth_identity_bundled_gem?("activerecord", "anonymous_active_record")
4+
# Bugfixes
5+
# JRuby needed an explicit "require 'logger'" for Rails < 7.1
6+
# See: https://github.com/rails/rails/issues/54260#issuecomment-2594650047
7+
# Placing above omniauth because it is a dependency of omniauth,
8+
# which is undeclared in older versions.
9+
require "logger"
910

10-
require "active_record"
11-
require "anonymous_active_record"
11+
require "active_record"
12+
require "anonymous_active_record"
1213

13-
class TestIdentity < OmniAuth::Identity::Models::ActiveRecord; end
14+
class TestIdentity < OmniAuth::Identity::Models::ActiveRecord; end
1415

15-
RSpec.describe(OmniAuth::Identity::Models::ActiveRecord, :sqlite3) do
16-
describe "model", type: :model do
17-
subject(:model_definition) { -> { model_klass } }
16+
RSpec.describe(OmniAuth::Identity::Models::ActiveRecord, :sqlite3) do
17+
describe "model", type: :model do
18+
subject(:model_definition) { -> { model_klass } }
1819

19-
let(:model_klass) do
20-
AnonymousActiveRecord.generate(
21-
parent_klass: "OmniAuth::Identity::Models::ActiveRecord",
22-
columns: OmniAuth::Identity::Model::SCHEMA_ATTRIBUTES | %w[provider password_digest],
23-
connection_params: {adapter: distinguish_jdbc_driver ? "jdbcsqlite3" : "sqlite3", encoding: "utf8", database: ":memory:"}
24-
) do
25-
auth_key :email
26-
def flower
27-
"🌸"
20+
let(:model_klass) do
21+
AnonymousActiveRecord.generate(
22+
parent_klass: "OmniAuth::Identity::Models::ActiveRecord",
23+
columns: OmniAuth::Identity::Model::SCHEMA_ATTRIBUTES | %w[provider password_digest],
24+
connection_params: {adapter: distinguish_jdbc_driver ? "jdbcsqlite3" : "sqlite3", encoding: "utf8", database: ":memory:"}
25+
) do
26+
auth_key :email
27+
def flower
28+
"🌸"
29+
end
2830
end
2931
end
30-
end
3132

32-
let(:distinguish_jdbc_driver) { RUBY_PLATFORM == "java" && defined?(ArJdbc::Version) && Gem::Version.create(ArJdbc::Version) >= Gem::Version.create("72.0") }
33+
let(:distinguish_jdbc_driver) { RUBY_PLATFORM == "java" && defined?(ArJdbc::Version) && Gem::Version.create(ArJdbc::Version) >= Gem::Version.create("72.0") }
3334

34-
include_context "with persistable model"
35+
include_context "with persistable model"
3536

36-
describe "::table_name" do
37-
it "does not use STI rules for its table name" do
38-
expect(TestIdentity.table_name).to(eq("test_identities"))
37+
describe "::table_name" do
38+
it "does not use STI rules for its table name" do
39+
expect(TestIdentity.table_name).to(eq("test_identities"))
40+
end
3941
end
40-
end
4142

42-
describe "::locate" do
43-
it "delegates locate to the where query method" do
44-
args = {
45-
email: "open faced",
46-
category: "sandwiches",
47-
provider: "identity"
48-
}
49-
allow(model_klass).to(receive(:where).with(args).and_return(["wakka"]))
50-
expect(model_klass.locate(args)).to(eq("wakka"))
43+
describe "::locate" do
44+
it "delegates locate to the where query method" do
45+
args = {
46+
email: "open faced",
47+
category: "sandwiches",
48+
provider: "identity"
49+
}
50+
allow(model_klass).to(receive(:where).with(args).and_return(["wakka"]))
51+
expect(model_klass.locate(args)).to(eq("wakka"))
52+
end
5153
end
52-
end
5354

54-
describe "#inspect" do
55-
it "filters password-related attributes from ActiveRecord inspect output" do
56-
instance = model_klass.new(email: DEFAULT_EMAIL, password: DEFAULT_PASSWORD, password_confirmation: DEFAULT_PASSWORD)
57-
inspected = instance.inspect
55+
describe "#inspect" do
56+
it "filters password-related attributes from ActiveRecord inspect output" do
57+
instance = model_klass.new(email: DEFAULT_EMAIL, password: DEFAULT_PASSWORD, password_confirmation: DEFAULT_PASSWORD)
58+
inspected = instance.inspect
5859

59-
expect(inspected).to include(DEFAULT_EMAIL)
60-
expect(inspected).not_to include(DEFAULT_PASSWORD)
61-
expect(inspected).not_to include(instance.password_digest)
62-
expect(inspected).to include("password_digest: [FILTERED]")
60+
expect(inspected).to include(DEFAULT_EMAIL)
61+
expect(inspected).not_to include(DEFAULT_PASSWORD)
62+
expect(inspected).not_to include(instance.password_digest)
63+
expect(inspected).to include("password_digest: [FILTERED]")
64+
end
6365
end
6466
end
6567
end

spec/omniauth/identity/models/couch_potato_module_spec.rb

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,50 @@
11
# frozen_string_literal: true
22

3-
# Bugfixes
4-
# JRuby needed an explicit "require 'logger'" for Rails < 7.1
5-
# See: https://github.com/rails/rails/issues/54260#issuecomment-2594650047
6-
# Placing above omniauth because it is a dependency of omniauth,
7-
# which is undeclared in older versions.
8-
require "logger"
9-
require "active_support"
10-
11-
require "couch_potato"
12-
13-
RSpec.describe(OmniAuth::Identity::Models::CouchPotatoModule, :couchdb) do
14-
before(:context) do
15-
CouchPotato::Config.database_host = "http://admin:#{ENV.fetch("COUCHDB_PASSWORD", "password")}@127.0.0.1:5984"
16-
CouchPotato::Config.database_name = "test"
17-
CouchPotato.couchrest_database.recreate!
18-
end
3+
if omniauth_identity_service_adapter_enabled?("COUCHDB") && omniauth_identity_bundled_gem?("couch_potato")
4+
# Bugfixes
5+
# JRuby needed an explicit "require 'logger'" for Rails < 7.1
6+
# See: https://github.com/rails/rails/issues/54260#issuecomment-2594650047
7+
# Placing above omniauth because it is a dependency of omniauth,
8+
# which is undeclared in older versions.
9+
require "logger"
10+
require "active_support"
11+
12+
require "couch_potato"
13+
14+
RSpec.describe(OmniAuth::Identity::Models::CouchPotatoModule, :couchdb) do
15+
before(:context) do
16+
CouchPotato::Config.database_host = "http://admin:#{ENV.fetch("COUCHDB_PASSWORD", "password")}@127.0.0.1:5984"
17+
CouchPotato::Config.database_name = "test"
18+
CouchPotato.couchrest_database.recreate!
19+
end
1920

20-
before do
21-
couch_potato_test_identity = Class.new do
22-
# NOTE: CouchPotato::Persistence must be included before OmniAuth::Identity::Models::CouchPotatoModule
23-
include CouchPotato::Persistence
21+
before do
22+
couch_potato_test_identity = Class.new do
23+
# NOTE: CouchPotato::Persistence must be included before OmniAuth::Identity::Models::CouchPotatoModule
24+
include CouchPotato::Persistence
2425

25-
include OmniAuth::Identity::Models::CouchPotatoModule
26+
include OmniAuth::Identity::Models::CouchPotatoModule
2627

27-
property :email
28-
property :password_digest
28+
property :email
29+
property :password_digest
30+
end
31+
stub_const("CouchPotatoTestIdentity", couch_potato_test_identity)
2932
end
30-
stub_const("CouchPotatoTestIdentity", couch_potato_test_identity)
31-
end
3233

33-
describe "model", type: :model do
34-
let(:model_klass) { CouchPotatoTestIdentity }
34+
describe "model", type: :model do
35+
let(:model_klass) { CouchPotatoTestIdentity }
3536

36-
include_context "with persistable model"
37+
include_context "with persistable model"
3738

38-
describe "::locate" do
39-
it "delegates to the where query method" do
40-
args = {
41-
"email" => "open faced",
42-
"category" => "sandwiches",
43-
}
44-
allow(model_klass).to(receive(:where).with(args).and_return(["wakka"]))
45-
expect(model_klass.locate(args)).to(eq("wakka"))
39+
describe "::locate" do
40+
it "delegates to the where query method" do
41+
args = {
42+
"email" => "open faced",
43+
"category" => "sandwiches"
44+
}
45+
allow(model_klass).to(receive(:where).with(args).and_return(["wakka"]))
46+
expect(model_klass.locate(args)).to(eq("wakka"))
47+
end
4648
end
4749
end
4850
end

0 commit comments

Comments
 (0)