engine_cart 2.5.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +22 -20
- data/Gemfile +0 -10
- data/README.md +1 -1
- data/Rakefile +18 -3
- data/engine_cart.gemspec +1 -1
- data/lib/engine_cart/gemfile_stanza.rb +2 -12
- data/lib/engine_cart/tasks/engine_cart.rake +14 -11
- data/lib/engine_cart/version.rb +1 -1
- data/lib/engine_cart.rb +13 -1
- data/spec/integration/engine_cart_spec.rb +11 -0
- metadata +5 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0c9c862d77d839d24bac91c4e8f6d18cd8c031eaf39d5330c718bd4896a6cf3c
|
|
4
|
+
data.tar.gz: 9afabca37a2c8c13ef48dfcff60161540ff587f840706517e02cadf81b544376
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ff2e7b28c8c29428f7ee533bbf2af5fe6d1c58a084d4b542334cfc91a3726e88603cdcd5595f5ba9bd2dbfdb0e44abda6b6450ccca851e06e9677cc0c70fd324
|
|
7
|
+
data.tar.gz: 4f246cecdbc1255e428b11cd6ad4b612c9d670e74b48288fe3ab1eb24d690c3c027bd217d9246c4bcb6fd69aa32907bb657b1926329c6041c7fa6bcea63a47e2
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -2,9 +2,9 @@ name: CI
|
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
|
-
branches: [
|
|
5
|
+
branches: [master]
|
|
6
6
|
pull_request:
|
|
7
|
-
branches: [
|
|
7
|
+
branches: [master]
|
|
8
8
|
|
|
9
9
|
jobs:
|
|
10
10
|
test:
|
|
@@ -12,23 +12,25 @@ jobs:
|
|
|
12
12
|
strategy:
|
|
13
13
|
matrix:
|
|
14
14
|
ruby:
|
|
15
|
-
- 2
|
|
15
|
+
- 3.2
|
|
16
|
+
- 3.4
|
|
17
|
+
- '4.0'
|
|
16
18
|
rails_version:
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
- 7.0.3.1
|
|
19
|
+
- 7.2.3
|
|
20
|
+
- 8.0.4
|
|
21
|
+
- 8.1.1
|
|
21
22
|
steps:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
- uses: actions/checkout@v2
|
|
24
|
+
- name: Set up Ruby
|
|
25
|
+
uses: ruby/setup-ruby@v1
|
|
26
|
+
with:
|
|
27
|
+
ruby-version: ${{ matrix.ruby }}
|
|
28
|
+
bundler: "latest"
|
|
29
|
+
- name: Install dependencies
|
|
30
|
+
run: bundle install
|
|
31
|
+
env:
|
|
32
|
+
RAILS_VERSION: ${{ matrix.rails_version }}
|
|
33
|
+
- name: Run tests
|
|
34
|
+
run: bundle exec rake
|
|
35
|
+
env:
|
|
36
|
+
RAILS_VERSION: ${{ matrix.rails_version }}
|
data/Gemfile
CHANGED
|
@@ -4,13 +4,3 @@ source 'https://rubygems.org'
|
|
|
4
4
|
gemspec
|
|
5
5
|
|
|
6
6
|
gem 'rails', ENV['RAILS_VERSION'] if ENV['RAILS_VERSION']
|
|
7
|
-
|
|
8
|
-
case ENV['RAILS_VERSION']
|
|
9
|
-
when /^6.0/
|
|
10
|
-
gem 'sass-rails', '>= 6'
|
|
11
|
-
gem 'webpacker', '~> 4.0'
|
|
12
|
-
when /^5.[12]/
|
|
13
|
-
gem 'sprockets', '< 4.0'
|
|
14
|
-
gem 'sass-rails', '~> 5.0'
|
|
15
|
-
gem 'thor', '~> 0.20'
|
|
16
|
-
end
|
data/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Rake tasks to generate a test application for a Rails Engine gem.
|
|
|
7
7
|
If you have a Rails Engine and want to test it, the suggested approach is a small dummy application that loads up a Rails application with your engine loaded. This dummy application is usually checked into source control and maintained with the application. This works great, until you want to test:
|
|
8
8
|
|
|
9
9
|
- different versions of Ruby (e.g. MRI and JRuby)
|
|
10
|
-
- different versions of Rails (Rails
|
|
10
|
+
- different versions of Rails (Rails 6.1, 7.1)
|
|
11
11
|
- different deployment environments (with and without devise, etc)
|
|
12
12
|
|
|
13
13
|
where each scenario may involve different configurations, Gemfiles, etc.
|
data/Rakefile
CHANGED
|
@@ -35,7 +35,7 @@ task :generate_test_gem => ['engine_cart:setup'] do
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
IO.write(".internal_test_gem/internal_test_gem.gemspec", gemspec_data)
|
|
38
|
-
IO.write(".internal_test_gem/Gemfile", File.open(".internal_test_gem/Gemfile") {|f| f.read.gsub(/.*sqlite3.*/, "")})
|
|
38
|
+
IO.write(".internal_test_gem/Gemfile", File.open(".internal_test_gem/Gemfile") {|f| f.read.gsub(/.*sqlite3.*/, "").gsub(/.*puma.*/, "")})
|
|
39
39
|
|
|
40
40
|
Rake::Task['engine_cart:inject_gemfile_extras'].invoke
|
|
41
41
|
EngineCart.within_test_app do
|
|
@@ -56,13 +56,28 @@ task :generate_test_gem => ['engine_cart:setup'] do
|
|
|
56
56
|
EOF
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
+
FileUtils.mkdir_p('lib/generators/internal_test_gem')
|
|
60
|
+
File.open('lib/generators/internal_test_gem/install_generator.rb', 'w') do |f|
|
|
61
|
+
f.puts <<-EOF
|
|
62
|
+
require 'rails/generators'
|
|
63
|
+
|
|
64
|
+
module InternalTestGem
|
|
65
|
+
class InstallGenerator < Rails::Generators::Base
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
EOF
|
|
69
|
+
end
|
|
70
|
+
|
|
59
71
|
system "echo '\ngem \"rspec-rails\"\n' >> Gemfile"
|
|
72
|
+
if RUBY_VERSION < '3.0'
|
|
73
|
+
system "echo '\ngem \"sqlite3\", \"< 1.7.0\"\n' >> Gemfile"
|
|
74
|
+
end
|
|
60
75
|
|
|
61
|
-
Bundler.
|
|
76
|
+
Bundler.unbundled_system "bundle update --quiet"
|
|
62
77
|
system "echo 'require \"engine_cart/rake_task\"\n' >> Rakefile"
|
|
63
78
|
|
|
64
79
|
system("bundle exec rake engine_cart:prepare")
|
|
65
|
-
Bundler.
|
|
80
|
+
Bundler.unbundled_system "bundle install --quiet"
|
|
66
81
|
end
|
|
67
82
|
end
|
|
68
83
|
|
data/engine_cart.gemspec
CHANGED
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
19
|
spec.require_paths = ["lib"]
|
|
20
20
|
|
|
21
|
-
spec.add_dependency 'rails', '>=
|
|
21
|
+
spec.add_dependency 'rails', '>= 6.1'
|
|
22
22
|
spec.add_development_dependency "rake"
|
|
23
23
|
spec.add_development_dependency "rspec"
|
|
24
24
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module EngineCart
|
|
2
2
|
def self.gemfile_stanza_check_line
|
|
3
|
-
'engine_cart stanza: 2.
|
|
3
|
+
'engine_cart stanza: 2.6.0'
|
|
4
4
|
end
|
|
5
5
|
|
|
6
6
|
def self.gemfile_stanza_text
|
|
@@ -23,20 +23,10 @@ module EngineCart
|
|
|
23
23
|
if ENV['RAILS_VERSION']
|
|
24
24
|
if ENV['RAILS_VERSION'] == 'edge'
|
|
25
25
|
gem 'rails', github: 'rails/rails'
|
|
26
|
-
ENV['ENGINE_CART_RAILS_OPTIONS'] = '--edge
|
|
26
|
+
ENV['ENGINE_CART_RAILS_OPTIONS'] = '--edge'
|
|
27
27
|
else
|
|
28
28
|
gem 'rails', ENV['RAILS_VERSION']
|
|
29
29
|
end
|
|
30
|
-
|
|
31
|
-
case ENV['RAILS_VERSION']
|
|
32
|
-
when /^6.0/
|
|
33
|
-
gem 'sass-rails', '>= 6'
|
|
34
|
-
gem 'webpacker', '~> 4.0'
|
|
35
|
-
when /^5.[12]/
|
|
36
|
-
gem 'sass-rails', '~> 5.0'
|
|
37
|
-
gem 'sprockets', '~> 3.7'
|
|
38
|
-
gem 'thor', '~> 0.20'
|
|
39
|
-
end
|
|
40
30
|
end
|
|
41
31
|
end
|
|
42
32
|
# END ENGINE_CART BLOCK
|
|
@@ -27,6 +27,7 @@ namespace :engine_cart do
|
|
|
27
27
|
task :create_test_rails_app => [:setup] do
|
|
28
28
|
require 'tmpdir'
|
|
29
29
|
require 'fileutils'
|
|
30
|
+
|
|
30
31
|
Dir.mktmpdir do |dir|
|
|
31
32
|
# Fork into a new process to avoid polluting the current one with the partial Rails environment ...
|
|
32
33
|
pid = fork do
|
|
@@ -37,6 +38,7 @@ namespace :engine_cart do
|
|
|
37
38
|
# Clear out our current bundle so that the rails generator can run with it's own bundle
|
|
38
39
|
backup_gemfile = ENV['BUNDLE_GEMFILE']
|
|
39
40
|
ENV.delete('BUNDLE_GEMFILE')
|
|
41
|
+
backup_lockfile = ENV.delete('BUNDLE_LOCKFILE')
|
|
40
42
|
|
|
41
43
|
# Using the Rails generator directly, instead of shelling out, to
|
|
42
44
|
# ensure we use the right version of Rails.
|
|
@@ -54,6 +56,7 @@ namespace :engine_cart do
|
|
|
54
56
|
|
|
55
57
|
# Restore our gemfile
|
|
56
58
|
ENV['BUNDLE_GEMFILE'] = backup_gemfile
|
|
59
|
+
ENV['BUNDLE_LOCKFILE'] = backup_lockfile
|
|
57
60
|
|
|
58
61
|
end
|
|
59
62
|
exit 0
|
|
@@ -66,12 +69,12 @@ namespace :engine_cart do
|
|
|
66
69
|
Rake::Task['engine_cart:clean'].invoke if File.exist? EngineCart.destination
|
|
67
70
|
FileUtils.move "#{dir}/internal", "#{EngineCart.destination}"
|
|
68
71
|
|
|
69
|
-
if
|
|
70
|
-
# Hack for https://github.com/
|
|
72
|
+
if RUBY_VERSION < '3.0'
|
|
73
|
+
# Hack for https://github.com/cbeer/engine_cart/issues/125
|
|
71
74
|
gemfile = File.join(EngineCart.destination, 'Gemfile')
|
|
72
75
|
IO.write(gemfile, File.open(gemfile) do |f|
|
|
73
76
|
text = f.read
|
|
74
|
-
text.gsub(/^gem ["']sqlite3["']$/, 'gem "sqlite3", "
|
|
77
|
+
text.gsub(/^gem ["']sqlite3["']$/, 'gem "sqlite3", "< 1.7"')
|
|
75
78
|
end)
|
|
76
79
|
end
|
|
77
80
|
end
|
|
@@ -106,19 +109,19 @@ namespace :engine_cart do
|
|
|
106
109
|
|
|
107
110
|
# Copy our test app generators into the app and prepare it
|
|
108
111
|
if File.exist? "#{EngineCart.templates_path}/lib/generators"
|
|
109
|
-
Bundler.
|
|
112
|
+
Bundler.unbundled_system "cp -r #{EngineCart.templates_path}/lib/generators #{EngineCart.destination}/lib"
|
|
110
113
|
end
|
|
111
114
|
|
|
112
115
|
within_test_app do
|
|
113
116
|
unless (system("bundle install --quiet") or system("bundle update --quiet")) and
|
|
114
|
-
system "(
|
|
115
|
-
system "
|
|
116
|
-
system "
|
|
117
|
+
system "(bin/rails g | grep test_app) && bin/rails generate test_app" and
|
|
118
|
+
system "bin/rails db:migrate" and
|
|
119
|
+
system "bin/rails db:test:prepare"
|
|
117
120
|
raise "EngineCart failed on with: #{$?}"
|
|
118
121
|
end
|
|
119
122
|
end
|
|
120
123
|
|
|
121
|
-
Bundler.
|
|
124
|
+
Bundler.unbundled_system "bundle install --quiet"
|
|
122
125
|
|
|
123
126
|
EngineCart.write_fingerprint
|
|
124
127
|
|
|
@@ -129,14 +132,14 @@ namespace :engine_cart do
|
|
|
129
132
|
desc 'Start the internal test application using `rails server`'
|
|
130
133
|
task :server, [:rails_server_args] => [:generate] do |_, args|
|
|
131
134
|
within_test_app do
|
|
132
|
-
system "
|
|
135
|
+
system "bin/rails server #{args[:rails_server_args]}"
|
|
133
136
|
end
|
|
134
137
|
end
|
|
135
138
|
|
|
136
139
|
desc 'Start the internal test application using `rails console`'
|
|
137
140
|
task :console, [:rails_console_args] => [:generate] do |_, args|
|
|
138
141
|
within_test_app do
|
|
139
|
-
system "
|
|
142
|
+
system "bin/rails console #{args[:rails_console_args]}"
|
|
140
143
|
end
|
|
141
144
|
end
|
|
142
145
|
end
|
|
@@ -144,7 +147,7 @@ end
|
|
|
144
147
|
def within_test_app
|
|
145
148
|
puts "\rtravis_fold:start:enginecart-bundler-cleanenv\r" if ENV['TRAVIS'] == 'true'
|
|
146
149
|
Dir.chdir(EngineCart.destination) do
|
|
147
|
-
|
|
150
|
+
EngineCart.with_unbundled_env do
|
|
148
151
|
yield
|
|
149
152
|
end
|
|
150
153
|
end
|
data/lib/engine_cart/version.rb
CHANGED
data/lib/engine_cart.rb
CHANGED
|
@@ -12,9 +12,21 @@ module EngineCart
|
|
|
12
12
|
require File.expand_path("config/environment", path || EngineCart.destination)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
+
def self.with_unbundled_env
|
|
16
|
+
method = if Bundler.respond_to?(:with_unbundled_env)
|
|
17
|
+
:with_unbundled_env
|
|
18
|
+
else
|
|
19
|
+
:with_clean_env
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
Bundler.public_send(method) do
|
|
23
|
+
yield
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
15
27
|
def self.within_test_app
|
|
16
28
|
Dir.chdir(EngineCart.destination) do
|
|
17
|
-
|
|
29
|
+
EngineCart.with_unbundled_env do
|
|
18
30
|
yield
|
|
19
31
|
end
|
|
20
32
|
end
|
|
@@ -31,6 +31,15 @@ describe "EngineCart powered application" do
|
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
it "should run the rails app generator's bundled installers when the engine_cart:generate task is invoked" do
|
|
35
|
+
EngineCart.within_test_app do
|
|
36
|
+
FileUtils.rm_rf('.internal_test_app')
|
|
37
|
+
output = `bundle exec rake engine_cart:generate 2>&1`
|
|
38
|
+
expect(output).not_to include('Bundler::GemNotFound')
|
|
39
|
+
expect(File).to exist(File.expand_path('.internal_test_app/config/importmap.rb'))
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
34
43
|
it "should not recreate an existing rails app when the engine_cart:generate task is reinvoked" do
|
|
35
44
|
EngineCart.within_test_app do
|
|
36
45
|
`bundle exec rake engine_cart:generate`
|
|
@@ -69,6 +78,7 @@ describe "EngineCart powered application" do
|
|
|
69
78
|
EOF
|
|
70
79
|
end
|
|
71
80
|
|
|
81
|
+
`bundle exec rake engine_cart:generate`
|
|
72
82
|
`bundle exec rspec spec/some_spec.rb`
|
|
73
83
|
expect($?).to eq 0
|
|
74
84
|
end
|
|
@@ -90,6 +100,7 @@ describe "EngineCart powered application" do
|
|
|
90
100
|
EOF
|
|
91
101
|
end
|
|
92
102
|
|
|
103
|
+
`bundle exec rake engine_cart:generate`
|
|
93
104
|
`bundle exec rspec spec/require_spec.rb`
|
|
94
105
|
expect($?).to eq 0
|
|
95
106
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: engine_cart
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chris Beer
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rails
|
|
@@ -16,14 +15,14 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
18
|
+
version: '6.1'
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
23
|
- - ">="
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
25
|
+
version: '6.1'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
27
|
name: rake
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -81,7 +80,6 @@ homepage: https://github.com/cbeer/engine_cart
|
|
|
81
80
|
licenses:
|
|
82
81
|
- MIT
|
|
83
82
|
metadata: {}
|
|
84
|
-
post_install_message:
|
|
85
83
|
rdoc_options: []
|
|
86
84
|
require_paths:
|
|
87
85
|
- lib
|
|
@@ -96,8 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
96
94
|
- !ruby/object:Gem::Version
|
|
97
95
|
version: '0'
|
|
98
96
|
requirements: []
|
|
99
|
-
rubygems_version:
|
|
100
|
-
signing_key:
|
|
97
|
+
rubygems_version: 4.0.22
|
|
101
98
|
specification_version: 4
|
|
102
99
|
summary: Helper for testing Rails Engines sanely
|
|
103
100
|
test_files:
|