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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 30d378a83bdf4b3d6836c8f59a5ca6b49144de1e
4
- data.tar.gz: fe2164ccd7be01006fe9ded1bef2c6d81103451d
3
+ metadata.gz: 863f26be8e49e62d9f0a792441f877165e23db13
4
+ data.tar.gz: 27569c1c40ac4d102bb0bfc23da1a7ac7f6625b8
5
5
  SHA512:
6
- metadata.gz: ead6b440b32d76287063ae9bc485f89a1638ff8009e756106358b62e6ec6e6afd170b8a37ddc8a80788eb911deb717afe1d718f2dadf2f699f7ab259bdecad89
7
- data.tar.gz: bad4e8e3691f0c34db3ea667a5b6c3bf780e0b5c1e35dfca3cd46cd3b3e1f1f15fd6e423ce2d902153e569d2ad881d9e941d4237aa814baecf699abd12ed9c90
6
+ metadata.gz: db1afd18ae808b2568ede53a0cd225dd2d65173428f0aeb8155386bf5fd4244f9bd15e60ee5295eca835165dbdaced1b32987b4bb8d2ec0e036109c5e024c305
7
+ data.tar.gz: b7a9f83623b6d1681d369b6eb81f45e3d6c7b9a25fe3ac61b50830df549b69f6a36e4c78daa06bc55522a794de97ee293056f669dbfe545aa141f2de57d15ab7
@@ -1,5 +1,5 @@
1
1
  module Rails
2
2
  module Dummy
3
- VERSION = '0.0.5'
3
+ VERSION = '0.0.6'
4
4
  end
5
5
  end
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(dummy)
11
+ FileUtils.rm_rf(dummy_path)
13
12
  params = %W{. -q -f --skip-bundle -T -G}
14
- params << '--dummy-path=%s' % dummy
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
- if @current_path.to_s.include?(rel_path)
68
- @current_path
69
- else
70
- @current_path = File.expand_path(rel_path)
71
- end
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
- let(:dummy_path) { 'spec/dummy' }
5
-
6
- before do
7
- full_dummy_path = File.expand_path("../../../#{dummy_path}", __FILE__)
8
- expect(FileUtils).to receive(:rm_rf).with(full_dummy_path)
9
- expect(Rails::Dummy::Generator).to receive(:start).with(
10
- %W(
11
- . -q -f --skip-bundle -T -G
12
- --dummy-path=#{full_dummy_path}
13
- --database=sqlite3
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
- it 'removes and generates a new dummy app' do
19
- task.invoke
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
- it 'removes and generates a new dummy app' do
26
- ENV['DUMMY_APP_PATH'] = dummy_path
27
- task.invoke
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.5
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-13 00:00:00.000000000 Z
11
+ date: 2018-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails