Skip to content

Commit d33a157

Browse files
committed
Fix compatibility issues with rspec-rails
With 0.6.0, requiring `super_diff/rspec-rails` in the context of `rspec-rails` suddenly started failing. We try to require `rspec/version` so that we can have access to RSpec::Version. However, `rspec-rails` does not depend on the `rspec` metagem, so RSpec::Version is not a constant when using `rspec-rails`. In addition, this was never caught because it turns out that integration with `rspec-rails` was not being properly tested. This commit fixes `super_diff` to reference RSpec::Core::Version (since we can always assume `rspec-core` has been loaded) and makes sure that we are testing it so the aforementioned problem does not occur again.
1 parent 9cc1d6c commit d33a157

20 files changed

+506
-67
lines changed

Appraisals

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,56 @@ appraisals = {
88
instance_eval(&rails_dependencies)
99

1010
gem "activerecord", "~> 5.0.0"
11+
gem "railties", "~> 5.0.0"
1112
gem "sqlite3", "~> 1.3.6", platform: [:ruby, :mswin, :mingw]
1213
},
1314
rails_5_1: proc {
1415
instance_eval(&rails_dependencies)
1516

1617
gem "activerecord", "~> 5.1.0"
18+
gem "railties", "~> 5.1.0"
1719
gem "sqlite3", "~> 1.3.6", platform: [:ruby, :mswin, :mingw]
1820
},
1921
rails_5_2: proc {
2022
instance_eval(&rails_dependencies)
2123

2224
gem "activerecord", "~> 5.2.0"
25+
gem "railties", "~> 5.2.0"
2326
gem "sqlite3", "~> 1.3.6", platform: [:ruby, :mswin, :mingw]
2427
},
2528
rails_6_0: proc {
2629
instance_eval(&rails_dependencies)
2730

2831
gem "activerecord", "~> 6.0"
32+
gem "railties", "~> 6.0"
2933
gem "sqlite3", "~> 1.4.0", platform: [:ruby, :mswin, :mingw]
3034
},
3135
no_rails: proc {},
32-
rspec_lt_3_10: proc {
33-
gem "rspec", "< 3.10"
36+
rspec_lt_3_10: proc { |with_rails|
37+
version = "< 3.10"
38+
39+
if with_rails
40+
gem "rspec-core", version
41+
gem "rspec-expectations", version
42+
gem "rspec-mocks", version
43+
gem "rspec-support", version
44+
gem "rspec-rails"
45+
else
46+
gem "rspec", version
47+
end
3448
},
35-
rspec_gte_3_10: proc {
36-
gem "rspec", ">= 3.10", "< 4"
49+
rspec_gte_3_10: proc { |with_rails|
50+
version = [">= 3.10", "< 4"]
51+
52+
if with_rails
53+
gem "rspec-core", *version
54+
gem "rspec-expectations", *version
55+
gem "rspec-mocks", *version
56+
gem "rspec-support", *version
57+
gem "rspec-rails"
58+
else
59+
gem "rspec", *version
60+
end
3761
},
3862
}
3963

@@ -54,9 +78,16 @@ rspec_appraisals = [
5478

5579
rails_appraisals.each do |rails_appraisal|
5680
rspec_appraisals.each do |rspec_appraisal|
57-
appraise "#{rails_appraisal}_#{rspec_appraisal}" do
58-
instance_eval(&appraisals.fetch(rails_appraisal))
59-
instance_eval(&appraisals.fetch(rspec_appraisal))
81+
if rails_appraisal == :no_rails
82+
appraise "#{rails_appraisal}_#{rspec_appraisal}" do
83+
instance_eval(&appraisals.fetch(rails_appraisal))
84+
instance_exec(false, &appraisals.fetch(rspec_appraisal))
85+
end
86+
else
87+
appraise "#{rails_appraisal}_#{rspec_appraisal}" do
88+
instance_eval(&appraisals.fetch(rails_appraisal))
89+
instance_exec(true, &appraisals.fetch(rspec_appraisal))
90+
end
6091
end
6192
end
6293
end

gemfiles/rails_5_0_rspec_gte_3_10.gemfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ gem "rubocop"
1111
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
1212
gem "jdbc-sqlite3", platform: :jruby
1313
gem "activerecord", "~> 5.0.0"
14+
gem "railties", "~> 5.0.0"
1415
gem "sqlite3", "~> 1.3.6", platform: [:ruby, :mswin, :mingw]
15-
gem "rspec", ">= 3.10", "< 4"
16+
gem "rspec-core", ">= 3.10", "< 4"
17+
gem "rspec-expectations", ">= 3.10", "< 4"
18+
gem "rspec-mocks", ">= 3.10", "< 4"
19+
gem "rspec-support", ">= 3.10", "< 4"
20+
gem "rspec-rails"
1621

1722
gemspec path: "../"

gemfiles/rails_5_0_rspec_gte_3_10.gemfile.lock

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ PATH
99
GEM
1010
remote: https://rubygems.org/
1111
specs:
12+
actionpack (5.0.7.2)
13+
actionview (= 5.0.7.2)
14+
activesupport (= 5.0.7.2)
15+
rack (~> 2.0)
16+
rack-test (~> 0.6.3)
17+
rails-dom-testing (~> 2.0)
18+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
19+
actionview (5.0.7.2)
20+
activesupport (= 5.0.7.2)
21+
builder (~> 3.1)
22+
erubis (~> 2.7.0)
23+
rails-dom-testing (~> 2.0)
24+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
1225
activemodel (5.0.7.2)
1326
activesupport (= 5.0.7.2)
1427
activerecord (5.0.7.2)
@@ -27,15 +40,24 @@ GEM
2740
arel (7.1.4)
2841
ast (2.4.1)
2942
attr_extras (6.2.4)
43+
builder (3.2.4)
3044
byebug (11.1.3)
3145
childprocess (4.0.0)
3246
coderay (1.1.3)
3347
concurrent-ruby (1.1.7)
48+
crass (1.0.6)
3449
diff-lcs (1.4.4)
50+
erubis (2.7.0)
3551
i18n (1.8.5)
3652
concurrent-ruby (~> 1.0)
53+
loofah (2.7.0)
54+
crass (~> 1.0.2)
55+
nokogiri (>= 1.5.9)
3756
method_source (1.0.0)
57+
mini_portile2 (2.4.0)
3858
minitest (5.14.2)
59+
nokogiri (1.10.10)
60+
mini_portile2 (~> 2.4.0)
3961
parallel (1.19.2)
4062
parser (2.7.1.4)
4163
ast (~> 2.4.1)
@@ -47,14 +69,24 @@ GEM
4769
pry-byebug (3.9.0)
4870
byebug (~> 11.0)
4971
pry (~> 0.13.0)
72+
rack (2.2.3)
73+
rack-test (0.6.3)
74+
rack (>= 1.0)
75+
rails-dom-testing (2.0.3)
76+
activesupport (>= 4.2.0)
77+
nokogiri (>= 1.6)
78+
rails-html-sanitizer (1.3.0)
79+
loofah (~> 2.3)
80+
railties (5.0.7.2)
81+
actionpack (= 5.0.7.2)
82+
activesupport (= 5.0.7.2)
83+
method_source
84+
rake (>= 0.8.7)
85+
thor (>= 0.18.1, < 2.0)
5086
rainbow (3.0.0)
5187
rake (13.0.1)
5288
regexp_parser (1.7.1)
5389
rexml (3.2.4)
54-
rspec (3.10.0)
55-
rspec-core (~> 3.10.0)
56-
rspec-expectations (~> 3.10.0)
57-
rspec-mocks (~> 3.10.0)
5890
rspec-core (3.10.0)
5991
rspec-support (~> 3.10.0)
6092
rspec-expectations (3.10.0)
@@ -63,6 +95,14 @@ GEM
6395
rspec-mocks (3.10.0)
6496
diff-lcs (>= 1.2.0, < 2.0)
6597
rspec-support (~> 3.10.0)
98+
rspec-rails (4.0.1)
99+
actionpack (>= 4.2)
100+
activesupport (>= 4.2)
101+
railties (>= 4.2)
102+
rspec-core (~> 3.9)
103+
rspec-expectations (~> 3.9)
104+
rspec-mocks (~> 3.9)
105+
rspec-support (~> 3.9)
66106
rspec-support (3.10.0)
67107
rubocop (0.89.1)
68108
parallel (~> 1.10)
@@ -95,8 +135,13 @@ DEPENDENCIES
95135
jdbc-sqlite3
96136
pry-byebug
97137
pry-nav
138+
railties (~> 5.0.0)
98139
rake
99-
rspec (>= 3.10, < 4)
140+
rspec-core (>= 3.10, < 4)
141+
rspec-expectations (>= 3.10, < 4)
142+
rspec-mocks (>= 3.10, < 4)
143+
rspec-rails
144+
rspec-support (>= 3.10, < 4)
100145
rubocop
101146
sqlite3 (~> 1.3.6)
102147
super_diff!

gemfiles/rails_5_0_rspec_lt_3_10.gemfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ gem "rubocop"
1111
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
1212
gem "jdbc-sqlite3", platform: :jruby
1313
gem "activerecord", "~> 5.0.0"
14+
gem "railties", "~> 5.0.0"
1415
gem "sqlite3", "~> 1.3.6", platform: [:ruby, :mswin, :mingw]
15-
gem "rspec", "< 3.10"
16+
gem "rspec-core", "< 3.10"
17+
gem "rspec-expectations", "< 3.10"
18+
gem "rspec-mocks", "< 3.10"
19+
gem "rspec-support", "< 3.10"
20+
gem "rspec-rails"
1621

1722
gemspec path: "../"

gemfiles/rails_5_0_rspec_lt_3_10.gemfile.lock

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ PATH
99
GEM
1010
remote: https://rubygems.org/
1111
specs:
12+
actionpack (5.0.7.2)
13+
actionview (= 5.0.7.2)
14+
activesupport (= 5.0.7.2)
15+
rack (~> 2.0)
16+
rack-test (~> 0.6.3)
17+
rails-dom-testing (~> 2.0)
18+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
19+
actionview (5.0.7.2)
20+
activesupport (= 5.0.7.2)
21+
builder (~> 3.1)
22+
erubis (~> 2.7.0)
23+
rails-dom-testing (~> 2.0)
24+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
1225
activemodel (5.0.7.2)
1326
activesupport (= 5.0.7.2)
1427
activerecord (5.0.7.2)
@@ -27,15 +40,24 @@ GEM
2740
arel (7.1.4)
2841
ast (2.4.1)
2942
attr_extras (6.2.4)
43+
builder (3.2.4)
3044
byebug (11.1.3)
3145
childprocess (4.0.0)
3246
coderay (1.1.3)
3347
concurrent-ruby (1.1.7)
48+
crass (1.0.6)
3449
diff-lcs (1.4.4)
50+
erubis (2.7.0)
3551
i18n (1.8.5)
3652
concurrent-ruby (~> 1.0)
53+
loofah (2.7.0)
54+
crass (~> 1.0.2)
55+
nokogiri (>= 1.5.9)
3756
method_source (1.0.0)
57+
mini_portile2 (2.4.0)
3858
minitest (5.14.2)
59+
nokogiri (1.10.10)
60+
mini_portile2 (~> 2.4.0)
3961
parallel (1.19.2)
4062
parser (2.7.1.4)
4163
ast (~> 2.4.1)
@@ -47,14 +69,24 @@ GEM
4769
pry-byebug (3.9.0)
4870
byebug (~> 11.0)
4971
pry (~> 0.13.0)
72+
rack (2.2.3)
73+
rack-test (0.6.3)
74+
rack (>= 1.0)
75+
rails-dom-testing (2.0.3)
76+
activesupport (>= 4.2.0)
77+
nokogiri (>= 1.6)
78+
rails-html-sanitizer (1.3.0)
79+
loofah (~> 2.3)
80+
railties (5.0.7.2)
81+
actionpack (= 5.0.7.2)
82+
activesupport (= 5.0.7.2)
83+
method_source
84+
rake (>= 0.8.7)
85+
thor (>= 0.18.1, < 2.0)
5086
rainbow (3.0.0)
5187
rake (13.0.1)
5288
regexp_parser (1.7.1)
5389
rexml (3.2.4)
54-
rspec (3.9.0)
55-
rspec-core (~> 3.9.0)
56-
rspec-expectations (~> 3.9.0)
57-
rspec-mocks (~> 3.9.0)
5890
rspec-core (3.9.2)
5991
rspec-support (~> 3.9.3)
6092
rspec-expectations (3.9.2)
@@ -63,6 +95,14 @@ GEM
6395
rspec-mocks (3.9.1)
6496
diff-lcs (>= 1.2.0, < 2.0)
6597
rspec-support (~> 3.9.0)
98+
rspec-rails (4.0.1)
99+
actionpack (>= 4.2)
100+
activesupport (>= 4.2)
101+
railties (>= 4.2)
102+
rspec-core (~> 3.9)
103+
rspec-expectations (~> 3.9)
104+
rspec-mocks (~> 3.9)
105+
rspec-support (~> 3.9)
66106
rspec-support (3.9.3)
67107
rubocop (0.89.1)
68108
parallel (~> 1.10)
@@ -95,8 +135,13 @@ DEPENDENCIES
95135
jdbc-sqlite3
96136
pry-byebug
97137
pry-nav
138+
railties (~> 5.0.0)
98139
rake
99-
rspec (< 3.10)
140+
rspec-core (< 3.10)
141+
rspec-expectations (< 3.10)
142+
rspec-mocks (< 3.10)
143+
rspec-rails
144+
rspec-support (< 3.10)
100145
rubocop
101146
sqlite3 (~> 1.3.6)
102147
super_diff!

gemfiles/rails_5_1_rspec_gte_3_10.gemfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ gem "rubocop"
1111
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
1212
gem "jdbc-sqlite3", platform: :jruby
1313
gem "activerecord", "~> 5.1.0"
14+
gem "railties", "~> 5.1.0"
1415
gem "sqlite3", "~> 1.3.6", platform: [:ruby, :mswin, :mingw]
15-
gem "rspec", ">= 3.10", "< 4"
16+
gem "rspec-core", ">= 3.10", "< 4"
17+
gem "rspec-expectations", ">= 3.10", "< 4"
18+
gem "rspec-mocks", ">= 3.10", "< 4"
19+
gem "rspec-support", ">= 3.10", "< 4"
20+
gem "rspec-rails"
1621

1722
gemspec path: "../"

0 commit comments

Comments
 (0)