engine_cart 0.4.1 → 0.5.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/.travis.yml +5 -0
- data/README.md +9 -5
- data/engine_cart.gemspec +1 -2
- data/lib/engine_cart.rb +16 -0
- data/lib/engine_cart/tasks/engine_cart.rake +11 -4
- data/lib/engine_cart/version.rb +1 -1
- data/spec/integration/engine_cart_spec.rb +29 -2
- data/spec/spec_helper.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9116ecd712cb9e6d990cdead35c846d1403020cf
|
4
|
+
data.tar.gz: 02611f17a1b7b6ef5fca1fe551fc228e7b7af1a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3870e1555e4435b791c061f6b4dabf80670e054f40b215f5ce7e2914bd411c451522709d6f30060fcc5dd1192e6db57251a13d6a197a29cec1a6c59ddadf221
|
7
|
+
data.tar.gz: 2d6118ce6b1cc2403247aee0ef73ab96d87f3b2be05e454c35484ce49e6548c4ca5ebf6c29837f3de317ee237b55bc44f4cc1e8e45e7441ef40bdd8c7470b6a4
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -8,10 +8,9 @@ If you have a Rails Engine and want to test it, the suggested approach is a smal
|
|
8
8
|
- different versions of Rails (Rails 3.x, 4.0 and 4.1)
|
9
9
|
- different deployment environments (with and without devise, etc)
|
10
10
|
|
11
|
-
where each scenario may involve different configurations, Gemfiles, etc.
|
12
|
-
|
13
|
-
EngineCart helps by adding Rake tasks to your Engine that builds a test application for you using Rails generators (and/or application templates).
|
11
|
+
where each scenario may involve different configurations, Gemfiles, etc.
|
14
12
|
|
13
|
+
EngineCart helps by adding Rake tasks to your Engine that builds a test application for you using Rails generators (and/or application templates).
|
15
14
|
|
16
15
|
## Installation
|
17
16
|
|
@@ -37,7 +36,7 @@ In your Rakefile add:
|
|
37
36
|
require 'engine_cart/rake_task'
|
38
37
|
```
|
39
38
|
|
40
|
-
then you can call:
|
39
|
+
then you can call:
|
41
40
|
|
42
41
|
```
|
43
42
|
$ rake engine_cart:prepare
|
@@ -60,6 +59,12 @@ And in your e.g. spec\_helper.rb (or rails\_helper.rb), initialize EngineCart:
|
|
60
59
|
EngineCart.load_application!
|
61
60
|
```
|
62
61
|
|
62
|
+
When you want to clean out and regenerate the test application, you can call:
|
63
|
+
|
64
|
+
```
|
65
|
+
$ rake engine_cart:regenerate
|
66
|
+
```
|
67
|
+
|
63
68
|
## Configuration
|
64
69
|
|
65
70
|
You can configure where the test app is created by setting the `ENGINE_CART_DESTINATION` env variable, e.g.:
|
@@ -70,7 +75,6 @@ ENGINE_CART_DESTINATION="/tmp/generate-the-test-app-into-tmp-instead-of-your-app
|
|
70
75
|
|
71
76
|
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`.
|
72
77
|
|
73
|
-
|
74
78
|
## Contributing
|
75
79
|
|
76
80
|
1. Fork it
|
data/engine_cart.gemspec
CHANGED
@@ -19,8 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency "rails"
|
22
|
-
|
23
|
-
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_dependency "bundler", "~> 1.3"
|
24
23
|
spec.add_development_dependency "rake"
|
25
24
|
spec.add_development_dependency "rspec"
|
26
25
|
end
|
data/lib/engine_cart.rb
CHANGED
@@ -50,4 +50,20 @@ module EngineCart
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
53
|
+
|
54
|
+
def self.fingerprint
|
55
|
+
@fingerprint || (@fingerprint_proc || method(:default_fingerprint)).call
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.fingerprint= fingerprint
|
59
|
+
@fingerprint = fingerprint
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.fingerprint_proc= fingerprint_proc
|
63
|
+
@fingerprint_proc = fingerprint_proc
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.default_fingerprint
|
67
|
+
""
|
68
|
+
end
|
53
69
|
end
|
@@ -14,6 +14,9 @@ namespace :engine_cart do
|
|
14
14
|
task :setup do
|
15
15
|
end
|
16
16
|
|
17
|
+
desc 'Regenerate the test rails app'
|
18
|
+
task :regenerate => [:clean, :generate]
|
19
|
+
|
17
20
|
desc "Clean out the test rails app"
|
18
21
|
task :clean => [:setup] do
|
19
22
|
puts "Removing sample rails app"
|
@@ -37,7 +40,8 @@ namespace :engine_cart do
|
|
37
40
|
raise "Error generating new rails app. Aborting."
|
38
41
|
end
|
39
42
|
end
|
40
|
-
|
43
|
+
|
44
|
+
Rake::Task['engine_cart:clean'].invoke if File.exists? EngineCart.destination
|
41
45
|
FileUtils.move "#{dir}/internal", "#{EngineCart.destination}"
|
42
46
|
|
43
47
|
end
|
@@ -56,8 +60,11 @@ EOF
|
|
56
60
|
end
|
57
61
|
|
58
62
|
desc "Create the test rails app"
|
59
|
-
task :generate => [:setup] do
|
60
|
-
|
63
|
+
task :generate, [:fingerprint] => [:setup] do |t, args|
|
64
|
+
args.with_defaults(:fingerprint => EngineCart.fingerprint) unless args[:fingerprint]
|
65
|
+
|
66
|
+
f = File.expand_path('.generated_engine_cart', EngineCart.destination)
|
67
|
+
unless File.exists? f and File.read(f) == args[:fingerprint]
|
61
68
|
|
62
69
|
# Create a new test rails app
|
63
70
|
Rake::Task['engine_cart:create_test_rails_app'].invoke
|
@@ -77,7 +84,7 @@ EOF
|
|
77
84
|
system "rake db:migrate db:test:prepare"
|
78
85
|
end
|
79
86
|
|
80
|
-
File.open(File.expand_path('.generated_engine_cart', EngineCart.destination), 'w') { |f| f.
|
87
|
+
File.open(File.expand_path('.generated_engine_cart', EngineCart.destination), 'w') { |f| f.write args[:fingerprint] }
|
81
88
|
|
82
89
|
puts "Done generating test app"
|
83
90
|
end
|
data/lib/engine_cart/version.rb
CHANGED
@@ -18,15 +18,42 @@ describe "EngineCart powered application" do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
it "should
|
21
|
+
it "should have a engine_cart:regenerate rake task available" do
|
22
|
+
EngineCart.within_test_app do
|
23
|
+
`rake -T | grep "engine_cart:regenerate"`
|
24
|
+
expect($?).to eq 0
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should create a rails app when the engine_cart:generate task is invoked" do
|
22
29
|
EngineCart.within_test_app do
|
23
30
|
`rake engine_cart:generate`
|
24
31
|
expect(File).to exist(File.expand_path("spec/internal"))
|
25
32
|
end
|
26
33
|
end
|
27
34
|
|
35
|
+
it "should not recreate an existing rails app when the engine_cart:generate task is reinvoked" do
|
36
|
+
EngineCart.within_test_app do
|
37
|
+
`rake engine_cart:generate`
|
38
|
+
expect(File).to exist(File.expand_path("spec/internal"))
|
39
|
+
FileUtils.touch "spec/internal/.this_should_still_exist"
|
40
|
+
`rake engine_cart:generate`
|
41
|
+
expect(File).to exist(File.expand_path("spec/internal/.this_should_still_exist"))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should create a rails app when the fingerprint argument is changed" do
|
46
|
+
EngineCart.within_test_app do
|
47
|
+
`rake engine_cart:generate[this-fingerprint]`
|
48
|
+
expect(File).to exist(File.expand_path("spec/internal"))
|
49
|
+
FileUtils.touch "spec/internal/.this_should_not_exist"
|
50
|
+
`rake engine_cart:generate[that-fingerprint]`
|
51
|
+
expect(File).to_not exist(File.expand_path("spec/internal/.this_should_not_exist"))
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
28
55
|
it "should be able to test the application controller from the internal app" do
|
29
|
-
EngineCart.within_test_app do
|
56
|
+
EngineCart.within_test_app do
|
30
57
|
File.open('spec/some_spec.rb', 'w') do |f|
|
31
58
|
f.puts <<-EOF
|
32
59
|
require 'spec_helper'
|
data/spec/spec_helper.rb
CHANGED
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: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.3'
|
34
|
-
type: :
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
@@ -74,6 +74,7 @@ extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
76
|
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
77
78
|
- Gemfile
|
78
79
|
- LICENSE.txt
|
79
80
|
- README.md
|