|
1 | 1 | require 'spec_helper' |
2 | 2 |
|
3 | | -describe "Rails Version Compatibility" do |
4 | | - describe "Rails 7.2.x compatibility code loading" do |
5 | | - context "when Rails version is in the 7.2.x range" do |
6 | | - it "should load compatibility code for Rails 7.2.0" do |
7 | | - version = Gem::Version.new("7.2.0") |
8 | | - expect(version >= Gem::Version.new("7.2")).to be true |
9 | | - expect(version < Gem::Version.new("7.3.0")).to be true |
10 | | - end |
11 | | - |
12 | | - it "should load compatibility code for Rails 7.2.1" do |
13 | | - version = Gem::Version.new("7.2.1") |
14 | | - expect(version >= Gem::Version.new("7.2")).to be true |
15 | | - expect(version < Gem::Version.new("7.3.0")).to be true |
16 | | - end |
17 | | - |
18 | | - it "should load compatibility code for Rails 7.2.2" do |
19 | | - version = Gem::Version.new("7.2.2") |
20 | | - expect(version >= Gem::Version.new("7.2")).to be true |
21 | | - expect(version < Gem::Version.new("7.3.0")).to be true |
22 | | - end |
| 3 | +module Polyamorous |
| 4 | + describe "Rails Version Compatibility" do |
| 5 | + describe "Rails 7.2.x compatibility code loading" do |
| 6 | + context "version boundary checks" do |
| 7 | + it "includes Rails 7.2.0 in compatibility range" do |
| 8 | + version = Gem::Version.new("7.2.0") |
| 9 | + expect(version >= Gem::Version.new("7.2")).to be true |
| 10 | + expect(version < Gem::Version.new("7.3.0")).to be true |
| 11 | + end |
23 | 12 |
|
24 | | - it "should load compatibility code for Rails 7.2.2.1" do |
25 | | - version = Gem::Version.new("7.2.2.1") |
26 | | - expect(version >= Gem::Version.new("7.2")).to be true |
27 | | - expect(version < Gem::Version.new("7.3.0")).to be true |
28 | | - end |
29 | | - end |
| 13 | + it "includes Rails 7.2.1 in compatibility range" do |
| 14 | + version = Gem::Version.new("7.2.1") |
| 15 | + expect(version >= Gem::Version.new("7.2")).to be true |
| 16 | + expect(version < Gem::Version.new("7.3.0")).to be true |
| 17 | + end |
30 | 18 |
|
31 | | - context "when Rails version is outside the 7.2.x range" do |
32 | | - it "should not load compatibility code for Rails 7.1.x" do |
33 | | - version = Gem::Version.new("7.1.3") |
34 | | - expect(version >= Gem::Version.new("7.2")).to be false |
35 | | - end |
| 19 | + it "excludes Rails 7.1.x from compatibility range" do |
| 20 | + version = Gem::Version.new("7.1.3") |
| 21 | + expect(version >= Gem::Version.new("7.2")).to be false |
| 22 | + end |
36 | 23 |
|
37 | | - it "should not load compatibility code for Rails 7.3.0" do |
38 | | - version = Gem::Version.new("7.3.0") |
39 | | - expect(version < Gem::Version.new("7.3.0")).to be false |
40 | | - end |
41 | | - end |
42 | | - end |
| 24 | + it "excludes Rails 7.3.0 from compatibility range" do |
| 25 | + version = Gem::Version.new("7.3.0") |
| 26 | + expect(version < Gem::Version.new("7.3.0")).to be false |
| 27 | + end |
43 | 28 |
|
44 | | - describe "actual compatibility behavior" do |
45 | | - context "when Rails 7.2 compatibility code is loaded" do |
46 | | - it "should have the JoinAssociationExtensions module available" do |
47 | | - # This test verifies that if we're in a Rails 7.2.x environment, |
48 | | - # the compatibility extensions are loaded |
49 | | - if ::ActiveRecord.version >= ::Gem::Version.new("7.2") && ::ActiveRecord.version < ::Gem::Version.new("7.3.0") |
50 | | - expect(Polyamorous::JoinAssociationExtensions).to be_a(Module) |
51 | | - expect(Polyamorous::JoinAssociationExtensions.instance_methods).to include(:join_constraints_with_tables) |
| 29 | + it "excludes Rails 8.0 from compatibility range" do |
| 30 | + version = Gem::Version.new("8.0.0") |
| 31 | + expect(version < Gem::Version.new("7.3.0")).to be false |
52 | 32 | end |
53 | 33 | end |
54 | 34 | end |
|
0 commit comments