padrino-gen 0.16.0.pre4 → 0.16.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.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/bin/padrino-gen +4 -4
  4. data/lib/padrino-gen/command.rb +2 -2
  5. data/lib/padrino-gen/generators/actions.rb +68 -64
  6. data/lib/padrino-gen/generators/app/app.rb.tt +6 -6
  7. data/lib/padrino-gen/generators/app.rb +19 -19
  8. data/lib/padrino-gen/generators/cli.rb +16 -19
  9. data/lib/padrino-gen/generators/component.rb +18 -19
  10. data/lib/padrino-gen/generators/components/actions.rb +42 -42
  11. data/lib/padrino-gen/generators/components/mocks/mocha.rb +7 -7
  12. data/lib/padrino-gen/generators/components/mocks/rr.rb +7 -7
  13. data/lib/padrino-gen/generators/components/orms/activerecord.rb +158 -156
  14. data/lib/padrino-gen/generators/components/orms/couchrest.rb +33 -33
  15. data/lib/padrino-gen/generators/components/orms/datamapper.rb +108 -103
  16. data/lib/padrino-gen/generators/components/orms/dynamoid.rb +40 -40
  17. data/lib/padrino-gen/generators/components/orms/minirecord.rb +114 -114
  18. data/lib/padrino-gen/generators/components/orms/mongoid.rb +65 -65
  19. data/lib/padrino-gen/generators/components/orms/mongomapper.rb +20 -20
  20. data/lib/padrino-gen/generators/components/orms/mongomatic.rb +63 -59
  21. data/lib/padrino-gen/generators/components/orms/ohm.rb +49 -47
  22. data/lib/padrino-gen/generators/components/orms/ripple.rb +45 -45
  23. data/lib/padrino-gen/generators/components/orms/sequel.rb +51 -46
  24. data/lib/padrino-gen/generators/components/renderers/erb.rb +1 -1
  25. data/lib/padrino-gen/generators/components/renderers/liquid.rb +1 -1
  26. data/lib/padrino-gen/generators/components/scripts/dojo.rb +6 -6
  27. data/lib/padrino-gen/generators/components/scripts/extcore.rb +6 -6
  28. data/lib/padrino-gen/generators/components/scripts/jquery.rb +6 -6
  29. data/lib/padrino-gen/generators/components/scripts/mootools.rb +6 -6
  30. data/lib/padrino-gen/generators/components/scripts/prototype.rb +8 -8
  31. data/lib/padrino-gen/generators/components/stylesheets/compass.rb +1 -1
  32. data/lib/padrino-gen/generators/components/stylesheets/less.rb +4 -4
  33. data/lib/padrino-gen/generators/components/tests/bacon.rb +66 -66
  34. data/lib/padrino-gen/generators/components/tests/cucumber.rb +61 -61
  35. data/lib/padrino-gen/generators/components/tests/minitest.rb +70 -70
  36. data/lib/padrino-gen/generators/components/tests/rspec.rb +74 -74
  37. data/lib/padrino-gen/generators/components/tests/shoulda.rb +72 -72
  38. data/lib/padrino-gen/generators/components/tests/testunit.rb +69 -69
  39. data/lib/padrino-gen/generators/controller.rb +16 -17
  40. data/lib/padrino-gen/generators/helper.rb +8 -9
  41. data/lib/padrino-gen/generators/mailer.rb +8 -9
  42. data/lib/padrino-gen/generators/migration.rb +6 -6
  43. data/lib/padrino-gen/generators/model.rb +20 -21
  44. data/lib/padrino-gen/generators/plugin.rb +9 -9
  45. data/lib/padrino-gen/generators/project/config/apps.rb.tt +4 -4
  46. data/lib/padrino-gen/generators/project/config/boot.rb +2 -2
  47. data/lib/padrino-gen/generators/project/config.ru +1 -1
  48. data/lib/padrino-gen/generators/project.rb +49 -51
  49. data/lib/padrino-gen/generators/runner.rb +25 -24
  50. data/lib/padrino-gen/generators/task.rb +7 -8
  51. data/lib/padrino-gen/generators/templates/Gemfile.tt +5 -5
  52. data/lib/padrino-gen/generators/templates/controller.rb.tt +3 -3
  53. data/lib/padrino-gen/generators/templates/mailer.rb.tt +15 -15
  54. data/lib/padrino-gen/generators/templates/project_bin.tt +1 -1
  55. data/lib/padrino-gen/generators/templates/task.rb.tt +1 -1
  56. data/lib/padrino-gen/padrino-tasks/activerecord.rb +152 -160
  57. data/lib/padrino-gen/padrino-tasks/database.rb +2 -2
  58. data/lib/padrino-gen/padrino-tasks/datamapper.rb +31 -31
  59. data/lib/padrino-gen/padrino-tasks/minirecord.rb +3 -3
  60. data/lib/padrino-gen/padrino-tasks/mongoid.rb +39 -41
  61. data/lib/padrino-gen/padrino-tasks/mongomapper.rb +18 -14
  62. data/lib/padrino-gen/padrino-tasks/sequel.rb +28 -28
  63. data/lib/padrino-gen/padrino-tasks/sql-helpers.rb +45 -45
  64. data/lib/padrino-gen.rb +4 -4
  65. data/padrino-gen.gemspec +19 -19
  66. data/test/fixtures/admin_template.rb +5 -5
  67. data/test/fixtures/database_template.rb +19 -22
  68. data/test/fixtures/example_template.rb +8 -8
  69. data/test/fixtures/git_template.rb +2 -2
  70. data/test/fixtures/plugin_template.rb +3 -3
  71. data/test/fixtures/rake_template.rb +5 -5
  72. data/test/helper.rb +23 -21
  73. data/test/test_app_generator.rb +13 -13
  74. data/test/test_cli.rb +4 -5
  75. data/test/test_component_generator.rb +17 -17
  76. data/test/test_controller_generator.rb +62 -63
  77. data/test/test_generator.rb +6 -6
  78. data/test/test_helper_generator.rb +23 -24
  79. data/test/test_mailer_generator.rb +7 -7
  80. data/test/test_migration_generator.rb +31 -31
  81. data/test/test_model_generator.rb +80 -80
  82. data/test/test_plugin_generator.rb +35 -36
  83. data/test/test_project_generator.rb +171 -169
  84. data/test/test_sql_helpers.rb +49 -50
  85. data/test/test_task_generator.rb +13 -13
  86. metadata +10 -10
@@ -1,105 +1,105 @@
1
- BACON_SETUP = (<<-TEST).gsub(/^ {10}/, '') unless defined?(BACON_SETUP)
2
- RACK_ENV = 'test' unless defined?(RACK_ENV)
3
- require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
4
- Dir[File.expand_path(File.dirname(__FILE__) + "/../app/helpers/**/*.rb")].each(&method(:require))
1
+ BACON_SETUP = <<~TEST.gsub(/^ {10}/, '') unless defined?(BACON_SETUP)
2
+ RACK_ENV = 'test' unless defined?(RACK_ENV)
3
+ require_relative '../config/boot'
4
+ Dir[File.expand_path("\#{__dir__}/../app/helpers/**/*.rb")].each(&method(:require))
5
5
 
6
- class Bacon::Context
7
- include Rack::Test::Methods
8
- end
6
+ class Bacon::Context
7
+ include Rack::Test::Methods
8
+ end
9
9
 
10
- # You can use this method to custom specify a Rack app
11
- # you want rack-test to invoke:
12
- #
13
- # app CLASS_NAME
14
- # app CLASS_NAME.tap { |a| }
15
- # app(CLASS_NAME) do
16
- # set :foo, :bar
17
- # end
18
- #
19
- def app(app = nil, &blk)
20
- @app ||= block_given? ? app.instance_eval(&blk) : app
21
- @app ||= Padrino.application
22
- end
10
+ # You can use this method to custom specify a Rack app
11
+ # you want rack-test to invoke:
12
+ #
13
+ # app CLASS_NAME
14
+ # app CLASS_NAME.tap { |a| }
15
+ # app(CLASS_NAME) do
16
+ # set :foo, :bar
17
+ # end
18
+ #
19
+ def app(app = nil, &blk)
20
+ @app ||= block_given? ? app.instance_eval(&blk) : app
21
+ @app ||= Padrino.application
22
+ end
23
23
  TEST
24
24
 
25
- BACON_CONTROLLER_TEST = (<<-TEST).gsub(/^ {10}/, '') unless defined?(BACON_CONTROLLER_TEST)
26
- require File.expand_path(File.dirname(__FILE__) + '/../../test_config.rb')
25
+ BACON_CONTROLLER_TEST = <<~TEST.gsub(/^ {10}/, '') unless defined?(BACON_CONTROLLER_TEST)
26
+ require File.expand_path("\#{__dir__}/../../test_config.rb")
27
27
 
28
- describe "!PATH!" do
29
- it 'returns text at root' do
30
- get "!EXPANDED_PATH!"
31
- last_response.body.should == "some text"
28
+ describe "!PATH!" do
29
+ it 'returns text at root' do
30
+ get "!EXPANDED_PATH!"
31
+ last_response.body.should == "some text"
32
+ end
32
33
  end
33
- end
34
34
  TEST
35
35
 
36
- BACON_RAKE = (<<-TEST).gsub(/^ {10}/, '') unless defined?(BACON_RAKE)
37
- require 'rake/testtask'
36
+ BACON_RAKE = <<~TEST.gsub(/^ {10}/, '') unless defined?(BACON_RAKE)
37
+ require 'rake/testtask'
38
38
 
39
- test_tasks = Dir['test/*/'].map { |d| File.basename(d) }
39
+ test_tasks = Dir['test/*/'].map { |d| File.basename(d) }
40
40
 
41
- test_tasks.each do |folder|
42
- Rake::TestTask.new("test:\#{folder}") do |test|
43
- test.pattern = "test/\#{folder}/**/*_test.rb"
44
- test.verbose = true
41
+ test_tasks.each do |folder|
42
+ Rake::TestTask.new("test:\#{folder}") do |test|
43
+ test.pattern = "test/\#{folder}/**/*_test.rb"
44
+ test.verbose = true
45
+ end
45
46
  end
46
- end
47
47
 
48
- desc "Run application test suite"
49
- task 'test' => test_tasks.map { |f| "test:\#{f}" }
48
+ desc "Run application test suite"
49
+ task 'test' => test_tasks.map { |f| "test:\#{f}" }
50
50
 
51
- task :default => :test
51
+ task default: :test
52
52
  TEST
53
53
 
54
- BACON_MODEL_TEST = (<<-TEST).gsub(/^ {10}/, '') unless defined?(BACON_MODEL_TEST)
55
- require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb')
54
+ BACON_MODEL_TEST = <<~TEST.gsub(/^ {10}/, '') unless defined?(BACON_MODEL_TEST)
55
+ require File.expand_path("\#{__dir__}!PATH!/test_config.rb")
56
56
 
57
- describe "!NAME! Model" do
58
- it 'can be created' do
59
- @!DNAME! = !NAME!.new
60
- @!DNAME!.should.not.be.nil
57
+ describe "!NAME! Model" do
58
+ it 'can be created' do
59
+ @!DNAME! = !NAME!.new
60
+ @!DNAME!.should.not.be.nil
61
+ end
61
62
  end
62
- end
63
63
  TEST
64
64
 
65
- BACON_HELPER_TEST = <<-TEST unless defined?(BACON_HELPER_TEST)
66
- require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb')
65
+ BACON_HELPER_TEST = <<~TEST unless defined?(BACON_HELPER_TEST)
66
+ require File.expand_path("\#{__dir__}!PATH!/test_config.rb")
67
67
 
68
- describe "!NAME!" do
69
- before do
70
- @helpers = Class.new
71
- @helpers.extend !NAME!
72
- end
68
+ describe "!NAME!" do
69
+ before do
70
+ @helpers = Class.new
71
+ @helpers.extend !NAME!
72
+ end
73
73
 
74
- it "should return nil" do
75
- @helpers.foo.should.equal nil
74
+ it "should return nil" do
75
+ @helpers.foo.should.equal nil
76
+ end
76
77
  end
77
- end
78
78
  TEST
79
79
 
80
80
  def setup_test
81
- require_dependencies 'rack-test', :require => 'rack/test', :group => 'test'
82
- require_dependencies 'bacon', :group => 'test'
83
- insert_test_suite_setup BACON_SETUP, :path => 'test/test_config.rb'
84
- create_file destination_root("test/test.rake"), BACON_RAKE
81
+ require_dependencies 'rack-test', require: 'rack/test', group: 'test'
82
+ require_dependencies 'bacon', group: 'test'
83
+ insert_test_suite_setup BACON_SETUP, path: 'test/test_config.rb'
84
+ create_file destination_root('test/test.rake'), BACON_RAKE
85
85
  end
86
86
 
87
87
  def generate_controller_test(name, path)
88
- bacon_contents = BACON_CONTROLLER_TEST.gsub(/!PATH!/, path).gsub(/!EXPANDED_PATH!/, path.gsub(/:\w+?_id/, "1"))
89
- controller_test_path = File.join('test',options[:app],'controllers',"#{name.to_s.underscore}_controller_test.rb")
90
- create_file destination_root(controller_test_path), bacon_contents, :skip => true
88
+ bacon_contents = BACON_CONTROLLER_TEST.gsub(/!PATH!/, path).gsub(/!EXPANDED_PATH!/, path.gsub(/:\w+?_id/, '1'))
89
+ controller_test_path = File.join('test', options[:app], 'controllers', "#{name.to_s.underscore}_controller_test.rb")
90
+ create_file destination_root(controller_test_path), bacon_contents, skip: true
91
91
  end
92
92
 
93
93
  def generate_model_test(name)
94
- bacon_contents = BACON_MODEL_TEST.gsub(/!NAME!/, name.to_s.underscore.camelize).gsub(/!DNAME!/, name.to_s.underscore)
94
+ bacon_contents = BACON_MODEL_TEST.gsub(/!NAME!/, name.to_s.underscore.camelize).gsub(/!DNAME!/, name.to_s.underscore)
95
95
  bacon_contents.gsub!(/!PATH!/, recognize_path)
96
- model_test_path = File.join('test',options[:app],'models',"#{name.to_s.underscore}_test.rb")
97
- create_file destination_root(model_test_path), bacon_contents, :skip => true
96
+ model_test_path = File.join('test', options[:app], 'models', "#{name.to_s.underscore}_test.rb")
97
+ create_file destination_root(model_test_path), bacon_contents, skip: true
98
98
  end
99
99
 
100
100
  def generate_helper_test(name, project_name, app_name)
101
101
  bacon_contents = BACON_HELPER_TEST.gsub(/!NAME!/, "#{project_name}::#{app_name}::#{name}")
102
102
  bacon_contents.gsub!(/!PATH!/, recognize_path)
103
103
  helper_spec_path = File.join('test', options[:app], 'helpers', "#{name.underscore}_test.rb")
104
- create_file destination_root(helper_spec_path), bacon_contents, :skip => true
104
+ create_file destination_root(helper_spec_path), bacon_contents, skip: true
105
105
  end
@@ -1,86 +1,86 @@
1
1
  apply_component_for(:rspec, :test)
2
2
 
3
- CUCUMBER_SETUP = (<<-TEST) unless defined?(CUCUMBER_SETUP)
4
- RACK_ENV = 'test' unless defined?(RACK_ENV)
5
- require File.expand_path(File.dirname(__FILE__) + "/../../config/boot")
6
- Dir[File.expand_path(File.dirname(__FILE__) + "/../app/helpers/**/*.rb")].each(&method(:require))
3
+ CUCUMBER_SETUP = <<~TEST unless defined?(CUCUMBER_SETUP)
4
+ RACK_ENV = 'test' unless defined?(RACK_ENV)
5
+ require_relative '../../config/boot'
6
+ Dir[File.expand_path("\#{__dir__}/../app/helpers/**/*.rb")].each(&method(:require))
7
7
 
8
- require 'capybara/cucumber'
9
- require 'rspec/expectations'
8
+ require 'capybara/cucumber'
9
+ require 'rspec/expectations'
10
10
 
11
- ##
12
- # You can handle all padrino applications using instead:
13
- # Padrino.application
14
- Capybara.app = CLASS_NAME.tap { |app| }
11
+ ##
12
+ # You can handle all padrino applications using instead:
13
+ # Padrino.application
14
+ Capybara.app = CLASS_NAME.tap { |app| }
15
15
  TEST
16
16
 
17
- CUCUMBER_YML = (<<-TEST) unless defined?(CUCUMBER_YML)
18
- default: --tags ~@wip --strict features
19
- html_report: --tags ~@wip --strict --format html --out=features_report.html features
17
+ CUCUMBER_YML = <<~TEST unless defined?(CUCUMBER_YML)
18
+ default: --tags ~@wip --strict features
19
+ html_report: --tags ~@wip --strict --format html --out=features_report.html features
20
20
  TEST
21
21
 
22
- CUCUMBER_FEATURE = (<<-TEST) unless defined?(CUCUMBER_FEATURE)
23
- Feature: Addition
24
- In order to avoid silly mistakes
25
- As a math idiot
26
- I want to be told the sum of two numbers
22
+ CUCUMBER_FEATURE = <<~TEST unless defined?(CUCUMBER_FEATURE)
23
+ Feature: Addition
24
+ In order to avoid silly mistakes
25
+ As a math idiot
26
+ I want to be told the sum of two numbers
27
27
 
28
- Scenario: Add two numbers
29
- Given I visit the calculator page
30
- And I fill in '50' for 'first'
31
- And I fill in '70' for 'second'
32
- When I press 'Add'
33
- Then I should see 'Answer: 120'
28
+ Scenario: Add two numbers
29
+ Given I visit the calculator page
30
+ And I fill in '50' for 'first'
31
+ And I fill in '70' for 'second'
32
+ When I press 'Add'
33
+ Then I should see 'Answer: 120'
34
34
  TEST
35
35
 
36
- CUCUMBER_STEP = (<<-TEST) unless defined?(CUCUMBER_STEP)
37
- Given /^I visit the calculator page$/ do
38
- visit '/add'
39
- end
36
+ CUCUMBER_STEP = <<~TEST unless defined?(CUCUMBER_STEP)
37
+ Given /^I visit the calculator page$/ do
38
+ visit '/add'
39
+ end
40
40
 
41
- Given /^I fill in '(.*)' for '(.*)'$/ do |value, field|
42
- fill_in(field, :with => value)
43
- end
41
+ Given /^I fill in '(.*)' for '(.*)'$/ do |value, field|
42
+ fill_in(field, with: value)
43
+ end
44
44
 
45
- When /^I press '(.*)'$/ do |name|
46
- click_button(name)
47
- end
45
+ When /^I press '(.*)'$/ do |name|
46
+ click_button(name)
47
+ end
48
48
 
49
- Then /^I should see '(.*)'$/ do |text|
50
- page.should have_content(text)
51
- end
49
+ Then /^I should see '(.*)'$/ do |text|
50
+ page.should have_content(text)
51
+ end
52
52
  TEST
53
53
 
54
- CUCUMBER_URL = (<<-TEST) unless defined?(CUCUMBER_URL)
55
- module Cucumber
56
- module Web
57
- module URLs
58
- def url_for(*names)
59
- Capybara.app.url_for(*names)
60
- end
61
- alias_method :url, :url_for
54
+ CUCUMBER_URL = <<~TEST unless defined?(CUCUMBER_URL)
55
+ module Cucumber
56
+ module Web
57
+ module URLs
58
+ def url_for(*names)
59
+ Capybara.app.url_for(*names)
60
+ end
61
+ alias_method :url, :url_for
62
62
 
63
- def absolute_url_for(*names)
64
- "http://www.example.com" + Capybara.app.url_for(*names)
63
+ def absolute_url_for(*names)
64
+ "http://www.example.com" + Capybara.app.url_for(*names)
65
+ end
66
+ alias_method :absolute_url, :absolute_url_for
65
67
  end
66
- alias_method :absolute_url, :absolute_url_for
67
68
  end
68
69
  end
69
- end
70
70
 
71
- World(Cucumber::Web::URLs)
71
+ World(Cucumber::Web::URLs)
72
72
  TEST
73
73
 
74
74
  def setup_test
75
- require_dependencies 'rack-test', :require => 'rack/test', :group => 'test'
76
- require_dependencies 'cucumber', :group => 'test'
77
- require_dependencies 'capybara', :group => 'test'
78
- insert_test_suite_setup CUCUMBER_SETUP, :path => "features/support/env.rb"
79
- create_file destination_root("features/support/url.rb"), CUCUMBER_URL
80
- create_file destination_root("features/add.feature"), CUCUMBER_FEATURE
81
- create_file destination_root("features/step_definitions/add_steps.rb"), CUCUMBER_STEP
82
- create_file destination_root("cucumber.yml"), CUCUMBER_YML
83
- require_dependencies 'rspec', :group => 'test'
84
- insert_test_suite_setup RSPEC_SETUP, :path => "spec/spec_helper.rb"
85
- create_file destination_root("spec/spec.rake"), RSPEC_RAKE
75
+ require_dependencies 'rack-test', require: 'rack/test', group: 'test'
76
+ require_dependencies 'cucumber', group: 'test'
77
+ require_dependencies 'capybara', group: 'test'
78
+ insert_test_suite_setup CUCUMBER_SETUP, path: 'features/support/env.rb'
79
+ create_file destination_root('features/support/url.rb'), CUCUMBER_URL
80
+ create_file destination_root('features/add.feature'), CUCUMBER_FEATURE
81
+ create_file destination_root('features/step_definitions/add_steps.rb'), CUCUMBER_STEP
82
+ create_file destination_root('cucumber.yml'), CUCUMBER_YML
83
+ require_dependencies 'rspec', group: 'test'
84
+ insert_test_suite_setup RSPEC_SETUP, path: 'spec/spec_helper.rb'
85
+ create_file destination_root('spec/spec.rake'), RSPEC_RAKE
86
86
  end
@@ -1,112 +1,112 @@
1
- MINITEST_SETUP = (<<-TEST).gsub(/^ {10}/, '') unless defined?(MINITEST_SETUP)
2
- RACK_ENV = 'test' unless defined?(RACK_ENV)
3
- require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
4
- Dir[File.expand_path(File.dirname(__FILE__) + "/../app/helpers/**/*.rb")].each(&method(:require))
5
-
6
- class Minitest::Spec
7
- include Rack::Test::Methods
8
-
9
- # You can use this method to custom specify a Rack app
10
- # you want rack-test to invoke:
11
- #
12
- # app CLASS_NAME
13
- # app CLASS_NAME.tap { |a| }
14
- # app(CLASS_NAME) do
15
- # set :foo, :bar
16
- # end
17
- #
18
- def app(app = nil, &blk)
19
- @app ||= block_given? ? app.instance_eval(&blk) : app
20
- @app ||= Padrino.application
1
+ MINITEST_SETUP = <<~TEST.gsub(/^ {10}/, '') unless defined?(MINITEST_SETUP)
2
+ RACK_ENV = 'test' unless defined?(RACK_ENV)
3
+ require_relative '../config/boot'
4
+ Dir[File.expand_path("\#{__dir__}/../app/helpers/**/*.rb")].each(&method(:require))
5
+
6
+ class Minitest::Spec
7
+ include Rack::Test::Methods
8
+
9
+ # You can use this method to custom specify a Rack app
10
+ # you want rack-test to invoke:
11
+ #
12
+ # app CLASS_NAME
13
+ # app CLASS_NAME.tap { |a| }
14
+ # app(CLASS_NAME) do
15
+ # set :foo, :bar
16
+ # end
17
+ #
18
+ def app(app = nil, &blk)
19
+ @app ||= block_given? ? app.instance_eval(&blk) : app
20
+ @app ||= Padrino.application
21
+ end
21
22
  end
22
- end
23
23
  TEST
24
24
 
25
- MINITEST_RAKE = (<<-TEST).gsub(/^ {10}/, '') unless defined?(MINITEST_RAKE)
26
- require 'rake/testtask'
25
+ MINITEST_RAKE = <<~TEST.gsub(/^ {10}/, '') unless defined?(MINITEST_RAKE)
26
+ require 'rake/testtask'
27
27
 
28
- test_tasks = Dir['test/*/'].map { |d| File.basename(d) }
28
+ test_tasks = Dir['test/*/'].map { |d| File.basename(d) }
29
29
 
30
- test_tasks.each do |folder|
31
- Rake::TestTask.new("test:\#{folder}") do |test|
32
- test.pattern = "test/\#{folder}/**/*_test.rb"
33
- test.verbose = true
30
+ test_tasks.each do |folder|
31
+ Rake::TestTask.new("test:\#{folder}") do |test|
32
+ test.pattern = "test/\#{folder}/**/*_test.rb"
33
+ test.verbose = true
34
+ end
34
35
  end
35
- end
36
36
 
37
- desc "Run application test suite"
38
- task 'test' => test_tasks.map { |f| "test:\#{f}" }
37
+ desc "Run application test suite"
38
+ task 'test' => test_tasks.map { |f| "test:\#{f}" }
39
39
 
40
- task :default => :test
40
+ task default: :test
41
41
  TEST
42
42
 
43
- MINITEST_CONTROLLER_TEST = (<<-TEST).gsub(/^ {10}/, '') unless defined?(MINITEST_CONTROLLER_TEST)
44
- require File.expand_path(File.dirname(__FILE__) + '/../../test_config.rb')
43
+ MINITEST_CONTROLLER_TEST = <<~TEST.gsub(/^ {10}/, '') unless defined?(MINITEST_CONTROLLER_TEST)
44
+ require File.expand_path("\#{__dir__}/../../test_config.rb")
45
45
 
46
- describe "!PATH!" do
47
- before do
48
- get "!EXPANDED_PATH!"
49
- end
46
+ describe "!PATH!" do
47
+ before do
48
+ get "!EXPANDED_PATH!"
49
+ end
50
50
 
51
- it "should return hello world text" do
52
- assert_equal "Hello World", last_response.body
51
+ it "should return hello world text" do
52
+ assert_equal "Hello World", last_response.body
53
+ end
53
54
  end
54
- end
55
55
  TEST
56
56
 
57
- MINITEST_MODEL_TEST = (<<-TEST).gsub(/^ {10}/, '') unless defined?(MINITEST_MODEL_TEST)
58
- require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb')
57
+ MINITEST_MODEL_TEST = <<~TEST.gsub(/^ {10}/, '') unless defined?(MINITEST_MODEL_TEST)
58
+ require File.expand_path("\#{__dir__}!PATH!/test_config.rb")
59
59
 
60
- describe "!NAME! Model" do
61
- it 'can construct a new instance' do
62
- @!DNAME! = !NAME!.new
63
- refute_nil @!DNAME!
60
+ describe "!NAME! Model" do
61
+ it 'can construct a new instance' do
62
+ @!DNAME! = !NAME!.new
63
+ refute_nil @!DNAME!
64
+ end
64
65
  end
65
- end
66
66
  TEST
67
67
 
68
- MINITEST_HELPER_TEST = (<<-TEST) unless defined?(MINITEST_HELPER_TEST)
69
- require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb')
68
+ MINITEST_HELPER_TEST = <<~TEST unless defined?(MINITEST_HELPER_TEST)
69
+ require File.expand_path("\#{__dir__}!PATH!/test_config.rb")
70
70
 
71
- describe "!NAME!" do
72
- before do
73
- @helpers = Class.new
74
- @helpers.extend !NAME!
75
- end
71
+ describe "!NAME!" do
72
+ before do
73
+ @helpers = Class.new
74
+ @helpers.extend !NAME!
75
+ end
76
76
 
77
- def helpers
78
- @helpers
79
- end
77
+ def helpers
78
+ @helpers
79
+ end
80
80
 
81
- it "should return nil" do
82
- assert_nil helpers.foo
81
+ it "should return nil" do
82
+ assert_nil helpers.foo
83
+ end
83
84
  end
84
- end
85
85
  TEST
86
86
 
87
87
  def setup_test
88
- require_dependencies 'rack-test', :require => 'rack/test', :group => 'test'
89
- require_dependencies 'minitest', :require => 'minitest/autorun', :group => 'test'
88
+ require_dependencies 'rack-test', require: 'rack/test', group: 'test'
89
+ require_dependencies 'minitest', require: 'minitest/autorun', group: 'test'
90
90
  insert_test_suite_setup MINITEST_SETUP
91
- create_file destination_root("test/test.rake"), MINITEST_RAKE
91
+ create_file destination_root('test/test.rake'), MINITEST_RAKE
92
92
  end
93
93
 
94
94
  def generate_controller_test(name, path)
95
- minitest_contents = MINITEST_CONTROLLER_TEST.gsub(/!PATH!/, path).gsub(/!EXPANDED_PATH!/, path.gsub(/:\w+?_id/, "1"))
96
- controller_test_path = File.join('test',options[:app],'controllers',"#{name.to_s.underscore}_controller_test.rb")
97
- create_file destination_root(controller_test_path), minitest_contents, :skip => true
95
+ minitest_contents = MINITEST_CONTROLLER_TEST.gsub(/!PATH!/, path).gsub(/!EXPANDED_PATH!/, path.gsub(/:\w+?_id/, '1'))
96
+ controller_test_path = File.join('test', options[:app], 'controllers', "#{name.to_s.underscore}_controller_test.rb")
97
+ create_file destination_root(controller_test_path), minitest_contents, skip: true
98
98
  end
99
99
 
100
100
  def generate_model_test(name)
101
101
  minitest_contents = MINITEST_MODEL_TEST.gsub(/!NAME!/, name.to_s.underscore.camelize).gsub(/!DNAME!/, name.to_s.underscore)
102
102
  minitest_contents.gsub!(/!PATH!/, recognize_path)
103
- model_test_path = File.join('test',options[:app],'models',"#{name.to_s.underscore}_test.rb")
104
- create_file destination_root(model_test_path), minitest_contents, :skip => true
103
+ model_test_path = File.join('test', options[:app], 'models', "#{name.to_s.underscore}_test.rb")
104
+ create_file destination_root(model_test_path), minitest_contents, skip: true
105
105
  end
106
106
 
107
107
  def generate_helper_test(name, project_name, app_name)
108
108
  minitest_contents = MINITEST_HELPER_TEST.gsub(/!NAME!/, "#{project_name}::#{app_name}::#{name}")
109
109
  minitest_contents.gsub!(/!PATH!/, recognize_path)
110
110
  helper_spec_path = File.join('test', options[:app], 'helpers', "#{name.underscore}_test.rb")
111
- create_file destination_root(helper_spec_path), minitest_contents, :skip => true
111
+ create_file destination_root(helper_spec_path), minitest_contents, skip: true
112
112
  end