engine_cart 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5f28543af73fa3b449e7c281dd0c78c246f309a8
4
- data.tar.gz: 70a199300e135a1515d7418dece040f52bcecf0a
3
+ metadata.gz: fe37849368098c72b72ec3f2c83c613e31ec89c4
4
+ data.tar.gz: cd7bfdd75e1ca203c9be2e07eb9d7e572771118d
5
5
  SHA512:
6
- metadata.gz: 97405b00fbe71928e8d86b1f5d871b03013f89956c6ae6558b6b839adb9cd60040e0b805b7ca35cb1ec3ecca733ddd71bc41adb0c03f47d64e32027fa89258d6
7
- data.tar.gz: 8e623d22dcd438356d3fa834c082a4317eef5b93c6afedc2fa4749c3cf11c38cdaa4984e2eb34dd43819387f735547cc8b90e2f3dd8e36fa1de84e11762f22e9
6
+ metadata.gz: e18c1fa840edf5b0d8f91d5e7278d5e055ff8d16808b7cccc33c14e52a0c90c3c86dc79656d2d2d0d52dac5357972eccd348535375b9768d52339effedff41e0
7
+ data.tar.gz: bbacb74b0b19c36fe0e0cf607c9f0bd819e45826ef4f3b81d35057a5cbf89b7d7baa1acb1b86c447810a2e57afa7a1e1d95bf537dd6a8606363fc57bdfd0843a
data/.gitignore CHANGED
@@ -15,4 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
- spec/internal
18
+ .internal_test_gem
data/README.md CHANGED
@@ -12,7 +12,7 @@ If you have a Rails Engine and want to test it, the suggested approach is a smal
12
12
 
13
13
  where each scenario may involve different configurations, Gemfiles, etc.
14
14
 
15
- EngineCart helps by adding Rake tasks to your Engine that builds a test application for you using Rails generators (and/or application templates).
15
+ EngineCart helps by adding Rake tasks to your Engine that builds a disposable test application for you using Rails generators (and/or application templates).
16
16
 
17
17
  ## Installation
18
18
 
@@ -30,21 +30,61 @@ Or install it yourself as:
30
30
 
31
31
  ## Usage
32
32
 
33
- Engine Cart comes with a generator to set up your engine to use Engine Cart. It is also packaged as a rake task:
33
+ ### engine_cart rake tasks
34
34
 
35
- In your Rakefile add:
35
+ To use engine_cart's rake tasks, in *your* engine's Rakefile add:
36
36
 
37
37
  ```ruby
38
38
  require 'engine_cart/rake_task'
39
39
  ```
40
40
 
41
- then you can call:
41
+ ### Set up your engine to use engine_cart
42
+
43
+ #### Run engine_cart:prepare
44
+
45
+ In order for your Rails engine gem to use engine_cart, some configuration is required. There is an EngineCart generator to do this; it is also packaged as a rake task.
42
46
 
43
47
  ```
44
48
  $ rake engine_cart:prepare
45
49
  ```
46
50
 
47
- In your Rakefile you can generate the Rails application using, e.g.:
51
+ This will create `lib/generators/test_app_generator.rb` in your engine and it will also append some code to your engine's `Gemfile`.
52
+
53
+ You only need to run this rake task once.
54
+
55
+ #### Adjust your engine's generators
56
+
57
+ EngineCart is configured so it will run the test app generator (located in `./spec/test_app_templates/lib/generators`) immediately after generating a testing rails app. By default, it will attempt to run the `install` generator for your engine. If you do not have an `install` generator, or want to add additional steps (e.g. to install additional gems), you can add them to the `TestAppGenerator`.
58
+
59
+
60
+ ### Generate the testing Rails application
61
+
62
+ You can generate a Rails testing application for your engine with a rake task:
63
+
64
+ ```
65
+ $ rake engine_cart:generate
66
+ ```
67
+
68
+ This creates a new Rails app containing your engine at .internal_test_app by running generators.
69
+
70
+ You can start the testing app, interact with it, etc:
71
+
72
+ ```
73
+ $ bundle exec rake engine_cart:server
74
+
75
+ # or with arguments
76
+ $ bundle exec rake engine_cart:server["-p 3001 -e production"]
77
+ ```
78
+
79
+ The testing app starts at [http://localhost:3000](http://localhost:3000), just like any Rails app.
80
+
81
+ If you need to perform additional debugging tasks, you can find the internal test application in the `.internal_test_app` directory. From there, you can do normal Rails things, like:
82
+ * run rake tasks
83
+ * run rails console
84
+
85
+ ### Running Tests using the Rails application
86
+
87
+ The easiest way to do this is via a rake task. In your engine's Rakefile:
48
88
 
49
89
  ```ruby
50
90
  require 'engine_cart/rake_task'
@@ -54,28 +94,81 @@ task :ci => ['engine_cart:generate'] do
54
94
  end
55
95
  ```
56
96
 
57
- And in your e.g. spec\_helper.rb (or rails\_helper.rb), initialize EngineCart:
97
+ And in your engine's test framework configuration (e.g. `spec_helper.rb` or `rails_helper.rb`), initialize EngineCart:
98
+
99
+ ```ruby
100
+ require 'engine_cart'
101
+ EngineCart.load_application!
102
+ ```
103
+
104
+ Your test files (e.g. spec files for your engine) can now be written as tests for a Rails application.
105
+
106
+ ## Cleaning out or refreshing testing application
107
+
108
+ The EngineCart test application is meant to be disposable and easily rebuildable.
109
+
110
+ ### Automatic detection of when to rebuild test application
111
+
112
+ In some cases, EngineCart can automatically detect and rebuild the test application when key files change. By default, the application will be rebuilt when your `Gemfile` or `Gemfile.lock` changes.
113
+
114
+ It can also track changes to your engine's db migrations and generators with a fingerprint mechanism. To use this, add the line below to your rake testing task:
115
+
116
+ ```ruby
117
+ EngineCart.fingerprint_proc = EngineCart.rails_fingerprint_proc
118
+ ```
119
+
120
+ For example, in your engine's Rakefile:
58
121
 
59
122
  ```ruby
60
- require 'engine_cart'
61
- EngineCart.load_application!
123
+ require 'engine_cart/rake_task'
124
+
125
+ task :ci do
126
+ EngineCart.fingerprint_proc = EngineCart.rails_fingerprint_proc
127
+ Rake::Task['engine_cart:generate'].invoke
128
+ # run the tests
129
+ end
130
+ ```
131
+
132
+ ### Rake tasks for rebuilding test application
133
+
134
+ You can also manually clean out and rebuild the test application. Run these rake tasks from the top level directory, not from the test application directory.
135
+
136
+ To clean out the testing app:
137
+
138
+ ```
139
+ $ rake engine_cart:clean
62
140
  ```
63
141
 
64
- When you want to clean out and regenerate the test application, you can call:
142
+ Or, if you wish to start over immediately with a pristine testing application, the following will clean out the testing app and generate it anew:
65
143
 
66
144
  ```
67
145
  $ rake engine_cart:regenerate
68
146
  ```
69
147
 
148
+ ### Brute force when all else fails
149
+
150
+ If you have generated a test application, there is a `Gemfile` and `Gemfile.lock` associated with the testing app at `.internal_test_app` (or wherever you designated as the test app location). If you then update *your* engine's `Gemfile` or `.gemspec`, Bundler can get confused if it has conflicting information between your engine and the testing app.
151
+
152
+ To fix this:
153
+
154
+ 1. Clean out your testing app: `$ bundle exec rake engine_cart:clean` or `$ rm -rf .internal_test_app`
155
+ 2. Remove your engine's Gemfile.lock: `$ rm Gemfile.lock` (not always necessary)
156
+ 3. Allow Bundler to resolve gem dependencies again: `$ bundle install`
157
+ 4. Rebuild the test application: `$ bundle exec rake engine_cart:generate`
158
+
70
159
  ## Configuration
71
160
 
161
+ ### Location of Rails testing app
162
+
72
163
  You can configure where the test app is created by setting the `ENGINE_CART_DESTINATION` env variable, e.g.:
73
164
 
74
- ```ruby
75
- ENGINE_CART_DESTINATION="/tmp/generate-the-test-app-into-tmp-instead-of-your-app" rake ci
76
165
  ```
166
+ ENGINE_CART_DESTINATION="/tmp/my_engines_test_app_here" rake engine_cart:generate
167
+ ```
168
+
169
+ ### Adjusting generators for Rails testing app
77
170
 
78
- After creating the test application, Engine Cart will run the test app generator (located in ./spec/test_app_templates/lib/generators). By default, it will attempt to run the `install` generator for your engine. If you do not have an `install` generator, or want to add additional steps (e.g. to install additional gems), you can add them to the `TestAppGenerator`.
171
+ After creating the test application, EngineCart will run the test app generator (located in `./spec/test_app_templates/lib/generators`). By default, it will attempt to run the `install` generator for your engine. If you do not have an `install` generator, or want to add additional steps (e.g. to install additional gems), you can add them to the `TestAppGenerator`.
79
172
 
80
173
  ## Contributing
81
174
 
@@ -83,4 +176,4 @@ After creating the test application, Engine Cart will run the test app generator
83
176
  2. Create your feature branch (`git checkout -b my-new-feature`)
84
177
  3. Commit your changes (`git commit -am 'Add some feature'`)
85
178
  4. Push to the branch (`git push origin my-new-feature`)
86
- 5. Create new Pull Request
179
+ 5. Create a [Pull Request](https://help.github.com/articles/using-pull-requests/)
data/Rakefile CHANGED
@@ -9,22 +9,22 @@ task :ci => ['generate_test_gem', 'spec'] do
9
9
  end
10
10
 
11
11
  task :generate_test_gem => ['engine_cart:setup'] do
12
- system("rm -rf spec/internal")
12
+ system("rm -rf .internal_test_gem")
13
13
  gem 'rails'
14
14
 
15
- version = if Gem.loaded_specs["rails"]
16
- "_#{Gem.loaded_specs["rails"].version}_"
17
- end
15
+ rails_path = Gem.bin_path('railties', 'rails')
18
16
 
19
17
  Bundler.with_clean_env do
20
- system("rails #{version} plugin new spec/internal_gem")
18
+ system("#{rails_path} plugin new internal_test_gem")
21
19
  end
20
+ system("mv internal_test_gem .internal_test_gem")
22
21
 
23
- IO.write("spec/internal_gem/internal_gem.gemspec", File.open("spec/internal_gem/internal_gem.gemspec") {|f| f.read.gsub(/FIXME/, "DONTCARE")})
24
- IO.write("spec/internal_gem/internal_gem.gemspec", File.open("spec/internal_gem/internal_gem.gemspec") {|f| f.read.gsub(/TODO/, "DONTCARE")})
25
- IO.write("spec/internal_gem/internal_gem.gemspec", File.open("spec/internal_gem/internal_gem.gemspec") {|f| f.read.gsub(/.*homepage.*/, "")})
22
+ IO.write(".internal_test_gem/internal_test_gem.gemspec", File.open(".internal_test_gem/internal_test_gem.gemspec") {|f| f.read.gsub(/FIXME/, "DONTCARE")})
23
+ IO.write(".internal_test_gem/internal_test_gem.gemspec", File.open(".internal_test_gem/internal_test_gem.gemspec") {|f| f.read.gsub(/TODO/, "DONTCARE")})
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
+
26
+ EngineCart.destination = '.internal_test_gem'
26
27
 
27
- system("mv spec/internal_gem spec/internal")
28
28
  Rake::Task['engine_cart:inject_gemfile_extras'].invoke
29
29
  EngineCart.within_test_app do
30
30
  system "git init"
@@ -38,7 +38,7 @@ task :generate_test_gem => ['engine_cart:setup'] do
38
38
  require 'rspec/rails'
39
39
  require 'rspec/autorun'
40
40
 
41
- require 'internal_gem'
41
+ require 'internal_test_gem'
42
42
  RSpec.configure do |config|
43
43
 
44
44
  end
@@ -48,11 +48,11 @@ task :generate_test_gem => ['engine_cart:setup'] do
48
48
  system "echo '\ngem \"rspec-rails\"\n' >> Gemfile"
49
49
  system %Q{echo '\ngem "sass", "~> 3.2.15"\n' >> Gemfile}
50
50
  system %Q{echo '\ngem "sprockets", "~> 2.11.0"\n' >> Gemfile}
51
- system "bundle update"
51
+ Bundler.clean_system "bundle update --quiet"
52
52
  system "echo 'require \"engine_cart/rake_task\"\n' >> Rakefile"
53
53
 
54
- system("rake engine_cart:prepare")
55
- system "bundle install"
54
+ system("bundle exec rake engine_cart:prepare")
55
+ Bundler.clean_system "bundle install --quiet"
56
56
  end
57
57
  end
58
58
 
data/engine_cart.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "rails"
22
- spec.add_dependency "bundler", "~> 1.3"
22
+ spec.add_dependency "bundler", "~> 1.5"
23
23
  spec.add_development_dependency "rake"
24
24
  spec.add_development_dependency "rspec"
25
25
  end
data/lib/engine_cart.rb CHANGED
@@ -1,39 +1,10 @@
1
1
  require "engine_cart/version"
2
+ require 'engine_cart/gemfile_stanza'
3
+ require 'bundler'
2
4
 
3
5
  module EngineCart
4
6
  require "engine_cart/engine" if defined? Rails
5
-
6
- class << self
7
-
8
- ##
9
- # Name of the engine we're testing
10
- attr_accessor :engine_name
11
-
12
- ##
13
- # Destination to generate the test app into
14
- attr_accessor :destination
15
-
16
- ##
17
- # Path to a Rails application template
18
- attr_accessor :template
19
-
20
- ##
21
- # Path to test app templates to make available to
22
- # the test app generator
23
- attr_accessor :templates_path
24
-
25
-
26
- ##
27
- # Additional options when generating a test rails application
28
- attr_accessor :rails_options
29
-
30
- end
31
-
32
- self.engine_name = ENV["CURRENT_ENGINE_NAME"]
33
- self.destination = ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || "./spec/internal"
34
- self.template = ENV["ENGINE_CART_TEMPLATE"]
35
- self.templates_path = ENV['ENGINE_CART_TEMPLATES_PATH'] || "./spec/test_app_templates"
36
- self.rails_options = ENV['ENGINE_CART_RAILS_OPTIONS']
7
+ require 'engine_cart/params'
37
8
 
38
9
  def self.current_engine_name
39
10
  engine_name || File.basename(Dir.glob("*.gemspec").first, '.gemspec')
@@ -65,11 +36,24 @@ module EngineCart
65
36
 
66
37
  def self.rails_fingerprint_proc extra_files = []
67
38
  lambda do
68
- (Dir.glob("./*.gemspec") + Dir.glob("./Gemfile*") + Dir.glob("./db/migrate/*") + Dir.glob("./lib/generators/**/**") + Dir.glob("./spec/test_app_templates/**/**") + extra_files).map {|f| File.mtime(f) }.max.to_s
39
+ EngineCart.default_fingerprint + (Dir.glob("./db/migrate/*") + Dir.glob("./lib/generators/**/**") + Dir.glob("./spec/test_app_templates/**/**") + extra_files).map {|f| File.mtime(f) }.max.to_s
69
40
  end
70
41
  end
71
42
 
72
43
  def self.default_fingerprint
73
- ""
44
+ EngineCart.env_fingerprint + (Dir.glob("./*.gemspec") + [Bundler.default_gemfile.to_s, Bundler.default_lockfile.to_s]).map {|f| File.mtime(f) }.max.to_s
45
+ end
46
+
47
+ def self.env_fingerprint
48
+ { 'RUBY_DESCRIPTION' => RUBY_DESCRIPTION, 'BUNDLE_GEMFILE' => Bundler.default_gemfile.to_s }.reject { |k, v| v.nil? || v.empty? }.to_s
49
+ end
50
+
51
+ def self.check_for_gemfile_stanza
52
+ return unless File.exist? 'Gemfile'
53
+
54
+ unless File.readlines('Gemfile').grep(/#{EngineCart.gemfile_stanza_check_line}/).any?
55
+ Bundler.ui.warn "[EngineCart] For better results, consider updating the EngineCart stanza in your Gemfile with:\n\n"
56
+ Bundler.ui.warn EngineCart.gemfile_stanza_text
57
+ end
74
58
  end
75
59
  end
@@ -0,0 +1,37 @@
1
+ require 'engine_cart/params'
2
+
3
+ module EngineCart
4
+ def self.gemfile_stanza_check_line
5
+ "engine_cart stanza: 0.8.0"
6
+ end
7
+
8
+ def self.gemfile_stanza_text
9
+ <<-EOF.gsub(/^ /, '')
10
+ # BEGIN ENGINE_CART BLOCK
11
+ # engine_cart: #{EngineCart::VERSION}
12
+ # #{EngineCart.gemfile_stanza_check_line}
13
+ # the below comes from engine_cart, a gem used to test this Rails engine gem in the context of a Rails app.
14
+ file = File.expand_path("Gemfile", ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || File.expand_path("#{EngineCart.destination}", File.dirname(__FILE__)))
15
+ if File.exist?(file)
16
+ begin
17
+ eval_gemfile file
18
+ rescue Bundler::GemfileError => e
19
+ Bundler.ui.warn '[EngineCart] Skipping Rails application dependencies:'
20
+ Bundler.ui.warn e.message
21
+ end
22
+ else
23
+ Bundler.ui.warn "[EngineCart] Unable to find test application dependencies in \#{file}, using placeholder dependencies"
24
+
25
+ gem 'rails', ENV['RAILS_VERSION'] if ENV['RAILS_VERSION']
26
+
27
+ if ENV['RAILS_VERSION'].nil? || ENV['RAILS_VERSION'] =~ /^4.2/
28
+ gem 'responders', "~> 2.0"
29
+ gem 'sass-rails', ">= 5.0"
30
+ else
31
+ gem 'sass-rails', "< 5.0"
32
+ end
33
+ end
34
+ # END ENGINE_CART BLOCK
35
+ EOF
36
+ end
37
+ end
@@ -0,0 +1,38 @@
1
+ module EngineCart
2
+ class << self
3
+
4
+ ##
5
+ # Name of the engine we're testing
6
+ attr_accessor :engine_name
7
+
8
+ ##
9
+ # Destination to generate the test app into
10
+ attr_accessor :destination
11
+
12
+ ##
13
+ # Path to a Rails application template
14
+ attr_accessor :template
15
+
16
+ ##
17
+ # Path to test app templates to make available to
18
+ # the test app generator
19
+ attr_accessor :templates_path
20
+
21
+
22
+ ##
23
+ # Additional options when generating a test rails application
24
+ attr_accessor :rails_options
25
+
26
+ end
27
+
28
+ self.engine_name = ENV["CURRENT_ENGINE_NAME"]
29
+
30
+ def self.default_destination
31
+ ('.internal_test_app' if File.exist? '.internal_test_app') || ('spec/internal' if File.exist? 'spec/internal') || '.internal_test_app'
32
+ end
33
+
34
+ self.destination = ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || default_destination
35
+ self.template = ENV["ENGINE_CART_TEMPLATE"]
36
+ self.templates_path = ENV['ENGINE_CART_TEMPLATES_PATH'] || "./spec/test_app_templates"
37
+ self.rails_options = ENV['ENGINE_CART_RAILS_OPTIONS']
38
+ end
@@ -12,6 +12,7 @@ namespace :engine_cart do
12
12
  end
13
13
 
14
14
  task :setup do
15
+ EngineCart.check_for_gemfile_stanza
15
16
  end
16
17
 
17
18
  desc 'Regenerate the test rails app'
@@ -28,12 +29,10 @@ namespace :engine_cart do
28
29
  require 'fileutils'
29
30
  Dir.mktmpdir do |dir|
30
31
  Dir.chdir dir do
31
- version = if Gem.loaded_specs["rails"]
32
- "_#{Gem.loaded_specs["rails"].version}_"
33
- end
32
+ rails_path = Gem.bin_path('railties', 'rails')
34
33
 
35
34
  Bundler.with_clean_env do
36
- `rails #{version} new internal --skip-spring #{EngineCart.rails_options} #{"-m #{EngineCart.template}" if EngineCart.template}`
35
+ `#{rails_path} new internal --skip-spring #{EngineCart.rails_options} #{"-m #{EngineCart.template}" if EngineCart.template}`
37
36
  end
38
37
 
39
38
  unless $?
@@ -48,13 +47,14 @@ namespace :engine_cart do
48
47
  has_web_console = false
49
48
 
50
49
  # Hack for https://github.com/rails/web-console/issues/150
51
- IO.write("spec/internal/Gemfile", File.open("spec/internal/Gemfile") do |f|
50
+ gemfile = File.join(EngineCart.destination, 'Gemfile')
51
+ IO.write(gemfile, File.open(gemfile) do |f|
52
52
  text = f.read
53
53
  has_web_console = text.match('web-console')
54
54
  text.gsub(/.*web-console.*/, "").gsub(/.*IRB console on exception pages.*/, "")
55
55
  end)
56
56
 
57
- File.open("spec/internal/Gemfile", "a") do |f|
57
+ File.open(gemfile, "a") do |f|
58
58
  f.puts 'gem "web-console", group: :development'
59
59
  end if has_web_console
60
60
  end
@@ -84,28 +84,42 @@ EOF
84
84
  # Create a new test rails app
85
85
  Rake::Task['engine_cart:create_test_rails_app'].invoke
86
86
 
87
- system "bundle install"
87
+ Bundler.clean_system "bundle install --quiet"
88
88
 
89
89
  Rake::Task['engine_cart:inject_gemfile_extras'].invoke
90
90
 
91
91
  # Copy our test app generators into the app and prepare it
92
92
  if File.exist? "#{EngineCart.templates_path}/lib/generators"
93
- system "cp -r #{EngineCart.templates_path}/lib/generators #{EngineCart.destination}/lib"
93
+ Bundler.clean_system "cp -r #{EngineCart.templates_path}/lib/generators #{EngineCart.destination}/lib"
94
94
  end
95
95
 
96
96
  within_test_app do
97
- system "bundle install"
98
- system "(rails g | grep test_app) && rails generate test_app"
99
- system "rake db:migrate db:test:prepare"
97
+ system "bundle install --quiet"
98
+ system "(bundle exec rails g | grep test_app) && bundle exec rails generate test_app"
99
+ system "bundle exec rake db:migrate db:test:prepare"
100
100
  end
101
101
 
102
- system "bundle install"
102
+ Bundler.clean_system "bundle install --quiet"
103
103
 
104
104
  File.open(File.expand_path('.generated_engine_cart', EngineCart.destination), 'w') { |f| f.write(original_fingerprint || EngineCart.fingerprint) }
105
105
 
106
106
  puts "Done generating test app"
107
107
  end
108
108
  end
109
+
110
+ desc 'Start the internal test application using `rails server`'
111
+ task :server, [:rails_server_args] => [:generate] do |_, args|
112
+ within_test_app do
113
+ system "bundle exec rails server #{args[:rails_server_args]}"
114
+ end
115
+ end
116
+
117
+ desc 'Start the internal test application using `rails console`'
118
+ task :console, [:rails_console_args] => [:generate] do |_, args|
119
+ within_test_app do
120
+ system "bundle exec rails console #{args[:rails_console_args]}"
121
+ end
122
+ end
109
123
  end
110
124
 
111
125
  def within_test_app
@@ -1,3 +1,3 @@
1
1
  module EngineCart
2
- VERSION = '0.7.1'
2
+ VERSION = '0.8.0'
3
3
  end
@@ -1,4 +1,6 @@
1
1
  require 'rails/generators'
2
+ require 'engine_cart/version'
3
+ require 'engine_cart/gemfile_stanza'
2
4
 
3
5
  ##
4
6
  # EngineCartGenerator sets up an engine to
@@ -47,25 +49,7 @@ module EngineCart
47
49
 
48
50
  def add_gemfile_include
49
51
  append_file "Gemfile" do
50
- <<-EOF
51
-
52
- # the below comes from engine_cart, a gem used to test this Rails engine gem in the context of a Rails app
53
- file = File.expand_path("Gemfile", ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || File.expand_path("../spec/internal", __FILE__))
54
- if File.exist?(file)
55
- puts "Loading \#{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
56
- instance_eval File.read(file)
57
- else
58
- # we get here when we haven't yet generated the testing app via engine_cart
59
- gem 'rails', ENV['RAILS_VERSION'] if ENV['RAILS_VERSION']
60
-
61
- if ENV['RAILS_VERSION'] && ENV['RAILS_VERSION'] =~ /^4.2/
62
- gem 'responders', "~> 2.0"
63
- gem 'sass-rails', ">= 5.0"
64
- else
65
- gem 'sass-rails', "< 5.0"
66
- end
67
- end
68
- EOF
52
+ EngineCart.gemfile_stanza_text
69
53
  end
70
54
  end
71
55
  end
@@ -1,14 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "EngineCart powered application" do
4
- TEST_APP = File.expand_path("../internal", File.dirname(__FILE__))
4
+ EngineCart.destination = File.expand_path("../../.internal_test_gem", File.dirname(__FILE__))
5
+
5
6
  it "should have the test_app_templates pre-generated" do
6
- expect(File).to exist File.expand_path("spec/test_app_templates", TEST_APP)
7
+ expect(File).to exist File.expand_path("spec/test_app_templates", EngineCart.destination)
7
8
  end
8
9
 
9
10
  it "should ignore the test app" do
10
- git_ignore = File.expand_path(".gitignore", TEST_APP)
11
- expect(File.read(git_ignore)).to match /spec\/internal/
11
+ git_ignore = File.expand_path(".gitignore", EngineCart.destination)
12
+ expect(File.read(git_ignore)).to match /.internal_test_app/
12
13
  end
13
14
 
14
15
  it "should have a engine_cart:generate rake task available" do
@@ -28,27 +29,27 @@ describe "EngineCart powered application" do
28
29
  it "should create a rails app when the engine_cart:generate task is invoked" do
29
30
  EngineCart.within_test_app do
30
31
  `rake engine_cart:generate`
31
- expect(File).to exist(File.expand_path(EngineCart.destination))
32
+ expect(File).to exist(File.expand_path('.internal_test_app'))
32
33
  end
33
34
  end
34
35
 
35
36
  it "should not recreate an existing rails app when the engine_cart:generate task is reinvoked" do
36
37
  EngineCart.within_test_app do
37
38
  `rake engine_cart:generate`
38
- expect(File).to exist(File.expand_path(EngineCart.destination))
39
- FileUtils.touch File.join(EngineCart.destination, ".this_should_still_exist")
39
+ expect(File).to exist(File.expand_path('.internal_test_app'))
40
+ FileUtils.touch File.join('.internal_test_app', ".this_should_still_exist")
40
41
  `rake engine_cart:generate`
41
- expect(File).to exist(File.expand_path(File.join(EngineCart.destination, ".this_should_still_exist")))
42
+ expect(File).to exist(File.expand_path(File.join('.internal_test_app', ".this_should_still_exist")))
42
43
  end
43
44
  end
44
45
 
45
46
  it "should create a rails app when the fingerprint argument is changed" do
46
47
  EngineCart.within_test_app do
47
48
  `rake engine_cart:generate[this-fingerprint]`
48
- expect(File).to exist(File.expand_path(EngineCart.destination))
49
- FileUtils.touch File.join(EngineCart.destination, ".this_should_not_exist")
49
+ expect(File).to exist(File.expand_path('.internal_test_app'))
50
+ FileUtils.touch File.join('.internal_test_app', ".this_should_not_exist")
50
51
  `rake engine_cart:generate[that-fingerprint]`
51
- expect(File).to_not exist(File.expand_path(File.join(EngineCart.destination, ".this_should_not_exist")))
52
+ expect(File).to_not exist(File.expand_path(File.join('.internal_test_app', ".this_should_not_exist")))
52
53
  end
53
54
  end
54
55
 
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: engine_cart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.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: 2015-09-10 00:00:00.000000000 Z
11
+ date: 2015-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ name: rails
14
15
  requirement: !ruby/object:Gem::Requirement
15
16
  requirements:
16
- - - '>='
17
+ - - ">="
17
18
  - !ruby/object:Gem::Version
18
19
  version: '0'
19
- name: rails
20
- prerelease: false
21
20
  type: :runtime
21
+ prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
+ name: bundler
28
29
  requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ~>
31
+ - - "~>"
31
32
  - !ruby/object:Gem::Version
32
- version: '1.3'
33
- name: bundler
34
- prerelease: false
33
+ version: '1.5'
35
34
  type: :runtime
35
+ prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.3'
40
+ version: '1.5'
41
41
  - !ruby/object:Gem::Dependency
42
+ name: rake
42
43
  requirement: !ruby/object:Gem::Requirement
43
44
  requirements:
44
- - - '>='
45
+ - - ">="
45
46
  - !ruby/object:Gem::Version
46
47
  version: '0'
47
- name: rake
48
- prerelease: false
49
48
  type: :development
49
+ prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
+ name: rspec
56
57
  requirement: !ruby/object:Gem::Requirement
57
58
  requirements:
58
- - - '>='
59
+ - - ">="
59
60
  - !ruby/object:Gem::Version
60
61
  version: '0'
61
- name: rspec
62
- prerelease: false
63
62
  type: :development
63
+ prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: Helper for testing Rails Engines sanely
@@ -73,8 +73,8 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - .gitignore
77
- - .travis.yml
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
78
  - Gemfile
79
79
  - LICENSE.txt
80
80
  - README.md
@@ -82,6 +82,8 @@ files:
82
82
  - engine_cart.gemspec
83
83
  - lib/engine_cart.rb
84
84
  - lib/engine_cart/engine.rb
85
+ - lib/engine_cart/gemfile_stanza.rb
86
+ - lib/engine_cart/params.rb
85
87
  - lib/engine_cart/rake_task.rb
86
88
  - lib/engine_cart/tasks/engine_cart.rake
87
89
  - lib/engine_cart/version.rb
@@ -92,24 +94,24 @@ homepage: https://github.com/cbeer/engine_cart
92
94
  licenses:
93
95
  - MIT
94
96
  metadata: {}
95
- post_install_message:
97
+ post_install_message:
96
98
  rdoc_options: []
97
99
  require_paths:
98
100
  - lib
99
101
  required_ruby_version: !ruby/object:Gem::Requirement
100
102
  requirements:
101
- - - '>='
103
+ - - ">="
102
104
  - !ruby/object:Gem::Version
103
105
  version: '0'
104
106
  required_rubygems_version: !ruby/object:Gem::Requirement
105
107
  requirements:
106
- - - '>='
108
+ - - ">="
107
109
  - !ruby/object:Gem::Version
108
110
  version: '0'
109
111
  requirements: []
110
- rubyforge_project:
111
- rubygems_version: 2.4.6
112
- signing_key:
112
+ rubyforge_project:
113
+ rubygems_version: 2.4.8
114
+ signing_key:
113
115
  specification_version: 4
114
116
  summary: Helper for testing Rails Engines sanely
115
117
  test_files: