padrino-gen 0.12.2 → 0.12.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/padrino-gen/generators/actions.rb +30 -2
- data/lib/padrino-gen/generators/app.rb +10 -7
- data/lib/padrino-gen/generators/app/app.rb.tt +2 -2
- data/lib/padrino-gen/generators/components/tests/bacon.rb +1 -0
- data/lib/padrino-gen/generators/components/tests/cucumber.rb +1 -0
- data/lib/padrino-gen/generators/components/tests/minitest.rb +2 -1
- data/lib/padrino-gen/generators/components/tests/riot.rb +1 -0
- data/lib/padrino-gen/generators/components/tests/rspec.rb +22 -16
- data/lib/padrino-gen/generators/components/tests/shoulda.rb +2 -5
- data/lib/padrino-gen/generators/components/tests/steak.rb +1 -0
- data/lib/padrino-gen/generators/controller.rb +12 -11
- data/lib/padrino-gen/generators/model.rb +12 -9
- data/lib/padrino-gen/generators/project.rb +32 -2
- data/lib/padrino-gen/generators/project/.gitignore +0 -1
- data/lib/padrino-gen/generators/project/config/boot.rb +1 -1
- data/lib/padrino-gen/generators/templates/project_bin.tt +15 -0
- data/lib/padrino-gen/generators/templates/static/ujs/jquery.js +3 -3
- data/lib/padrino-gen/padrino-tasks/datamapper.rb +11 -13
- data/lib/padrino-gen/padrino-tasks/sql-helpers.rb +5 -2
- data/test/test_app_generator.rb +11 -0
- data/test/test_component_generator.rb +10 -14
- data/test/test_controller_generator.rb +12 -0
- data/test/test_model_generator.rb +8 -9
- data/test/test_plugin_generator.rb +2 -0
- data/test/test_project_generator.rb +89 -0
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9723f186fd87abe0b38622f0fa4fc17ad84686a2
|
4
|
+
data.tar.gz: abaefe256065c0c96e0765a3b9d28d8dfa80eb7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33a337375ecd93d5bd1fefd82c349f4c17dd31aad25fe0ca827374a7370e49024e7a377cae09bec6b10147fd2bdfbc8bfa85739102ea8ed85fa6175f11d8e720
|
7
|
+
data.tar.gz: 2ce9dcf92dc0aa13ab49d339af8590ad5add089e01ae3a61e77fee905f55fbaba3cd0642743b68380dc4cb5a8cde5b66ca95c29327da145f5e13f6e3aea974e0
|
@@ -3,12 +3,24 @@ module Padrino
|
|
3
3
|
# Raised when an application does not have a resolved root path.
|
4
4
|
class AppRootNotFound < RuntimeError; end
|
5
5
|
##
|
6
|
+
# Default helper name for use in tiny app skeleton generator.
|
7
|
+
#
|
8
|
+
DEFAULT_HELPER_NAME = "Helper".freeze
|
9
|
+
##
|
6
10
|
# Common actions needed to support project and component generation.
|
7
11
|
#
|
8
12
|
module Actions
|
9
13
|
def self.included(base)
|
10
14
|
base.extend(ClassMethods)
|
11
15
|
end
|
16
|
+
##
|
17
|
+
# Avoids editing destination file if it does not exist.
|
18
|
+
#
|
19
|
+
def inject_into_file(destination, *args, &block)
|
20
|
+
destination_path = destination.start_with?("/") ? destination : destination_root(destination)
|
21
|
+
return unless File.exist?(destination_path)
|
22
|
+
super
|
23
|
+
end
|
12
24
|
|
13
25
|
##
|
14
26
|
# Performs the necessary generator for a given component choice.
|
@@ -37,7 +49,7 @@ module Padrino
|
|
37
49
|
# The type of the component module.
|
38
50
|
#
|
39
51
|
# @example
|
40
|
-
#
|
52
|
+
# apply_component_for('rr', :mock)
|
41
53
|
#
|
42
54
|
def apply_component_for(choice, component)
|
43
55
|
# I need to override Thor#apply because for unknow reason :verbose => false break tasks.
|
@@ -335,7 +347,7 @@ WARNING
|
|
335
347
|
inject_into_file('config/boot.rb', " #{include_text}\n", :after => "Padrino.#{where} do\n")
|
336
348
|
end
|
337
349
|
|
338
|
-
|
350
|
+
##
|
339
351
|
# Inserts a middleware inside app.rb.
|
340
352
|
#
|
341
353
|
# @param [String] include_text
|
@@ -464,6 +476,7 @@ WARNING
|
|
464
476
|
directory('app/', destination_root(app))
|
465
477
|
if tiny
|
466
478
|
template 'templates/controller.rb.tt', destination_root(app, 'controllers.rb')
|
479
|
+
@helper_name = DEFAULT_HELPER_NAME
|
467
480
|
template 'templates/helper.rb.tt', destination_root(app, 'helpers.rb')
|
468
481
|
@short_name = 'notifier'
|
469
482
|
template 'templates/mailer.rb.tt', destination_root(app, 'mailers.rb')
|
@@ -502,6 +515,21 @@ WARNING
|
|
502
515
|
options[:app] == '.' ? '/..' : '/../..'
|
503
516
|
end
|
504
517
|
|
518
|
+
##
|
519
|
+
# Creates an empty directory with .keep file
|
520
|
+
#
|
521
|
+
def empty_directory_with_keep_file(destination, config = {})
|
522
|
+
empty_directory(destination, config)
|
523
|
+
keep_file(destination)
|
524
|
+
end
|
525
|
+
|
526
|
+
##
|
527
|
+
# Creates an empty .keep file
|
528
|
+
#
|
529
|
+
def keep_file(destination)
|
530
|
+
create_file("#{destination}/.keep")
|
531
|
+
end
|
532
|
+
|
505
533
|
# Class methods for Thor generators to support the generators and component choices.
|
506
534
|
module ClassMethods
|
507
535
|
##
|
@@ -17,10 +17,11 @@ module Padrino
|
|
17
17
|
|
18
18
|
desc "Description:\n\n\tpadrino-gen app generates a new Padrino application"
|
19
19
|
argument :name, :desc => 'The name of your padrino application'
|
20
|
-
class_option :root, :desc => 'The root destination',
|
21
|
-
class_option :destroy,
|
22
|
-
class_option :tiny, :desc => 'Generate tiny app skeleton',
|
23
|
-
class_option :namespace, :desc => 'The name space of your padrino project',
|
20
|
+
class_option :root, :desc => 'The root destination', :aliases => '-r', :default => '.', :type => :string
|
21
|
+
class_option :destroy, :aliases => '-d', :default => false, :type => :boolean
|
22
|
+
class_option :tiny, :desc => 'Generate tiny app skeleton', :aliases => '-i', :default => false, :type => :boolean
|
23
|
+
class_option :namespace, :desc => 'The name space of your padrino project', :aliases => '-n', :default => '', :type => :string
|
24
|
+
class_option :force, :desc => 'Generate app files if app already exists', :aliases => '-f', :default => false, :type => :boolean
|
24
25
|
|
25
26
|
# Show help if no ARGV given
|
26
27
|
require_arguments!
|
@@ -39,9 +40,11 @@ module Padrino
|
|
39
40
|
if options[:destroy]
|
40
41
|
self.behavior = :revoke
|
41
42
|
else
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
unless options[:force]
|
44
|
+
say "#{@app_name} already exists."
|
45
|
+
say "Please, change the name."
|
46
|
+
return
|
47
|
+
end
|
45
48
|
end if already_exists?(@app_name, @project_name)
|
46
49
|
|
47
50
|
lowercase_app_folder = @app_folder.downcase
|
@@ -1,6 +1,7 @@
|
|
1
1
|
BACON_SETUP = (<<-TEST).gsub(/^ {10}/, '') unless defined?(BACON_SETUP)
|
2
2
|
RACK_ENV = 'test' unless defined?(RACK_ENV)
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
|
4
|
+
Dir[File.expand_path(File.dirname(__FILE__) + "/../app/helpers/**/*.rb")].each(&method(:require))
|
4
5
|
|
5
6
|
class Bacon::Context
|
6
7
|
include Rack::Test::Methods
|
@@ -3,6 +3,7 @@ apply_component_for(:rspec, :test)
|
|
3
3
|
CUCUMBER_SETUP = (<<-TEST) unless defined?(CUCUMBER_SETUP)
|
4
4
|
RACK_ENV = 'test' unless defined?(RACK_ENV)
|
5
5
|
require File.expand_path(File.dirname(__FILE__) + "/../../config/boot")
|
6
|
+
Dir[File.expand_path(File.dirname(__FILE__) + "/../app/helpers/**/*.rb")].each(&method(:require))
|
6
7
|
|
7
8
|
require 'capybara/cucumber'
|
8
9
|
require 'rspec/expectations'
|
@@ -1,6 +1,7 @@
|
|
1
1
|
MINITEST_SETUP = (<<-TEST).gsub(/^ {10}/, '') unless defined?(MINITEST_SETUP)
|
2
2
|
RACK_ENV = 'test' unless defined?(RACK_ENV)
|
3
|
-
require File.expand_path(
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
|
4
|
+
Dir[File.expand_path(File.dirname(__FILE__) + "/../app/helpers/**/*.rb")].each(&method(:require))
|
4
5
|
|
5
6
|
class MiniTest::Spec
|
6
7
|
include Rack::Test::Methods
|
@@ -1,6 +1,7 @@
|
|
1
1
|
RIOT_SETUP = (<<-TEST).gsub(/^ {10}/, '') unless defined?(RIOT_SETUP)
|
2
2
|
RACK_ENV = 'test' unless defined?(RACK_ENV)
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
|
4
|
+
Dir[File.expand_path(File.dirname(__FILE__) + "/../app/helpers/**/*.rb")].each(&method(:require))
|
4
5
|
|
5
6
|
# Specify your app using the #app helper inside a context.
|
6
7
|
# Takes either an app class or a block argument.
|
@@ -1,6 +1,7 @@
|
|
1
1
|
RSPEC_SETUP = (<<-TEST).gsub(/^ {12}/, '') unless defined?(RSPEC_SETUP)
|
2
2
|
RACK_ENV = 'test' unless defined?(RACK_ENV)
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
|
4
|
+
Dir[File.expand_path(File.dirname(__FILE__) + "/../app/helpers/**/*.rb")].each(&method(:require))
|
4
5
|
|
5
6
|
RSpec.configure do |conf|
|
6
7
|
conf.include Rack::Test::Methods
|
@@ -24,13 +25,15 @@ TEST
|
|
24
25
|
RSPEC_CONTROLLER_TEST = (<<-TEST).gsub(/^ {12}/, '') unless defined?(RSPEC_CONTROLLER_TEST)
|
25
26
|
require 'spec_helper'
|
26
27
|
|
27
|
-
describe "!NAME!Controller" do
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
RSpec.describe "!NAME!Controller" do
|
29
|
+
pending "add some examples to \#{__FILE__}" do
|
30
|
+
before do
|
31
|
+
get "/"
|
32
|
+
end
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
+
it "returns hello world" do
|
35
|
+
expect(last_response.body).to eq "Hello World"
|
36
|
+
end
|
34
37
|
end
|
35
38
|
end
|
36
39
|
TEST
|
@@ -39,15 +42,15 @@ RSPEC_RAKE = (<<-TEST).gsub(/^ {12}/, '') unless defined?(RSPEC_RAKE)
|
|
39
42
|
begin
|
40
43
|
require 'rspec/core/rake_task'
|
41
44
|
|
42
|
-
spec_tasks = Dir['spec/*/'].
|
45
|
+
spec_tasks = Dir['spec/*/'].each_with_object([]) do |d, result|
|
43
46
|
result << File.basename(d) unless Dir["\#{d}*"].empty?
|
44
|
-
result
|
45
47
|
end
|
46
48
|
|
47
49
|
spec_tasks.each do |folder|
|
50
|
+
desc "Run the spec suite in \#{folder}"
|
48
51
|
RSpec::Core::RakeTask.new("spec:\#{folder}") do |t|
|
49
52
|
t.pattern = "./spec/\#{folder}/**/*_spec.rb"
|
50
|
-
t.rspec_opts =
|
53
|
+
t.rspec_opts = "--color"
|
51
54
|
end
|
52
55
|
end
|
53
56
|
|
@@ -61,20 +64,23 @@ TEST
|
|
61
64
|
RSPEC_MODEL_TEST = (<<-TEST).gsub(/^ {12}/, '') unless defined?(RSPEC_MODEL_TEST)
|
62
65
|
require 'spec_helper'
|
63
66
|
|
64
|
-
describe !NAME! do
|
67
|
+
RSpec.describe !NAME! do
|
68
|
+
pending "add some examples to (or delete) \#{__FILE__}"
|
65
69
|
end
|
66
70
|
TEST
|
67
71
|
|
68
72
|
RSPEC_HELPER_TEST = (<<-TEST) unless defined?(RSPEC_HELPER_TEST)
|
69
73
|
require 'spec_helper'
|
70
74
|
|
71
|
-
describe "!NAME!" do
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
+
RSpec.describe "!NAME!" do
|
76
|
+
pending "add some examples to (or delete) \#{__FILE__}" do
|
77
|
+
let(:helpers){ Class.new }
|
78
|
+
before { helpers.extend !NAME! }
|
79
|
+
subject { helpers }
|
75
80
|
|
76
|
-
|
77
|
-
|
81
|
+
it "should return nil" do
|
82
|
+
expect(subject.foo).to be_nil
|
83
|
+
end
|
78
84
|
end
|
79
85
|
end
|
80
86
|
TEST
|
@@ -1,6 +1,7 @@
|
|
1
1
|
SHOULDA_SETUP = (<<-TEST).gsub(/^ {10}/, '') unless defined?(SHOULDA_SETUP)
|
2
2
|
RACK_ENV = 'test' unless defined?(RACK_ENV)
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
|
4
|
+
Dir[File.expand_path(File.dirname(__FILE__) + "/../app/helpers/**/*.rb")].each(&method(:require))
|
4
5
|
|
5
6
|
require "test/unit"
|
6
7
|
|
@@ -78,12 +79,8 @@ class !NAME!Test < Test::Unit::TestCase
|
|
78
79
|
@helpers.extend !NAME!
|
79
80
|
end
|
80
81
|
|
81
|
-
def helpers
|
82
|
-
@helpers
|
83
|
-
end
|
84
|
-
|
85
82
|
should "return nil" do
|
86
|
-
assert_equal nil, helpers.foo
|
83
|
+
assert_equal nil, @helpers.foo
|
87
84
|
end
|
88
85
|
end
|
89
86
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
STEAK_SETUP = (<<-TEST).gsub(/^ {12}/, '') unless defined?(STEAK_SETUP)
|
2
2
|
RACK_ENV = 'test' unless defined?(RACK_ENV)
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
|
4
|
+
Dir[File.expand_path(File.dirname(__FILE__) + "/../app/helpers/**/*.rb")].each(&method(:require))
|
4
5
|
|
5
6
|
RSpec.configure do |conf|
|
6
7
|
conf.include Rack::Test::Methods
|
@@ -16,15 +16,16 @@ module Padrino
|
|
16
16
|
|
17
17
|
desc "Description:\n\n\tpadrino-gen controller generates a new Padrino controller"
|
18
18
|
|
19
|
-
argument :name,
|
20
|
-
argument :fields,
|
21
|
-
class_option :root,
|
22
|
-
class_option :app,
|
23
|
-
class_option :destroy,
|
24
|
-
class_option :namespace,
|
25
|
-
class_option :layout,
|
26
|
-
class_option :parent,
|
27
|
-
class_option :provides,
|
19
|
+
argument :name, :desc => 'The name of your padrino controller'
|
20
|
+
argument :fields, :desc => 'The fields for the controller', :default => [], :type => :array
|
21
|
+
class_option :root, :desc => 'The root destination', :aliases => '-r', :default => '.', :type => :string
|
22
|
+
class_option :app, :desc => 'The application destination path', :aliases => '-a', :default => '/app', :type => :string
|
23
|
+
class_option :destroy, :aliases => '-d', :default => false, :type => :boolean
|
24
|
+
class_option :namespace, :desc => 'The name space of your padrino project', :aliases => '-n', :default => '', :type => :string
|
25
|
+
class_option :layout, :desc => 'The layout for the controller', :aliases => '-l', :default => '', :type => :string
|
26
|
+
class_option :parent, :desc => 'The parent of the controller', :aliases => '-p', :default => '', :type => :string
|
27
|
+
class_option :provides, :desc => 'The formats provided by the controller', :aliases => '-f', :default => '', :type => :string
|
28
|
+
class_option :'no-helper',:desc => 'Not generate helper', :default => false, :type => :boolean
|
28
29
|
|
29
30
|
# Show help if no ARGV given
|
30
31
|
require_arguments!
|
@@ -52,12 +53,12 @@ module Padrino
|
|
52
53
|
|
53
54
|
self.behavior = :revoke if options[:destroy]
|
54
55
|
template 'templates/controller.rb.tt', destination_root(app, 'controllers', "#{name.to_s.underscore}.rb")
|
55
|
-
template 'templates/helper.rb.tt', destination_root(app, 'helpers', "#{name.to_s.underscore}_helper.rb")
|
56
|
+
template 'templates/helper.rb.tt', destination_root(app, 'helpers', "#{name.to_s.underscore}_helper.rb") unless options[:'no-helper']
|
56
57
|
empty_directory destination_root(app, "/views/#{name.to_s.underscore}")
|
57
58
|
include_component_module_for(:test)
|
58
59
|
if test?
|
59
60
|
generate_controller_test(name)
|
60
|
-
generate_helper_test(@helper_name, @project_name, @app_name)
|
61
|
+
generate_helper_test(@helper_name, @project_name, @app_name) unless options[:'no-helper']
|
61
62
|
end
|
62
63
|
else
|
63
64
|
say 'You are not at the root of a Padrino application! (config/boot.rb not found)'
|
@@ -15,12 +15,13 @@ module Padrino
|
|
15
15
|
|
16
16
|
desc "Description:\n\n\tpadrino-gen model generates a new model and migration files"
|
17
17
|
|
18
|
-
argument :name,
|
19
|
-
argument :fields,
|
20
|
-
class_option :root,
|
21
|
-
class_option :app,
|
22
|
-
class_option :destroy,
|
23
|
-
class_option :skip_migration,
|
18
|
+
argument :name, :desc => 'The name of your padrino model'
|
19
|
+
argument :fields, :desc => 'The fields for the model', :default => [], :type => :array
|
20
|
+
class_option :root, :desc => 'The root destination', :aliases => '-r', :default => '.', :type => :string
|
21
|
+
class_option :app, :desc => 'The application destination path', :aliases => '-a', :default => '.', :type => :string
|
22
|
+
class_option :destroy, :aliases => '-d', :default => false, :type => :boolean
|
23
|
+
class_option :skip_migration, :aliases => '-s', :default => false, :type => :boolean
|
24
|
+
class_option :force, :desc => 'Generate model files if app already exists', :aliases => '-f', :default => false, :type => :boolean
|
24
25
|
|
25
26
|
# Show help if no ARGV given.
|
26
27
|
require_arguments!
|
@@ -54,9 +55,11 @@ module Padrino
|
|
54
55
|
if options[:destroy]
|
55
56
|
self.behavior = :revoke
|
56
57
|
else
|
57
|
-
|
58
|
-
|
59
|
-
|
58
|
+
unless options[:force]
|
59
|
+
say "#{@camel_name} already exists."
|
60
|
+
say "Please, change the name."
|
61
|
+
return false
|
62
|
+
end
|
60
63
|
end if model_name_already_exists?
|
61
64
|
|
62
65
|
return false if has_invalid_fields?
|
@@ -55,7 +55,6 @@ module Padrino
|
|
55
55
|
empty_directory destination_root('public/images')
|
56
56
|
empty_directory destination_root('public/javascripts')
|
57
57
|
empty_directory destination_root('public/stylesheets')
|
58
|
-
empty_directory destination_root('tmp')
|
59
58
|
store_component_config('.components')
|
60
59
|
unless options[:lean]
|
61
60
|
app_skeleton('app', options[:tiny])
|
@@ -63,11 +62,16 @@ module Padrino
|
|
63
62
|
end
|
64
63
|
template 'templates/Gemfile.tt', destination_root('Gemfile')
|
65
64
|
template 'templates/Rakefile.tt', destination_root('Rakefile')
|
65
|
+
template 'templates/project_bin.tt', destination_root("bin/#{name}")
|
66
|
+
File.chmod(0755, destination_root("bin/#{name}"))
|
66
67
|
if options.gem?
|
67
68
|
template 'templates/gem/gemspec.tt', destination_root(name + '.gemspec')
|
68
69
|
template 'templates/gem/README.md.tt', destination_root('README.md')
|
69
70
|
template 'templates/gem/lib/libname.tt', destination_root("lib/#{name}.rb")
|
70
71
|
template 'templates/gem/lib/libname/version.tt', destination_root("lib/#{name}/version.rb")
|
72
|
+
else
|
73
|
+
empty_directory_with_keep_file destination_root('tmp')
|
74
|
+
empty_directory_with_keep_file destination_root('log')
|
71
75
|
end
|
72
76
|
end
|
73
77
|
end
|
@@ -87,6 +91,32 @@ module Padrino
|
|
87
91
|
store_component_choice(:migration_format, options[:migration_format])
|
88
92
|
end
|
89
93
|
|
94
|
+
##
|
95
|
+
# Generates test files for tiny app skeleton.
|
96
|
+
#
|
97
|
+
def setup_test_files
|
98
|
+
if options[:tiny] && @_components[:test] != :none
|
99
|
+
test_component = @_components[:test]
|
100
|
+
test_component = "rspec" if test_component == "cucumber"
|
101
|
+
uppercase_test_component = test_component.upcase
|
102
|
+
controller_template_name = "#{uppercase_test_component}_CONTROLLER_TEST"
|
103
|
+
helper_template_name = "#{uppercase_test_component}_HELPER_TEST"
|
104
|
+
return unless defined?(controller_template_name)
|
105
|
+
|
106
|
+
controller_content = instance_eval(controller_template_name).gsub(/!NAME!/, "")
|
107
|
+
helper_content = instance_eval(helper_template_name).gsub(/!NAME!/, "#{@project_name}::#{@app_name}::#{DEFAULT_HELPER_NAME}")
|
108
|
+
|
109
|
+
proc{|*args| args.map{|str| str.gsub!(/!PATH!/, recognize_path)} }.call(controller_content, helper_content)
|
110
|
+
|
111
|
+
directory_name = [:rspec, :steak].include?(test_component.to_sym) ? "spec" : "test"
|
112
|
+
base_path = File.join(directory_name, "app")
|
113
|
+
create_file destination_root("#{base_path}/controllers/controllers_#{directory_name}.rb"), controller_content, :skip => true
|
114
|
+
create_file destination_root("#{base_path}/helpers/helpers_#{directory_name}.rb"), helper_content, :skip => true
|
115
|
+
helper_path = destination_root(File.join(directory_name, "#{directory_name == "spec" ? "spec_helper" : "test_config"}.rb"))
|
116
|
+
gsub_file helper_path, %r{helpers/\*\*/\*\.rb}, "helpers.rb"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
90
120
|
##
|
91
121
|
# Bundle all required components using bundler and Gemfile.
|
92
122
|
#
|
@@ -106,7 +136,7 @@ module Padrino
|
|
106
136
|
say '=' * 65, :green
|
107
137
|
say "$ cd #{options[:root]}/#{name}"
|
108
138
|
say "$ bundle" unless options[:bundle]
|
109
|
-
say "="*65, :green
|
139
|
+
say "=" * 65, :green
|
110
140
|
say
|
111
141
|
end
|
112
142
|
|
@@ -13,7 +13,7 @@ Bundler.require(:default, RACK_ENV)
|
|
13
13
|
# Padrino::Logger::Config[:development][:log_level] = :devel
|
14
14
|
# Padrino::Logger::Config[:development][:log_static] = true
|
15
15
|
#
|
16
|
-
# ##
|
16
|
+
# ## Configure your I18n
|
17
17
|
#
|
18
18
|
# I18n.default_locale = :en
|
19
19
|
# I18n.enforce_available_locales = false
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
Dir.chdir(File.dirname(__FILE__)+'/..')
|
4
|
+
|
5
|
+
# Start the app with Padrino::Server
|
6
|
+
require 'rubygems'
|
7
|
+
require 'bundler/setup'
|
8
|
+
require 'padrino-core/cli/launcher'
|
9
|
+
|
10
|
+
ARGV.unshift('start') if ARGV.first.nil? || ARGV.first.start_with?('-')
|
11
|
+
Padrino::Cli::Launcher.start ARGV
|
12
|
+
|
13
|
+
# Start the app with Rack::Server
|
14
|
+
#require "rack"
|
15
|
+
#Rack::Server.start
|
@@ -26,7 +26,7 @@ $(function(){
|
|
26
26
|
* link_to 'sign out', '/logout', :confirm => 'Log out?'
|
27
27
|
**/
|
28
28
|
|
29
|
-
$('a[data-confirm]'
|
29
|
+
$(document).on('click', 'a[data-confirm]', function(e) {
|
30
30
|
var message = $(this).data('confirm');
|
31
31
|
if (!confirm(message)) { e.preventDefault(); e.stopped = true; }
|
32
32
|
});
|
@@ -36,7 +36,7 @@ $(function(){
|
|
36
36
|
* link_to 'add item', '/create', :remote => true
|
37
37
|
**/
|
38
38
|
|
39
|
-
$('a[data-remote=true]'
|
39
|
+
$(document).on('click', 'a[data-remote=true]', function(e) {
|
40
40
|
var element = $(this);
|
41
41
|
if (e.stopped) return;
|
42
42
|
e.preventDefault(); e.stopped = true;
|
@@ -51,7 +51,7 @@ $(function(){
|
|
51
51
|
* link_to 'delete item', '/destroy', :method => :delete
|
52
52
|
**/
|
53
53
|
|
54
|
-
$('a[data-method]:not([data-remote])'
|
54
|
+
$(document).on('click', 'a[data-method]:not([data-remote])', function(e) {
|
55
55
|
if (e.stopped) return;
|
56
56
|
JSAdapter.sendMethod($(this));
|
57
57
|
e.preventDefault(); e.stopped = true;
|
@@ -51,33 +51,31 @@ if PadrinoTasks.load?(:datamapper, defined?(DataMapper))
|
|
51
51
|
desc "Create the database"
|
52
52
|
task :create => :environment do
|
53
53
|
config = DataMapper.repository.adapter.options.symbolize_keys
|
54
|
+
adapter = config[:adapter]
|
54
55
|
user, password, host = config[:user], config[:password], config[:host]
|
55
|
-
|
56
|
+
|
57
|
+
database = config[:database] || config[:path]
|
58
|
+
database.sub!(/^\//,'') unless adapter.start_with?('sqlite')
|
59
|
+
|
56
60
|
charset = config[:charset] || ENV['CHARSET'] || 'utf8'
|
57
61
|
collation = config[:collation] || ENV['COLLATION'] || 'utf8_unicode_ci'
|
58
62
|
|
59
63
|
puts "=> Creating database '#{database}'"
|
60
|
-
|
61
|
-
DataMapper.setup(DataMapper.repository.name, config)
|
62
|
-
else
|
63
|
-
# require 'padrino-gen/padrino-tasks/sql-helpers'
|
64
|
-
Padrino::Generators::SqlHelpers.create_db(config[:adapter], user, password, host, database, charset, collation)
|
65
|
-
end
|
64
|
+
Padrino::Generators::SqlHelpers.create_db(adapter, user, password, host, database, charset, collation)
|
66
65
|
puts "<= dm:create executed"
|
67
66
|
end
|
68
67
|
|
69
68
|
desc "Drop the database (postgres and mysql only)"
|
70
69
|
task :drop => :environment do
|
71
70
|
config = DataMapper.repository.adapter.options.symbolize_keys
|
71
|
+
adapter = config[:adapter]
|
72
72
|
user, password, host = config[:user], config[:password], config[:host]
|
73
|
-
|
73
|
+
|
74
|
+
database = config[:database] || config[:path]
|
75
|
+
database.sub!(/^\//,'') unless adapter.start_with?('sqlite')
|
74
76
|
|
75
77
|
puts "=> Dropping database '#{database}'"
|
76
|
-
|
77
|
-
File.delete(config[:path]) if File.exist?(config[:path])
|
78
|
-
else
|
79
|
-
Padrino::Generators::SqlHelpers.drop_db(config[:adapter], user, password, host, database)
|
80
|
-
end
|
78
|
+
Padrino::Generators::SqlHelpers.drop_db(adapter, user, password, host, database)
|
81
79
|
puts "<= dm:drop executed"
|
82
80
|
end
|
83
81
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
1
3
|
module Padrino
|
2
4
|
module Generators
|
3
5
|
module SqlHelpers
|
@@ -26,8 +28,9 @@ module Padrino
|
|
26
28
|
arguments << "CREATE DATABASE #{database} DEFAULT CHARACTER SET #{charset} DEFAULT COLLATE #{collation}"
|
27
29
|
|
28
30
|
Process.wait Process.spawn(environment, 'mysql', *arguments)
|
29
|
-
when 'sqlite'
|
31
|
+
when 'sqlite', 'sqlite3'
|
30
32
|
fail "Database #{database} already exists" if File.file?(database)
|
33
|
+
FileUtils.mkdir_p(File.dirname(database))
|
31
34
|
File.open(database, 'a') {}
|
32
35
|
else
|
33
36
|
raise "Adapter #{adapter} not supported for creating databases yet."
|
@@ -58,7 +61,7 @@ module Padrino
|
|
58
61
|
arguments << "DROP DATABASE IF EXISTS #{database}"
|
59
62
|
|
60
63
|
Process.wait Process.spawn(environment, 'mysql', *arguments)
|
61
|
-
when 'sqlite'
|
64
|
+
when 'sqlite', 'sqlite3'
|
62
65
|
File.delete(database) if File.file?(database)
|
63
66
|
else
|
64
67
|
raise "Adapter #{adapter} not supported for dropping databases yet."
|
data/test/test_app_generator.rb
CHANGED
@@ -63,6 +63,8 @@ describe "AppGenerator" do
|
|
63
63
|
assert_file_exists("#{@apptmp}/sample_project/demo/mailers.rb")
|
64
64
|
assert_dir_exists("#{@apptmp}/sample_project/public/demo")
|
65
65
|
assert_match_in_file(/:notifier/,"#{@apptmp}/sample_project/demo/mailers.rb")
|
66
|
+
assert_match_in_file(/module Helper/, "#{@apptmp}/sample_project/demo/helpers.rb")
|
67
|
+
assert_match_in_file(/helpers Helper/, "#{@apptmp}/sample_project/demo/helpers.rb")
|
66
68
|
assert_no_file_exists("#{@apptmp}/sample_project/demo/helpers")
|
67
69
|
assert_no_file_exists("#{@apptmp}/sample_project/demo/controllers")
|
68
70
|
end
|
@@ -117,5 +119,14 @@ describe "AppGenerator" do
|
|
117
119
|
assert_file_exists("#{@apptmp}/sample_project/subapp/app.rb")
|
118
120
|
assert_match(/Subapp already exists/, out)
|
119
121
|
end
|
122
|
+
|
123
|
+
it 'should generate app files if :force option is specified' do
|
124
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}") }
|
125
|
+
out, err = capture_io { generate(:app, 'kernel', "--root=#{@apptmp}/sample_project", "--force") }
|
126
|
+
assert_dir_exists("#{@apptmp}/sample_project/public/kernel")
|
127
|
+
assert_dir_exists("#{@apptmp}/sample_project/kernel/controllers")
|
128
|
+
assert_dir_exists("#{@apptmp}/sample_project/kernel/helpers")
|
129
|
+
assert_file_exists("#{@apptmp}/sample_project/kernel/app.rb")
|
130
|
+
end
|
120
131
|
end
|
121
132
|
end
|
@@ -79,25 +79,21 @@ describe "ComponentGenerator" do
|
|
79
79
|
capture_io { generate(:project, 'sample_project', '-renderer=slim', "--root=#{@apptmp}") }
|
80
80
|
components_chosen = YAML.load_file("#{@apptmp}/sample_project/.components")
|
81
81
|
assert_equal 'slim', components_chosen[:renderer]
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
assert_equal 'haml', components_chosen[:renderer]
|
88
|
-
end
|
82
|
+
Readline.stubs(:readline).returns('yes').once
|
83
|
+
out, err = capture_io { generate(:component, '--renderer=haml', "-r=#{@apptmp}/sample_project") }
|
84
|
+
assert_match(/applying.*?haml.*?renderer/, out)
|
85
|
+
components_chosen = YAML.load_file("#{@apptmp}/sample_project/.components")
|
86
|
+
assert_equal 'haml', components_chosen[:renderer]
|
89
87
|
end
|
90
88
|
it 'should when deny changes, will not be applied' do
|
91
89
|
capture_io { generate(:project, 'sample_project', '-renderer=slim', "--root=#{@apptmp}") }
|
92
90
|
components_chosen = YAML.load_file("#{@apptmp}/sample_project/.components")
|
93
91
|
assert_equal 'slim', components_chosen[:renderer]
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
assert_equal 'slim', components_chosen[:renderer]
|
100
|
-
end
|
92
|
+
Readline.stubs(:readline).returns('no').once
|
93
|
+
out, err = capture_io { generate(:component, '--renderer=haml', "-r=#{@apptmp}/sample_project") }
|
94
|
+
refute_match(/applying.*?haml.*?renderer/, out)
|
95
|
+
components_chosen = YAML.load_file("#{@apptmp}/sample_project/.components")
|
96
|
+
assert_equal 'slim', components_chosen[:renderer]
|
101
97
|
end
|
102
98
|
end
|
103
99
|
|
@@ -185,6 +185,18 @@ describe "ControllerGenerator" do
|
|
185
185
|
assert_match_in_file(/get :test do\n\n end\n/m, @controller_path)
|
186
186
|
assert_match_in_file(/post :yada do\n\n end\n/m, @controller_path)
|
187
187
|
end
|
188
|
+
|
189
|
+
describe "with 'no-helper' option" do
|
190
|
+
it 'should not generate helper within existing project' do
|
191
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=rspec') }
|
192
|
+
capture_io { generate(:controller, 'DemoItems', "-r=#{@apptmp}/sample_project", '--no-helper') }
|
193
|
+
assert_file_exists("#{@apptmp}/sample_project/app/views/demo_items")
|
194
|
+
assert_file_exists("#{@apptmp}/sample_project/app/controllers/demo_items.rb")
|
195
|
+
assert_file_exists("#{@apptmp}/sample_project/spec/app/controllers/demo_items_controller_spec.rb")
|
196
|
+
assert_no_file_exists("#{@apptmp}/sample_project/app/helpers/demo_items_helper.rb")
|
197
|
+
assert_no_file_exists("#{@apptmp}/sample_project/spec/app/helpers/demo_items_helper_spec.rb")
|
198
|
+
end
|
199
|
+
end
|
188
200
|
end
|
189
201
|
|
190
202
|
describe "the controller destroy option" do
|
@@ -57,15 +57,6 @@ describe "ModelGenerator" do
|
|
57
57
|
assert_match_in_file(/DataMapper.finalize/m,"#{@apptmp}/sample_project/config/boot.rb")
|
58
58
|
end
|
59
59
|
|
60
|
-
it 'should generate only generate model once' do
|
61
|
-
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
|
62
|
-
response_success = capture_io { generate(:model, 'user', "-r=#{@apptmp}/sample_project") }
|
63
|
-
out, err = capture_io { generate(:model, 'user', "-r=#{@apptmp}/sample_project") }
|
64
|
-
assert_match_in_file(/class User < ActiveRecord::Base/m, "#{@apptmp}/sample_project/models/user.rb")
|
65
|
-
assert_match(/identical\e\[0m models\/user\.rb/, out)
|
66
|
-
assert_match(/identical\e\[0m test\/models\/user_test\.rb/, out)
|
67
|
-
end
|
68
|
-
|
69
60
|
it 'should generate migration file versions properly' do
|
70
61
|
capture_io { generate(:project, 'sample_project', "--migration_format=number", "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
|
71
62
|
capture_io { generate(:model, 'user', "-r=#{@apptmp}/sample_project") }
|
@@ -114,6 +105,14 @@ describe "ModelGenerator" do
|
|
114
105
|
assert_no_file_exists("#{@apptmp}/sample_project/models/user.rb")
|
115
106
|
assert_match(/User already exists/, out)
|
116
107
|
end
|
108
|
+
|
109
|
+
it 'should generate model files if :force option is specified' do
|
110
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", "-d=activerecord") }
|
111
|
+
capture_io { generate(:app, 'user', "--root=#{@apptmp}/sample_project") }
|
112
|
+
out, err = capture_io { generate_with_parts(:model, 'user', "--root=#{@apptmp}/sample_project", "--force", :apps => "user") }
|
113
|
+
assert_file_exists("#{@apptmp}/sample_project/user/app.rb")
|
114
|
+
assert_file_exists("#{@apptmp}/sample_project/models/user.rb")
|
115
|
+
end
|
117
116
|
end
|
118
117
|
|
119
118
|
# ACTIVERECORD
|
@@ -39,12 +39,14 @@ describe "PluginGenerator" do
|
|
39
39
|
expects_generated :migration, "AddEmailToUser email:string -r=#{@apptmp}/sample_project"
|
40
40
|
expects_generated :fake, "foo bar -r=#{@apptmp}/sample_project"
|
41
41
|
expects_generated :plugin, "carrierwave -r=#{@apptmp}/sample_project"
|
42
|
+
File.stubs(:exist?).returns(true)
|
42
43
|
expects_dependencies 'nokogiri'
|
43
44
|
expects_initializer :test, "# Example", :root => "#{@apptmp}/sample_project"
|
44
45
|
expects_generated :app, "testapp -r=#{@apptmp}/sample_project"
|
45
46
|
expects_generated :controller, "users get:index -r=#{@apptmp}/sample_project --app=testapp"
|
46
47
|
example_template_path = File.join(File.dirname(__FILE__), 'fixtures', 'example_template.rb')
|
47
48
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", "-p=#{example_template_path}", '> /dev/null') }
|
49
|
+
File.unstub(:exist?)
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
@@ -20,6 +20,7 @@ describe "ProjectGenerator" do
|
|
20
20
|
assert_match_in_file("Padrino.mount('SampleProject::App', :app_file => Padrino.root('app/app.rb')).to('/')", "#{@apptmp}/sample_project/config/apps.rb")
|
21
21
|
assert_file_exists("#{@apptmp}/sample_project/config/boot.rb")
|
22
22
|
assert_file_exists("#{@apptmp}/sample_project/Rakefile")
|
23
|
+
assert_file_exists("#{@apptmp}/sample_project/bin/sample_project")
|
23
24
|
assert_file_exists("#{@apptmp}/sample_project/public/favicon.ico")
|
24
25
|
assert_dir_exists("#{@apptmp}/sample_project/public/images")
|
25
26
|
assert_dir_exists("#{@apptmp}/sample_project/public/javascripts")
|
@@ -93,6 +94,11 @@ describe "ProjectGenerator" do
|
|
93
94
|
assert_no_match_in_file(/Padrino.mount\('SampleProject::App'/, "#{@apptmp}/sample_project/config/apps.rb")
|
94
95
|
end
|
95
96
|
|
97
|
+
it 'should generate lean project correctly even if the component is specified' do
|
98
|
+
out, err = capture_io { generate(:project,'sample_project', '--lean', "--root=#{@apptmp}", "--orm=activerecord", "--stylesheet=compass") }
|
99
|
+
assert_match("", err)
|
100
|
+
end
|
101
|
+
|
96
102
|
it 'should generate tiny skeleton' do
|
97
103
|
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}") }
|
98
104
|
assert_file_exists("#{@apptmp}/sample_project")
|
@@ -104,6 +110,8 @@ describe "ProjectGenerator" do
|
|
104
110
|
assert_dir_exists("#{@apptmp}/sample_project/public/javascripts")
|
105
111
|
assert_dir_exists("#{@apptmp}/sample_project/public/stylesheets")
|
106
112
|
assert_match_in_file(/:notifier/,"#{@apptmp}/sample_project/app/mailers.rb")
|
113
|
+
assert_match_in_file(/module Helper/, "#{@apptmp}/sample_project/app/helpers.rb")
|
114
|
+
assert_match_in_file(/helpers Helper/, "#{@apptmp}/sample_project/app/helpers.rb")
|
107
115
|
assert_no_file_exists("#{@apptmp}/sample_project/demo/helpers")
|
108
116
|
assert_no_file_exists("#{@apptmp}/sample_project/demo/controllers")
|
109
117
|
end
|
@@ -115,6 +123,8 @@ describe "ProjectGenerator" do
|
|
115
123
|
assert_match_in_file(/^module SampleGem/,"#{@apptmp}/sample_gem/app/app.rb")
|
116
124
|
assert_match_in_file(/class App/,"#{@apptmp}/sample_gem/app/app.rb")
|
117
125
|
assert_file_exists("#{@apptmp}/sample_gem/README.md")
|
126
|
+
assert_no_file_exists("#{@apptmp}/sample_gem/tmp/.keep")
|
127
|
+
assert_no_file_exists("#{@apptmp}/sample_gem/log/.keep")
|
118
128
|
end
|
119
129
|
|
120
130
|
it 'should generate gemspec and special files with dashes in name' do
|
@@ -192,6 +202,12 @@ describe "ProjectGenerator" do
|
|
192
202
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none') }
|
193
203
|
assert_match_in_file(/gem 'padrino'/, "#{@apptmp}/sample_project/Gemfile")
|
194
204
|
end
|
205
|
+
|
206
|
+
it 'should create .keep files for empty directories that are required for running application' do
|
207
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", "--stylesheet=sass", "--orm=sequel") }
|
208
|
+
assert_file_exists("#{@apptmp}/sample_project/tmp/.keep")
|
209
|
+
assert_file_exists("#{@apptmp}/sample_project/log/.keep")
|
210
|
+
end
|
195
211
|
end
|
196
212
|
|
197
213
|
describe "a generator for mock component" do
|
@@ -659,4 +675,77 @@ describe "ProjectGenerator" do
|
|
659
675
|
assert_dir_exists("#{@apptmp}/sample_project/app/stylesheets")
|
660
676
|
end
|
661
677
|
end
|
678
|
+
|
679
|
+
describe "tiny app skeleton generator for test component" do
|
680
|
+
it "should properly generate for rspec" do
|
681
|
+
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}", "--test=rspec") }
|
682
|
+
assert_dir_exists("#{@apptmp}/sample_project/spec/")
|
683
|
+
assert_file_exists("#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
684
|
+
assert_file_exists("#{@apptmp}/sample_project/spec/app/helpers/helpers_spec.rb")
|
685
|
+
assert_match_in_file(/Dir\[File\.expand_path\(File\.dirname\(__FILE__\) \+ "\/\.\.\/app\/helpers\.rb"\)\]\.each\(&method\(:require\)\)/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
686
|
+
assert_match_in_file(/RSpec\.describe "Controller" do/, "#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
687
|
+
assert_match_in_file(/RSpec.describe "SampleProject::App::Helper" do/, "#{@apptmp}/sample_project/spec/app/helpers/helpers_spec.rb")
|
688
|
+
end
|
689
|
+
|
690
|
+
it "should properly generate for steak" do
|
691
|
+
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}", "--test=steak") }
|
692
|
+
assert_dir_exists("#{@apptmp}/sample_project/spec/")
|
693
|
+
assert_file_exists("#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
694
|
+
assert_file_exists("#{@apptmp}/sample_project/spec/app/helpers/helpers_spec.rb")
|
695
|
+
assert_match_in_file(/Dir\[File\.expand_path\(File\.dirname\(__FILE__\) \+ "\/\.\.\/app\/helpers\.rb"\)\]\.each\(&method\(:require\)\)/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
696
|
+
assert_match_in_file(/describe "Controller" do/, "#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
697
|
+
assert_match_in_file(/describe "SampleProject::App::Helper" do/, "#{@apptmp}/sample_project/spec/app/helpers/helpers_spec.rb")
|
698
|
+
end
|
699
|
+
|
700
|
+
it "should properly generate for cucumber" do
|
701
|
+
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}", "--test=cucumber") }
|
702
|
+
assert_dir_exists("#{@apptmp}/sample_project/spec/")
|
703
|
+
assert_file_exists("#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
704
|
+
assert_file_exists("#{@apptmp}/sample_project/spec/app/helpers/helpers_spec.rb")
|
705
|
+
assert_match_in_file(/Dir\[File\.expand_path\(File\.dirname\(__FILE__\) \+ "\/\.\.\/app\/helpers\.rb"\)\]\.each\(&method\(:require\)\)/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
706
|
+
assert_match_in_file(/describe "Controller" do/, "#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
707
|
+
assert_match_in_file(/describe "SampleProject::App::Helper" do/, "#{@apptmp}/sample_project/spec/app/helpers/helpers_spec.rb")
|
708
|
+
end
|
709
|
+
|
710
|
+
it "should properly generate for bacon" do
|
711
|
+
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}", "--test=bacon") }
|
712
|
+
assert_dir_exists("#{@apptmp}/sample_project/test/")
|
713
|
+
assert_file_exists("#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
714
|
+
assert_file_exists("#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
715
|
+
assert_match_in_file(/Dir\[File\.expand_path\(File\.dirname\(__FILE__\) \+ "\/\.\.\/app\/helpers\.rb"\)\]\.each\(&method\(:require\)\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
716
|
+
assert_match_in_file(/describe "Controller" do/, "#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
717
|
+
assert_match_in_file(/describe "SampleProject::App::Helper"/, "#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
718
|
+
end
|
719
|
+
|
720
|
+
it "should properly generate for minitest" do
|
721
|
+
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}", "--test=minitest") }
|
722
|
+
assert_dir_exists("#{@apptmp}/sample_project/test/")
|
723
|
+
assert_file_exists("#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
724
|
+
assert_file_exists("#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
725
|
+
assert_match_in_file(/Dir\[File\.expand_path\(File\.dirname\(__FILE__\) \+ "\/\.\.\/app\/helpers\.rb"\)\]\.each\(&method\(:require\)\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
726
|
+
assert_match_in_file(/describe "Controller" do/, "#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
727
|
+
assert_match_in_file(/describe "SampleProject::App::Helper"/, "#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
728
|
+
end
|
729
|
+
|
730
|
+
it "should properly generate for riot" do
|
731
|
+
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}", "--test=riot") }
|
732
|
+
assert_dir_exists("#{@apptmp}/sample_project/test/")
|
733
|
+
assert_file_exists("#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
734
|
+
assert_file_exists("#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
735
|
+
assert_match_in_file(/Dir\[File\.expand_path\(File\.dirname\(__FILE__\) \+ "\/\.\.\/app\/helpers\.rb"\)\]\.each\(&method\(:require\)\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
736
|
+
assert_match_in_file(/context "Controller" do/, "#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
737
|
+
assert_match_in_file(/describe "SampleProject::App::Helper"/, "#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
738
|
+
end
|
739
|
+
|
740
|
+
it "should properly generate for shoulda" do
|
741
|
+
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}", "--test=shoulda") }
|
742
|
+
assert_dir_exists("#{@apptmp}/sample_project/test/")
|
743
|
+
assert_file_exists("#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
744
|
+
assert_file_exists("#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
745
|
+
assert_match_in_file(/Dir\[File\.expand_path\(File\.dirname\(__FILE__\) \+ "\/\.\.\/app\/helpers\.rb"\)\]\.each\(&method\(:require\)\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
746
|
+
assert_match_in_file(/class ControllerTest < Test::Unit::TestCase/, "#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
747
|
+
assert_match_in_file(/class SampleProject::App::HelperTest < Test::Unit::TestCase/, "#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
748
|
+
end
|
749
|
+
|
750
|
+
end
|
662
751
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-gen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Padrino Team
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-
|
14
|
+
date: 2014-08-13 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: padrino-core
|
@@ -19,14 +19,14 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - '='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.12.
|
22
|
+
version: 0.12.3
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.12.
|
29
|
+
version: 0.12.3
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: bundler
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -47,28 +47,28 @@ dependencies:
|
|
47
47
|
requirements:
|
48
48
|
- - '='
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version: 0.12.
|
50
|
+
version: 0.12.3
|
51
51
|
type: :development
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
55
|
- - '='
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: 0.12.
|
57
|
+
version: 0.12.3
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: padrino-mailer
|
60
60
|
requirement: !ruby/object:Gem::Requirement
|
61
61
|
requirements:
|
62
62
|
- - '='
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version: 0.12.
|
64
|
+
version: 0.12.3
|
65
65
|
type: :development
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
69
|
- - '='
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version: 0.12.
|
71
|
+
version: 0.12.3
|
72
72
|
description: Generators for easily creating and building padrino applications from
|
73
73
|
the console
|
74
74
|
email: padrinorb@gmail.com
|
@@ -152,6 +152,7 @@ files:
|
|
152
152
|
- lib/padrino-gen/generators/templates/helper.rb.tt
|
153
153
|
- lib/padrino-gen/generators/templates/initializer.rb.tt
|
154
154
|
- lib/padrino-gen/generators/templates/mailer.rb.tt
|
155
|
+
- lib/padrino-gen/generators/templates/project_bin.tt
|
155
156
|
- lib/padrino-gen/generators/templates/task.rb.tt
|
156
157
|
- lib/padrino-gen/padrino-tasks/activerecord.rb
|
157
158
|
- lib/padrino-gen/padrino-tasks/database.rb
|