rails-dummy 0.0.7 → 0.1.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
- SHA1:
3
- metadata.gz: 22de84dbae9a5919fdef3bc51731d2ccc5e28580
4
- data.tar.gz: 6f7dee4b36cfa8cd97ea0f6a514ea71dbfe8929e
2
+ SHA256:
3
+ metadata.gz: 0eee8b42d6f94515f3c19e6894e0166c5c029e94c492f268acbb9de2ef3594fb
4
+ data.tar.gz: eb601ed67ac5bc6f0d03fe3e148fa46fee5a4ddc89135942410ac741c5b3f7e7
5
5
  SHA512:
6
- metadata.gz: 016c073d01ae9b4df3bf35b03d5374e625567cea1430349e9d229205600f740b710941cced969c5c89f5b378ac6b9faa6443db17fb9b95b31557b1f180beea16
7
- data.tar.gz: 0cdc85b477a3379028df5c2926f86c8cecf8abb1f4aaaa8c02adacb4cede2c5f5238777228f47f7f59a78ad510c92aeeda91ed01966daaaa3b573692fca6dd26
6
+ metadata.gz: aca3948bba5457c0177743842cb6910f4610c96c60c37d762b539c469cda7c1f2752751ff5e760a659aaee8e257bc7b6ec90c554ff4f053eda06dd762b86bf42
7
+ data.tar.gz: b4bea087ae077c035fae8fa7d5725fa6b74686adbc1232f571936a795054b2e02ac8b788602850623dacbd8e870365ebcfe9dc434611f311d80382675134e648
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # Rails::Dummy
2
2
 
3
3
  [![Build Status](https://travis-ci.org/Courseware/rails-dummy.png?branch=master)](https://travis-ci.org/Courseware/rails-dummy)
4
-
5
4
  A simple task to generate a dummy app for engines using RSpec or Test::Unit.
6
5
 
7
6
  ## Installation
@@ -28,24 +27,26 @@ Now you should be able to run:
28
27
 
29
28
  rake dummy:app
30
29
 
31
- ## Customization by environment variables:
30
+ ## Customization via environment variables:
32
31
 
33
32
  `DUMMY_APP_PATH` - Specify path where dummy app will be located. Defaults to
34
33
  `spec/dummy`.
35
34
 
36
- `TEMPLATE` - Specify a Rails template by path location variable. Defaults to
37
- nil; creates generic Rails app.
38
-
39
35
  `ENGINE` - Specify engine name migrations to be installed via `rake
40
36
  ENGINE:install:migrations`. Defaults to nil; engine specific migrations are not
41
37
  installed.
42
38
 
43
- `ENGINE_DB` - Specify engine database. Defaults to `sqlite3`.
44
-
45
39
  `DISABLE_CREATE` - Don't run `db:create`.
46
40
 
47
41
  `DISABLE_MIGRATE` - Don't run `db:migrate db:test:prepare` after creating database.
48
42
 
43
+ ### Customization via `.dummyrc`
44
+
45
+ In addition to the environment variables, you can create a `.dummyrc` file which
46
+ will be picked up by the dummy application generator.
47
+
48
+ This file follows [the same syntax as the `.railsrc` file](https://github.com/rails/rails/blob/master/railties/lib/rails/generators/rails/app/USAGE).
49
+
49
50
  ## Projects using this gem
50
51
 
51
52
  * [Coursewa.re](http://coursewa.re/about)
@@ -1,46 +1,14 @@
1
1
  require 'rails'
2
2
  require 'rails/generators'
3
3
  require 'rails/dummy/version'
4
-
5
- begin
6
- require 'rails/generators/rails/plugin_new/plugin_new_generator'
7
- rescue LoadError
8
- require 'rails/generators/rails/plugin/plugin_generator'
9
- end
4
+ require 'rails/generators/rails/app/app_generator'
10
5
 
11
6
  module Rails
12
7
  module Dummy
13
-
14
- def self.generator_class
15
- begin
16
- Rails::Generators::PluginNewGenerator
17
- rescue
18
- Rails::Generators::PluginGenerator
19
- end
20
- end
21
-
22
- class Generator < Rails::Dummy.generator_class
23
-
8
+ class Generator < Rails::Generators::AppGenerator
24
9
  def self.default_source_root
25
10
  superclass.default_source_root
26
11
  end
27
-
28
- def do_nothing
29
- end
30
-
31
- alias_method :create_root, :do_nothing
32
- alias_method :create_root_files, :do_nothing
33
- alias_method :create_app_files, :do_nothing
34
- alias_method :create_config_files, :do_nothing
35
- alias_method :create_lib_files, :do_nothing
36
- alias_method :create_public_stylesheets_files, :do_nothing
37
- alias_method :create_javascript_files, :do_nothing
38
- alias_method :create_script_files, :do_nothing
39
- alias_method :update_gemfile, :do_nothing
40
- alias_method :create_test_files, :do_nothing
41
- alias_method :finish_template, :do_nothing
42
- alias_method :create_bin_files, :do_nothing
43
- alias_method :create_images_directory, :do_nothing
44
12
  end
45
13
  end
46
14
  end
@@ -1,5 +1,5 @@
1
1
  module Rails
2
2
  module Dummy
3
- VERSION = '0.0.7'
3
+ VERSION = '0.1.0'
4
4
  end
5
5
  end
@@ -1,38 +1,25 @@
1
1
  namespace :dummy do
2
2
  desc(
3
3
  'Generates a dummy app for testing.'\
4
- 'Use options: `DUMMY_APP_PATH`, `ENGINE` and `ENGINE_DB`'
4
+ 'Use $DUMMY_APP_PATH and $ENGINE`'\
5
+ 'to overwrite the location and integrate with a Rails engine.'\
6
+ 'Create a .dummyrc (aka .railsrc) file to customize the generator options.'
5
7
  )
6
- task :app => [:setup, :template, :install_migrations, :create, :migrate]
8
+ task :app => [:setup, :install_migrations, :db_create, :db_migrate]
7
9
 
8
10
  task :setup do
9
- database = ENV['ENGINE_DB'] || 'sqlite3'
10
-
11
11
  FileUtils.rm_rf(dummy_path)
12
- params = %W{. -q -f --skip-bundle -T -G}
13
- params << '--dummy-path=%s' % dummy_path
14
- params << '--database=%s' % database
12
+
13
+ params = [dummy_path] + %W{-q -f --skip-bundle -T -G}
14
+
15
+ params += File.read(File.expand_path('.dummyrc'))
16
+ .to_s.split("\n").compact if File.exists?('.dummyrc')
17
+
15
18
  Rails::Dummy::Generator.start(params)
16
19
 
17
20
  patch_database_config(dummy_path) if ENV['ENGINE_DB']
18
21
  end
19
22
 
20
- task :template do
21
- unless ENV['TEMPLATE']
22
- Kernel.puts(
23
- 'No `TEMPLATE` environment variable was set, no template to apply.'
24
- )
25
- else
26
- # File.expand_path is executed directory of generated Rails app
27
- rakefile = File.expand_path('Rakefile', dummy_path)
28
- template = File.expand_path(
29
- ENV['TEMPLATE'], File.expand_path('../../', dummy_path))
30
- command = "rake -f '%s' rails:template LOCATION='%s'" % [
31
- rakefile, template]
32
- sh(command)
33
- end
34
- end
35
-
36
23
  task :install_migrations do
37
24
  engine = ENV['ENGINE']
38
25
  unless engine
@@ -48,14 +35,14 @@ namespace :dummy do
48
35
  end
49
36
  end
50
37
 
51
- task :create do
38
+ task :db_create do
52
39
  # File.expand_path is executed directory of generated Rails app
53
40
  rakefile = File.expand_path('Rakefile', dummy_path)
54
41
  command = "rake -f '%s' db:create" % rakefile
55
42
  sh(command) unless ENV["DISABLE_CREATE"]
56
43
  end
57
44
 
58
- task :migrate do
45
+ task :db_migrate do
59
46
  # File.expand_path is executed directory of generated Rails app
60
47
  rakefile = File.expand_path('Rakefile', dummy_path)
61
48
  command = "rake -f '%s' db:migrate" % rakefile
@@ -79,6 +66,8 @@ namespace :dummy do
79
66
  def patch_database_config(path)
80
67
  db_config_path = File.expand_path('config/database.yml', path)
81
68
  content = <<-YML
69
+ development:
70
+ url: <%= ENV['DATABASE_URL'] %>
82
71
  test:
83
72
  url: <%= ENV['DATABASE_URL'] %>
84
73
  YML
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "rails"
21
+ spec.add_dependency "railties"
22
22
 
23
23
  spec.add_development_dependency "bundler"
24
24
  spec.add_development_dependency "rake"
@@ -15,8 +15,7 @@ describe Rails::Dummy::Generator do
15
15
  end
16
16
 
17
17
  it 'creates a dummy app' do
18
- params = %W{. -q -f --skip-bundle -T -G --dummy-path}
19
- params << dummy_path
18
+ params = [dummy_path] + %W{-q -f --skip-bundle -T -G}
20
19
  Rails::Dummy::Generator.start(params)
21
20
 
22
21
  expect(Dir[File.join(@current_path, dummy_path, '*')]).to_not be_empty
@@ -2,8 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe 'dummy:app', type: :task do
4
4
  its(:prerequisites) { should include('setup') }
5
- its(:prerequisites) { should include('template') }
6
5
  its(:prerequisites) { should include('install_migrations') }
7
- its(:prerequisites) { should include('create') }
8
- its(:prerequisites) { should include('migrate') }
6
+ its(:prerequisites) { should include('db_create') }
7
+ its(:prerequisites) { should include('db_migrate') }
9
8
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'dummy:create', type: :task do
4
-
3
+ describe 'dummy:db_create', type: :task do
5
4
  context 'when DISABLE_CREATE variable is set' do
6
5
  before do
7
6
  ENV['DISABLE_CREATE'] = '1'
@@ -32,5 +31,4 @@ describe 'dummy:create', type: :task do
32
31
  task.invoke
33
32
  end
34
33
  end
35
-
36
34
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'dummy:install_migrations', type: :task do
4
-
5
4
  context 'when ENGINE variable is set' do
6
5
  let(:engine_name) { 'TEST_ENGINE' }
7
6
 
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'dummy:migrate', type: :task do
4
-
3
+ describe 'dummy:db_migrate', type: :task do
5
4
  context 'when DISABLE_MIGRATE variable is set' do
6
5
  before do
7
6
  ENV['DISABLE_MIGRATE'] = '1'
@@ -49,5 +48,4 @@ describe 'dummy:migrate', type: :task do
49
48
  task.invoke
50
49
  end
51
50
  end
52
-
53
51
  end
@@ -10,9 +10,7 @@ describe 'dummy:setup', type: :task do
10
10
  expect(FileUtils).to receive(:rm_rf).with(full_dummy_path)
11
11
  expect(Rails::Dummy::Generator).to receive(:start).with(
12
12
  %W(
13
- . -q -f --skip-bundle -T -G
14
- --dummy-path=#{full_dummy_path}
15
- --database=#{db_type}
13
+ #{full_dummy_path} -q -f --skip-bundle -T -G --database=#{db_type}
16
14
  )
17
15
  )
18
16
 
@@ -20,10 +18,18 @@ describe 'dummy:setup', type: :task do
20
18
  end
21
19
  end
22
20
 
21
+ before do
22
+ File.write(File.expand_path('.dummyrc'), "--database=#{db_type}\n")
23
+ end
24
+
25
+ after do
26
+ File.unlink(File.expand_path('.dummyrc'))
27
+ end
28
+
23
29
  include_examples 'setup task'
24
30
 
25
31
  context 'using ENGINE_DB environment variable' do
26
- let(:db_type) { ENV['ENGINE_DB'] = 'postgresql' }
32
+ let(:db_type) { 'postgresql' }
27
33
 
28
34
  after { ENV.delete('ENGINE_DB') }
29
35
 
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-dummy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.1.0
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-20 00:00:00.000000000 Z
11
+ date: 2019-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: railties
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -120,7 +120,6 @@ files:
120
120
  - spec/tasks/dummy_install_migrations_spec.rb
121
121
  - spec/tasks/dummy_migrate_spec.rb
122
122
  - spec/tasks/dummy_setup_spec.rb
123
- - spec/tasks/dummy_template_spec.rb
124
123
  homepage: https://github.com/courseware/rails-dummy
125
124
  licenses:
126
125
  - MIT
@@ -140,8 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
139
  - !ruby/object:Gem::Version
141
140
  version: '0'
142
141
  requirements: []
143
- rubyforge_project:
144
- rubygems_version: 2.6.8
142
+ rubygems_version: 3.0.1
145
143
  signing_key:
146
144
  specification_version: 4
147
145
  summary: Use it to generate a dummy app for RSpec
@@ -153,4 +151,3 @@ test_files:
153
151
  - spec/tasks/dummy_install_migrations_spec.rb
154
152
  - spec/tasks/dummy_migrate_spec.rb
155
153
  - spec/tasks/dummy_setup_spec.rb
156
- - spec/tasks/dummy_template_spec.rb
@@ -1,36 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'dummy:template', type: :task do
4
-
5
- context 'when TEMPLATE variable was not set' do
6
- it 'calls puts with a notice message' do
7
- task.invoke
8
- end
9
- end
10
-
11
- context 'when TEMPLATE variable is set' do
12
- let(:template) { 'test/TMPL' }
13
-
14
- before do
15
- ENV['TEMPLATE'] = template
16
- rakefile = File.expand_path('../../dummy/Rakefile', __FILE__)
17
- template_path = File.expand_path(
18
- template, File.expand_path('../../../', __FILE__))
19
-
20
- command = "rake -f '%s' rails:template LOCATION='%s'" % [
21
- rakefile, template_path ]
22
-
23
- expect_any_instance_of(::Kernel).to(
24
- receive(:system).with(command, {}).and_return(true)
25
- )
26
- end
27
-
28
- after do
29
- ENV.delete('TEMPLATE')
30
- end
31
-
32
- it 'calls rake with rails:template task' do
33
- task.invoke
34
- end
35
- end
36
- end