rails-dummy 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails/dummy/version.rb +1 -1
- data/lib/tasks/dummy.rake +21 -8
- data/spec/tasks/dummy_setup_spec.rb +28 -19
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 863f26be8e49e62d9f0a792441f877165e23db13
|
4
|
+
data.tar.gz: 27569c1c40ac4d102bb0bfc23da1a7ac7f6625b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db1afd18ae808b2568ede53a0cd225dd2d65173428f0aeb8155386bf5fd4244f9bd15e60ee5295eca835165dbdaced1b32987b4bb8d2ec0e036109c5e024c305
|
7
|
+
data.tar.gz: b7a9f83623b6d1681d369b6eb81f45e3d6c7b9a25fe3ac61b50830df549b69f6a36e4c78daa06bc55522a794de97ee293056f669dbfe545aa141f2de57d15ab7
|
data/lib/rails/dummy/version.rb
CHANGED
data/lib/tasks/dummy.rake
CHANGED
@@ -6,14 +6,15 @@ namespace :dummy do
|
|
6
6
|
task :app => [:setup, :template, :install_migrations, :create, :migrate]
|
7
7
|
|
8
8
|
task :setup do
|
9
|
-
dummy = File.expand_path(dummy_path)
|
10
9
|
database = ENV['ENGINE_DB'] || 'sqlite3'
|
11
10
|
|
12
|
-
FileUtils.rm_rf(
|
11
|
+
FileUtils.rm_rf(dummy_path)
|
13
12
|
params = %W{. -q -f --skip-bundle -T -G}
|
14
|
-
params << '--dummy-path=%s' %
|
13
|
+
params << '--dummy-path=%s' % dummy_path
|
15
14
|
params << '--database=%s' % database
|
16
15
|
Rails::Dummy::Generator.start(params)
|
16
|
+
|
17
|
+
patch_database_config(dummy_path) if ENV['ENGINE_DB']
|
17
18
|
end
|
18
19
|
|
19
20
|
task :template do
|
@@ -64,10 +65,22 @@ namespace :dummy do
|
|
64
65
|
|
65
66
|
def dummy_path
|
66
67
|
rel_path = ENV['DUMMY_APP_PATH'] || 'spec/dummy'
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
68
|
+
File.expand_path(rel_path)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Replaces the `database.yml` file with a version to allow reading from env.
|
72
|
+
#
|
73
|
+
# See: https://github.com/rails/rails/issues/28827
|
74
|
+
def patch_database_config(path)
|
75
|
+
db_config_path = File.expand_path('config/database.yml', path)
|
76
|
+
content = <<-YML
|
77
|
+
test:
|
78
|
+
url: <%= ENV['DATABASE_URL'] %>
|
79
|
+
development:
|
80
|
+
url: <%= ENV['DATABASE_URL'] %>
|
81
|
+
production:
|
82
|
+
url: <%= ENV['DATABASE_URL'] %>
|
83
|
+
YML
|
84
|
+
open(db_config_path, 'w').write(content)
|
72
85
|
end
|
73
86
|
end
|
@@ -1,31 +1,40 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'dummy:setup', type: :task do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
4
|
+
shared_examples 'setup task' do
|
5
|
+
let(:dummy_path) { 'spec/dummy' }
|
6
|
+
let(:db_type) { 'sqlite3' }
|
7
|
+
|
8
|
+
it 'removes and generates a new dummy app' do
|
9
|
+
full_dummy_path = File.expand_path("../../../#{dummy_path}", __FILE__)
|
10
|
+
expect(FileUtils).to receive(:rm_rf).with(full_dummy_path)
|
11
|
+
expect(Rails::Dummy::Generator).to receive(:start).with(
|
12
|
+
%W(
|
13
|
+
. -q -f --skip-bundle -T -G
|
14
|
+
--dummy-path=#{full_dummy_path}
|
15
|
+
--database=#{db_type}
|
16
|
+
)
|
14
17
|
)
|
15
|
-
|
18
|
+
|
19
|
+
task.invoke
|
20
|
+
end
|
16
21
|
end
|
17
22
|
|
18
|
-
|
19
|
-
|
23
|
+
include_examples 'setup task'
|
24
|
+
|
25
|
+
context 'using ENGINE_DB environment variable' do
|
26
|
+
let(:db_type) { ENV['ENGINE_DB'] = 'postgresql' }
|
27
|
+
|
28
|
+
after { ENV.delete('ENGINE_DB') }
|
29
|
+
|
30
|
+
include_examples 'setup task'
|
20
31
|
end
|
21
32
|
|
22
33
|
context 'using DUMMY_APP_PATH environment variable' do
|
23
|
-
let(:dummy_path) { 'test_path' }
|
34
|
+
let(:dummy_path) { ENV['DUMMY_APP_PATH'] = 'test_path' }
|
24
35
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
ENV.delete('DUMMY_APP_PATH')
|
29
|
-
end
|
36
|
+
after { ENV.delete('DUMMY_APP_PATH') }
|
37
|
+
|
38
|
+
include_examples 'setup task'
|
30
39
|
end
|
31
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-dummy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stas SUȘCOV
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|