engine_cart 0.4.1 → 0.5.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: 3b4c343f882f6a39250e8904c87795aa8c88d400
4
- data.tar.gz: 47301fcca406dc70759b1ed72c00bb1e7f80e6d0
3
+ metadata.gz: 9116ecd712cb9e6d990cdead35c846d1403020cf
4
+ data.tar.gz: 02611f17a1b7b6ef5fca1fe551fc228e7b7af1a3
5
5
  SHA512:
6
- metadata.gz: 18fed66978a246772fcf0854f3f362bc018c4a8e8a627b9319972e85be8115f315ee56aa138bc6a26d9e4ab27af3c9125258d27d5da83eeedac7e0158d275981
7
- data.tar.gz: 23813481ca32e16802b25024f66b9f76110768e2b0a526157e67a24d2230ec96ba6cbcff20a50a4b106d97bc9bc1a924e51a82b288b67bf8c05c42f53a8ad361
6
+ metadata.gz: a3870e1555e4435b791c061f6b4dabf80670e054f40b215f5ce7e2914bd411c451522709d6f30060fcc5dd1192e6db57251a13d6a197a29cec1a6c59ddadf221
7
+ data.tar.gz: 2d6118ce6b1cc2403247aee0ef73ab96d87f3b2be05e454c35484ce49e6548c4ca5ebf6c29837f3de317ee237b55bc44f4cc1e8e45e7441ef40bdd8c7470b6a4
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ sudo: false
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.2.0
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
- unless File.exists? File.expand_path('.generated_engine_cart', EngineCart.destination)
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.puts true }
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
@@ -1,3 +1,3 @@
1
1
  module EngineCart
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -18,15 +18,42 @@ describe "EngineCart powered application" do
18
18
  end
19
19
  end
20
20
 
21
- it "should create a rails app when the engine_cart:generate is invoked" do
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
@@ -1,5 +1,6 @@
1
1
  require 'engine_cart'
2
2
  require 'rspec'
3
+ require 'fileutils'
3
4
 
4
5
  RSpec.configure do |config|
5
6
 
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.1
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-16 00:00:00.000000000 Z
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: :development
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