engine_cart 2.2.1 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +34 -0
- data/Gemfile +10 -0
- data/README.md +2 -2
- data/Rakefile +22 -12
- data/engine_cart.gemspec +1 -1
- data/lib/engine_cart/configuration.rb +4 -2
- data/lib/engine_cart/gemfile_stanza.rb +10 -9
- data/lib/engine_cart/tasks/engine_cart.rake +30 -21
- data/lib/engine_cart/version.rb +1 -1
- data/lib/engine_cart.rb +34 -4
- data/spec/integration/engine_cart_spec.rb +1 -1
- metadata +9 -9
- data/.travis.yml +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db419965be01fa06326e357013ea09c444dec04e71428a38ee9eaa24cc79426f
|
4
|
+
data.tar.gz: ee7b17829334ddeeb2e1b48c4557cce763b0bb7b12cd436713f6ddca97680fe1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 817da9a19e20ed5ad760a3c7e3ad0b10ac484c341d8823487aae83c2a049d437de97134d7d966e9fae239f5d1faf57e1c2e7cf541c73c97498922ef6a07a8e62
|
7
|
+
data.tar.gz: 8c520fea25e5ce140ce9e53c6ad5ec6015a679b783272383dbe9785c969dec91db194c592fed72d7c062a01b3649470edfd8fbeefdef6334c75fd39f02380b6b
|
@@ -0,0 +1,34 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
ruby:
|
15
|
+
- 2.7
|
16
|
+
rails_version:
|
17
|
+
- 5.2.8.1
|
18
|
+
- 6.0.5.1
|
19
|
+
- 6.1.6.1
|
20
|
+
- 7.0.3.1
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@v2
|
23
|
+
- name: Set up Ruby
|
24
|
+
uses: ruby/setup-ruby@v1
|
25
|
+
with:
|
26
|
+
ruby-version: ${{ matrix.ruby }}
|
27
|
+
- name: Install dependencies
|
28
|
+
run: bundle install
|
29
|
+
env:
|
30
|
+
RAILS_VERSION: ${{ matrix.rails_version }}
|
31
|
+
- name: Run tests
|
32
|
+
run: bundle exec rake
|
33
|
+
env:
|
34
|
+
RAILS_VERSION: ${{ matrix.rails_version }}
|
data/Gemfile
CHANGED
@@ -4,3 +4,13 @@ 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
@@ -1,4 +1,4 @@
|
|
1
|
-
[![
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/engine_cart.svg)](http://badge.fury.io/rb/engine_cart)
|
2
2
|
|
3
3
|
# EngineCart
|
4
4
|
|
@@ -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 5.0, 6.0)
|
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
@@ -10,19 +10,32 @@ end
|
|
10
10
|
|
11
11
|
task :generate_test_gem => ['engine_cart:setup'] do
|
12
12
|
system("rm -rf .internal_test_gem")
|
13
|
-
gem 'rails'
|
13
|
+
gem 'rails', ENV['RAILS_VERSION']
|
14
14
|
|
15
15
|
rails_path = Gem.bin_path('railties', 'rails')
|
16
|
+
puts rails_path
|
16
17
|
|
17
|
-
|
18
|
-
|
18
|
+
require "rails/generators"
|
19
|
+
require "rails/generators/rails/plugin/plugin_generator"
|
20
|
+
|
21
|
+
pwd = Dir.pwd
|
22
|
+
Rails::Generators::PluginGenerator.start ['internal_test_gem']
|
23
|
+
|
24
|
+
Dir.chdir(pwd)
|
25
|
+
|
26
|
+
system("mv #{Dir.pwd}/internal_test_gem #{Dir.pwd}/.internal_test_gem")
|
27
|
+
|
28
|
+
gemspec_data = File.open(".internal_test_gem/internal_test_gem.gemspec") do |f|
|
29
|
+
f.read.gsub(/FIXME/, "DONTCARE")
|
30
|
+
.gsub(/TODO/, "DONTCARE")
|
31
|
+
.gsub(/.*homepage.*/, "")
|
32
|
+
.gsub(/.*sqlite3.*/, "")
|
33
|
+
.gsub(/.*source_code_uri.*/, "")
|
34
|
+
.gsub(/.*changelog_uri.*/, "")
|
19
35
|
end
|
20
|
-
system("mv internal_test_gem .internal_test_gem")
|
21
36
|
|
22
|
-
IO.write(".internal_test_gem/internal_test_gem.gemspec",
|
23
|
-
IO.write(".internal_test_gem/
|
24
|
-
IO.write(".internal_test_gem/internal_test_gem.gemspec", File.open(".internal_test_gem/internal_test_gem.gemspec") {|f| f.read.gsub(/.*homepage.*/, "")})
|
25
|
-
IO.write(".internal_test_gem/internal_test_gem.gemspec", File.open(".internal_test_gem/internal_test_gem.gemspec") {|f| f.read.gsub(/.*sqlite3.*/, "")})
|
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.*/, "")})
|
26
39
|
|
27
40
|
Rake::Task['engine_cart:inject_gemfile_extras'].invoke
|
28
41
|
EngineCart.within_test_app do
|
@@ -44,10 +57,7 @@ task :generate_test_gem => ['engine_cart:setup'] do
|
|
44
57
|
end
|
45
58
|
|
46
59
|
system "echo '\ngem \"rspec-rails\"\n' >> Gemfile"
|
47
|
-
|
48
|
-
system %Q{echo '\ngem "sass", "~> 3.2.15"\n' >> Gemfile}
|
49
|
-
system %Q{echo '\ngem "sprockets", "~> 2.11.0"\n' >> Gemfile}
|
50
|
-
end
|
60
|
+
|
51
61
|
Bundler.clean_system "bundle update --quiet"
|
52
62
|
system "echo 'require \"engine_cart/rake_task\"\n' >> Rakefile"
|
53
63
|
|
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
|
21
|
+
spec.add_dependency 'rails', '>= 5.0'
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
spec.add_development_dependency "rspec"
|
24
24
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'erb'
|
3
|
+
require 'shellwords'
|
3
4
|
|
4
5
|
module EngineCart
|
5
6
|
class Configuration
|
@@ -86,10 +87,11 @@ module EngineCart
|
|
86
87
|
# Split a string of options into individual options.
|
87
88
|
# @example
|
88
89
|
# parse_options('--skip-foo --skip-bar -d postgres --skip-lala')
|
89
|
-
# # => ["--skip-foo", "--skip-bar", "-d postgres", "--skip-lala"]
|
90
|
+
# # => ["--skip-foo", "--skip-bar", "-d", "postgres", "--skip-lala"]
|
90
91
|
def parse_options(options)
|
91
92
|
return if options.nil?
|
92
|
-
|
93
|
+
|
94
|
+
Shellwords.shellwords(options)
|
93
95
|
end
|
94
96
|
|
95
97
|
def read_config(config_file)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module EngineCart
|
2
2
|
def self.gemfile_stanza_check_line
|
3
|
-
|
3
|
+
'engine_cart stanza: 2.5.0'
|
4
4
|
end
|
5
5
|
|
6
6
|
def self.gemfile_stanza_text
|
@@ -27,15 +27,16 @@ module EngineCart
|
|
27
27
|
else
|
28
28
|
gem 'rails', ENV['RAILS_VERSION']
|
29
29
|
end
|
30
|
-
end
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
39
40
|
end
|
40
41
|
end
|
41
42
|
# END ENGINE_CART BLOCK
|
@@ -34,9 +34,27 @@ namespace :engine_cart do
|
|
34
34
|
require 'rails/generators'
|
35
35
|
require 'rails/generators/rails/app/app_generator'
|
36
36
|
|
37
|
+
# Clear out our current bundle so that the rails generator can run with it's own bundle
|
38
|
+
backup_gemfile = ENV['BUNDLE_GEMFILE']
|
39
|
+
ENV.delete('BUNDLE_GEMFILE')
|
40
|
+
|
37
41
|
# Using the Rails generator directly, instead of shelling out, to
|
38
42
|
# ensure we use the right version of Rails.
|
39
|
-
Rails::Generators::AppGenerator.start([
|
43
|
+
Rails::Generators::AppGenerator.start([
|
44
|
+
'internal',
|
45
|
+
'--skip-git',
|
46
|
+
'--skip-keeps',
|
47
|
+
'--skip_spring',
|
48
|
+
'--skip-bootsnap',
|
49
|
+
'--skip-listen',
|
50
|
+
'--skip-test',
|
51
|
+
*EngineCart.rails_options,
|
52
|
+
("-m #{EngineCart.template}" if EngineCart.template)
|
53
|
+
].compact)
|
54
|
+
|
55
|
+
# Restore our gemfile
|
56
|
+
ENV['BUNDLE_GEMFILE'] = backup_gemfile
|
57
|
+
|
40
58
|
end
|
41
59
|
exit 0
|
42
60
|
end
|
@@ -56,22 +74,6 @@ namespace :engine_cart do
|
|
56
74
|
text.gsub(/^gem ["']sqlite3["']$/, 'gem "sqlite3", "~> 1.3.0"')
|
57
75
|
end)
|
58
76
|
end
|
59
|
-
|
60
|
-
if Gem.loaded_specs["rails"].version.to_s < '4.2.4'
|
61
|
-
has_web_console = false
|
62
|
-
|
63
|
-
# Hack for https://github.com/rails/web-console/issues/150
|
64
|
-
gemfile = File.join(EngineCart.destination, 'Gemfile')
|
65
|
-
IO.write(gemfile, File.open(gemfile) do |f|
|
66
|
-
text = f.read
|
67
|
-
has_web_console = text.match('web-console')
|
68
|
-
text.gsub(/.*web-console.*/, "").gsub(/.*IRB console on exception pages.*/, "")
|
69
|
-
end)
|
70
|
-
|
71
|
-
File.open(gemfile, "a") do |f|
|
72
|
-
f.puts 'gem "web-console", group: :development'
|
73
|
-
end if has_web_console
|
74
|
-
end
|
75
77
|
end
|
76
78
|
end
|
77
79
|
|
@@ -85,15 +87,21 @@ namespace :engine_cart do
|
|
85
87
|
end
|
86
88
|
end
|
87
89
|
|
90
|
+
desc 'find out if the generated app needs to be rebuilt'
|
91
|
+
task :test => [:setup] do
|
92
|
+
EngineCart.debug = true
|
93
|
+
if EngineCart.fingerprint_expired?
|
94
|
+
puts "Expired!"
|
95
|
+
exit 1
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
88
99
|
desc "Create the test rails app"
|
89
100
|
task :generate => [:setup] do
|
90
101
|
if EngineCart.fingerprint_expired?
|
91
102
|
|
92
103
|
# Create a new test rails app
|
93
104
|
Rake::Task['engine_cart:create_test_rails_app'].invoke
|
94
|
-
|
95
|
-
Bundler.clean_system "bundle install --quiet"
|
96
|
-
|
97
105
|
Rake::Task['engine_cart:inject_gemfile_extras'].invoke
|
98
106
|
|
99
107
|
# Copy our test app generators into the app and prepare it
|
@@ -104,7 +112,8 @@ namespace :engine_cart do
|
|
104
112
|
within_test_app do
|
105
113
|
unless (system("bundle install --quiet") or system("bundle update --quiet")) and
|
106
114
|
system "(bundle exec rails g | grep test_app) && bundle exec rails generate test_app" and
|
107
|
-
system "bundle exec rake db:migrate
|
115
|
+
system "bundle exec rake db:migrate" and
|
116
|
+
system "bundle exec rake db:test:prepare"
|
108
117
|
raise "EngineCart failed on with: #{$?}"
|
109
118
|
end
|
110
119
|
end
|
data/lib/engine_cart/version.rb
CHANGED
data/lib/engine_cart.rb
CHANGED
@@ -25,10 +25,32 @@ module EngineCart
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.fingerprint_current?
|
28
|
-
|
28
|
+
|
29
|
+
unless File.exist? stored_fingerprint_file
|
30
|
+
STDERR.puts "No finger print file found: #{stored_fingerprint_file}" if debug?
|
31
|
+
return false
|
32
|
+
end
|
29
33
|
content = File.read(stored_fingerprint_file)
|
30
34
|
data = JSON.parse(content, symbolize_names: true)
|
31
|
-
|
35
|
+
calculated = fingerprint
|
36
|
+
|
37
|
+
return true if data == calculated
|
38
|
+
if debug?
|
39
|
+
STDERR.puts "Fingerprint mismatch:\n\n"
|
40
|
+
|
41
|
+
data.keys.each do |key|
|
42
|
+
case data[key]
|
43
|
+
when Array
|
44
|
+
data[key].zip(calculated[key]).each do |(stored, calc)|
|
45
|
+
STDERR.puts("#{key}:\nstored: #{stored}\ncalculate: #{calc}") if stored != calc
|
46
|
+
end
|
47
|
+
else
|
48
|
+
STDERR.puts("#{key}:\nstored: #{data[key]}\ncalculate: #{calculated[key]}") if data[key] != calculated[key]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
false
|
32
54
|
rescue
|
33
55
|
false
|
34
56
|
end
|
@@ -53,7 +75,7 @@ module EngineCart
|
|
53
75
|
|
54
76
|
def self.fingerprinted_files
|
55
77
|
Dir.glob("./*.gemspec").select { |f| File.file? f } +
|
56
|
-
[Bundler.default_gemfile.to_s
|
78
|
+
[Bundler.default_gemfile.to_s] +
|
57
79
|
Dir.glob("./db/migrate/*").select { |f| File.file? f } +
|
58
80
|
Dir.glob("./lib/generators/**/**").select { |f| File.file? f } +
|
59
81
|
Dir.glob("./spec/test_app_templates/**/**").select { |f| File.file? f } +
|
@@ -69,7 +91,7 @@ module EngineCart
|
|
69
91
|
end
|
70
92
|
|
71
93
|
def self.env_fingerprint
|
72
|
-
{
|
94
|
+
{ RUBY_DESCRIPTION: RUBY_DESCRIPTION, BUNDLE_GEMFILE: Bundler.default_gemfile.to_s }.reject { |k, v| v.nil? || v.empty? }
|
73
95
|
end
|
74
96
|
|
75
97
|
def self.configuration(options = {})
|
@@ -92,4 +114,12 @@ module EngineCart
|
|
92
114
|
Bundler.ui.warn EngineCart.gemfile_stanza_text
|
93
115
|
end
|
94
116
|
end
|
117
|
+
|
118
|
+
def self.debug=(debug)
|
119
|
+
@debug = debug
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.debug?
|
123
|
+
@debug
|
124
|
+
end
|
95
125
|
end
|
@@ -79,7 +79,7 @@ describe "EngineCart powered application" do
|
|
79
79
|
File.open('spec/require_spec.rb', 'w') do |f|
|
80
80
|
f.puts <<-EOF
|
81
81
|
require 'spec_helper'
|
82
|
-
require '
|
82
|
+
require 'sqlite3'
|
83
83
|
|
84
84
|
describe ApplicationController do
|
85
85
|
it "should be able to run specs that reference gems provided by the test app" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: engine_cart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '5.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
26
|
+
version: '5.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,8 +60,8 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- ".engine_cart.yml"
|
63
|
+
- ".github/workflows/ci.yml"
|
63
64
|
- ".gitignore"
|
64
|
-
- ".travis.yml"
|
65
65
|
- Gemfile
|
66
66
|
- LICENSE.txt
|
67
67
|
- README.md
|
@@ -81,7 +81,7 @@ homepage: https://github.com/cbeer/engine_cart
|
|
81
81
|
licenses:
|
82
82
|
- MIT
|
83
83
|
metadata: {}
|
84
|
-
post_install_message:
|
84
|
+
post_install_message:
|
85
85
|
rdoc_options: []
|
86
86
|
require_paths:
|
87
87
|
- lib
|
@@ -96,8 +96,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
98
|
requirements: []
|
99
|
-
rubygems_version: 3.
|
100
|
-
signing_key:
|
99
|
+
rubygems_version: 3.3.7
|
100
|
+
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: Helper for testing Rails Engines sanely
|
103
103
|
test_files:
|