padrino-gen 0.9.18 → 0.9.19
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/padrino-gen/generators/actions.rb +5 -2
- data/lib/padrino-gen/generators/components/actions.rb +1 -1
- data/lib/padrino-gen/generators/components/mocks/mocha.rb +2 -0
- data/lib/padrino-gen/generators/components/mocks/rr.rb +2 -0
- data/lib/padrino-gen/generators/components/orms/activerecord.rb +2 -2
- data/lib/padrino-gen/generators/components/orms/couchrest.rb +1 -0
- data/lib/padrino-gen/generators/components/tests/cucumber.rb +2 -2
- data/lib/padrino-gen/generators/components/tests/rspec.rb +6 -6
- data/lib/padrino-gen/generators/components/tests/rspec1.rb +67 -0
- data/lib/padrino-gen/generators/components/tests/shoulda.rb +4 -1
- data/lib/padrino-gen/generators/plugin.rb +13 -3
- data/lib/padrino-gen/generators/project/public/index.html +48 -0
- data/lib/padrino-gen/generators/project.rb +10 -10
- data/lib/padrino-gen/generators/runner.rb +3 -3
- data/test/test_model_generator.rb +7 -6
- data/test/test_plugin_generator.rb +5 -5
- data/test/test_project_generator.rb +43 -6
- metadata +9 -7
@@ -197,10 +197,13 @@ module Padrino
|
|
197
197
|
template "templates/helper.rb.tt", destination_root(app, "helpers.rb")
|
198
198
|
@short_name = 'notifier'
|
199
199
|
template "templates/mailer.rb.tt", destination_root(app, "mailers.rb")
|
200
|
+
empty_directory destination_root(app, "views", "layouts")
|
200
201
|
empty_directory destination_root(app, "views", "mailers")
|
201
202
|
else # generate standard folders
|
202
|
-
empty_directory destination_root(
|
203
|
-
empty_directory destination_root(
|
203
|
+
empty_directory destination_root(app, 'controllers')
|
204
|
+
empty_directory destination_root(app, 'helpers')
|
205
|
+
empty_directory destination_root(app, 'views')
|
206
|
+
empty_directory destination_root(app, 'views', 'layouts')
|
204
207
|
end
|
205
208
|
end
|
206
209
|
|
@@ -8,7 +8,7 @@ module Padrino
|
|
8
8
|
# :down => "..text...", column_format => "t.column :#{field}, :#{kind}" }
|
9
9
|
def output_model_migration(filename, name, columns, options={})
|
10
10
|
if behavior == :revoke
|
11
|
-
remove_migration(
|
11
|
+
remove_migration(filename)
|
12
12
|
else
|
13
13
|
return if migration_exist?(filename)
|
14
14
|
model_name = name.to_s.pluralize
|
@@ -2,6 +2,8 @@ def setup_mock
|
|
2
2
|
require_dependencies 'mocha', :group => 'test'
|
3
3
|
case options[:test].to_s
|
4
4
|
when 'rspec'
|
5
|
+
inject_into_file 'spec/spec_helper.rb', " conf.mock_with :mocha\n", :after => "RSpec.configure do |conf|\n"
|
6
|
+
when 'rspec1'
|
5
7
|
inject_into_file 'spec/spec_helper.rb', " conf.mock_with :mocha\n", :after => "Spec::Runner.configure do |conf|\n"
|
6
8
|
else
|
7
9
|
insert_mocking_include "Mocha::API"
|
@@ -2,6 +2,8 @@ def setup_mock
|
|
2
2
|
require_dependencies 'rr', :group => 'test'
|
3
3
|
case options[:test].to_s
|
4
4
|
when 'rspec'
|
5
|
+
inject_into_file 'spec/spec_helper.rb', " conf.mock_with :rr\n", :after => "RSpec.configure do |conf|\n"
|
6
|
+
when 'rspec1'
|
5
7
|
inject_into_file 'spec/spec_helper.rb', " conf.mock_with :rr\n", :after => "Spec::Runner.configure do |conf|\n"
|
6
8
|
when 'riot'
|
7
9
|
inject_into_file "test/test_config.rb","require 'riot/rr'\n", :after => "\"/../config/boot\")\n"
|
@@ -92,12 +92,12 @@ def setup_orm
|
|
92
92
|
when 'mysql'
|
93
93
|
ar.gsub! /!DB_DEVELOPMENT!/, MYSQL.gsub(/!DB_NAME!/,"\"#{db}_development\"")
|
94
94
|
ar.gsub! /!DB_PRODUCTION!/, MYSQL.gsub(/!DB_NAME!/,"\"#{db}_production\"")
|
95
|
-
ar.gsub! /!DB_TEST
|
95
|
+
ar.gsub! /!DB_TEST!/, MYSQL.gsub(/!DB_NAME!/,"\"#{db}_test\"")
|
96
96
|
require_dependencies 'mysql'
|
97
97
|
when 'mysql2'
|
98
98
|
ar.gsub! /!DB_DEVELOPMENT!/, MYSQL2.gsub(/!DB_NAME!/,"\"#{db}_development\"")
|
99
99
|
ar.gsub! /!DB_PRODUCTION!/, MYSQL2.gsub(/!DB_NAME!/,"\"#{db}_production\"")
|
100
|
-
ar.gsub! /!DB_TEST
|
100
|
+
ar.gsub! /!DB_TEST!/, MYSQL2.gsub(/!DB_NAME!/,"\"#{db}_test\"")
|
101
101
|
require_dependencies 'mysql2'
|
102
102
|
when 'postgres'
|
103
103
|
ar.gsub! /!DB_DEVELOPMENT!/, POSTGRES.gsub(/!DB_NAME!/,"\"#{db}_development\"")
|
@@ -9,6 +9,7 @@ COUCHREST
|
|
9
9
|
|
10
10
|
def setup_orm
|
11
11
|
require_dependencies 'couchrest'
|
12
|
+
require_dependencies 'couchrest_extended_document'
|
12
13
|
require_dependencies 'json_pure'
|
13
14
|
create_file("config/database.rb", COUCHREST.gsub(/!NAME!/, @app_name.underscore))
|
14
15
|
empty_directory('app/models')
|
@@ -79,7 +79,7 @@ def setup_test
|
|
79
79
|
create_file destination_root("features/add.feature"), CUCUMBER_FEATURE
|
80
80
|
create_file destination_root("features/step_definitions/add_steps.rb"), CUCUMBER_STEP
|
81
81
|
create_file destination_root("cucumber.yml"), CUCUMBER_YML
|
82
|
-
require_dependencies 'rspec', :
|
82
|
+
require_dependencies 'rspec', :group => 'test'
|
83
83
|
insert_test_suite_setup RSPEC_SETUP, :path => "spec/spec_helper.rb"
|
84
84
|
create_file destination_root("spec/spec.rake"), RSPEC_RAKE
|
85
|
-
end
|
85
|
+
end
|
@@ -2,7 +2,7 @@ RSPEC_SETUP = (<<-TEST).gsub(/^ {12}/, '') unless defined?(RSPEC_SETUP)
|
|
2
2
|
PADRINO_ENV = 'test' unless defined?(PADRINO_ENV)
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
|
4
4
|
|
5
|
-
|
5
|
+
RSpec.configure do |conf|
|
6
6
|
conf.include Rack::Test::Methods
|
7
7
|
end
|
8
8
|
|
@@ -29,11 +29,11 @@ end
|
|
29
29
|
TEST
|
30
30
|
|
31
31
|
RSPEC_RAKE = (<<-TEST).gsub(/^ {12}/, '') unless defined?(RSPEC_RAKE)
|
32
|
-
require '
|
32
|
+
require 'rspec/core/rake_task'
|
33
33
|
|
34
|
-
|
35
|
-
t.
|
36
|
-
|
34
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
35
|
+
t.pattern = "./spec/**/*_spec.rb"
|
36
|
+
# Put spec opts in a file named .rspec in root
|
37
37
|
end
|
38
38
|
TEST
|
39
39
|
|
@@ -50,7 +50,7 @@ TEST
|
|
50
50
|
|
51
51
|
def setup_test
|
52
52
|
require_dependencies 'rack-test', :require => 'rack/test', :group => 'test'
|
53
|
-
require_dependencies 'rspec', :
|
53
|
+
require_dependencies 'rspec', :group => 'test'
|
54
54
|
insert_test_suite_setup RSPEC_SETUP, :path => "spec/spec_helper.rb"
|
55
55
|
create_file destination_root("spec/spec.rake"), RSPEC_RAKE
|
56
56
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
RSPEC_SETUP = (<<-TEST).gsub(/^ {12}/, '') unless defined?(RSPEC_SETUP)
|
2
|
+
PADRINO_ENV = 'test' unless defined?(PADRINO_ENV)
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
|
4
|
+
|
5
|
+
Spec::Runner.configure do |conf|
|
6
|
+
conf.include Rack::Test::Methods
|
7
|
+
end
|
8
|
+
|
9
|
+
def app
|
10
|
+
##
|
11
|
+
# You can handle all padrino applications using instead:
|
12
|
+
# Padrino.application
|
13
|
+
CLASS_NAME.tap { |app| }
|
14
|
+
end
|
15
|
+
TEST
|
16
|
+
|
17
|
+
RSPEC_CONTROLLER_TEST = (<<-TEST).gsub(/^ {12}/, '') unless defined?(RSPEC_CONTROLLER_TEST)
|
18
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
|
19
|
+
|
20
|
+
describe "!NAME!Controller" do
|
21
|
+
before do
|
22
|
+
get "/"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns hello world" do
|
26
|
+
last_response.body.should == "Hello World"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
TEST
|
30
|
+
|
31
|
+
RSPEC_RAKE = (<<-TEST).gsub(/^ {12}/, '') unless defined?(RSPEC_RAKE)
|
32
|
+
require 'spec/rake/spectask'
|
33
|
+
|
34
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
35
|
+
t.spec_files = Dir['spec/**/*_spec.rb']
|
36
|
+
t.spec_opts = %w(-fs --color)
|
37
|
+
end
|
38
|
+
TEST
|
39
|
+
|
40
|
+
RSPEC_MODEL_TEST = (<<-TEST).gsub(/^ {12}/, '') unless defined?(RSPEC_MODEL_TEST)
|
41
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
|
42
|
+
|
43
|
+
describe "!NAME! Model" do
|
44
|
+
let(:!DNAME!) { !NAME!.new }
|
45
|
+
it 'can be created' do
|
46
|
+
!DNAME!.should_not be_nil
|
47
|
+
end
|
48
|
+
end
|
49
|
+
TEST
|
50
|
+
|
51
|
+
def setup_test
|
52
|
+
require_dependencies 'rack-test', :require => 'rack/test', :group => 'test'
|
53
|
+
require_dependencies 'rspec', :version => "~> 1.2.3", :require => 'spec', :group => 'test'
|
54
|
+
insert_test_suite_setup RSPEC_SETUP, :path => "spec/spec_helper.rb"
|
55
|
+
create_file destination_root("spec/spec.rake"), RSPEC_RAKE
|
56
|
+
end
|
57
|
+
|
58
|
+
# Generates a controller test given the controllers name
|
59
|
+
def generate_controller_test(name)
|
60
|
+
rspec_contents = RSPEC_CONTROLLER_TEST.gsub(/!NAME!/, name.to_s.camelize)
|
61
|
+
create_file destination_root("spec/controllers/#{name.to_s.underscore}_controller_spec.rb"), rspec_contents, :skip => true
|
62
|
+
end
|
63
|
+
|
64
|
+
def generate_model_test(name)
|
65
|
+
rspec_contents = RSPEC_MODEL_TEST.gsub(/!NAME!/, name.to_s.camelize).gsub(/!DNAME!/, name.to_s.underscore)
|
66
|
+
create_file destination_root("spec/models/#{name.to_s.underscore}_spec.rb"), rspec_contents, :skip => true
|
67
|
+
end
|
@@ -42,7 +42,7 @@ TEST
|
|
42
42
|
SHOULDA_MODEL_TEST = (<<-TEST).gsub(/^ {10}/, '') unless defined?(SHOULDA_MODEL_TEST)
|
43
43
|
require File.expand_path(File.dirname(__FILE__) + '/../test_config.rb')
|
44
44
|
|
45
|
-
class !NAME!
|
45
|
+
class !NAME!Test < Test::Unit::TestCase
|
46
46
|
context "!NAME! Model" do
|
47
47
|
should 'construct new instance' do
|
48
48
|
@!DNAME! = !NAME!.new
|
@@ -56,6 +56,9 @@ def setup_test
|
|
56
56
|
require_dependencies 'rack-test', :require => 'rack/test', :group => 'test'
|
57
57
|
require_dependencies 'shoulda', :group => 'test'
|
58
58
|
insert_test_suite_setup SHOULDA_SETUP
|
59
|
+
if options[:orm] == "activerecord"
|
60
|
+
inject_into_file destination_root("test/test_config.rb"), "require 'shoulda/active_record'\n\n", :before => /class.*?\n/
|
61
|
+
end
|
59
62
|
create_file destination_root("test/test.rake"), SHOULDA_RAKE
|
60
63
|
end
|
61
64
|
|
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'padrino-core/cli/base' unless defined?(Padrino::Cli::Base)
|
2
|
+
require 'net/https'
|
2
3
|
|
3
4
|
module Padrino
|
4
5
|
module Generators
|
5
6
|
class Plugin < Thor::Group
|
6
|
-
PLUGIN_URL = '
|
7
|
+
PLUGIN_URL = 'https://github.com/padrino/padrino-recipes/tree/master/plugins'
|
7
8
|
# Add this generator to our padrino-gen
|
8
9
|
Padrino::Generators.add_generator(:plugin, self)
|
9
10
|
|
@@ -29,7 +30,16 @@ module Padrino
|
|
29
30
|
# Create the Padrino Plugin
|
30
31
|
def setup_plugin
|
31
32
|
if options[:list] # list method ran here
|
32
|
-
plugins =
|
33
|
+
plugins = {}
|
34
|
+
uri = URI.parse(PLUGIN_URL)
|
35
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
36
|
+
http.use_ssl = true if uri.scheme == "https"
|
37
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
38
|
+
http.start do
|
39
|
+
http.request_get(uri.path) do |res|
|
40
|
+
plugins = res.body.scan(%r{/plugins/(\w+)_plugin.rb}).uniq
|
41
|
+
end
|
42
|
+
end
|
33
43
|
say "Available plugins:", :green
|
34
44
|
say plugins.map { |plugin| " - #{plugin}" }.join("\n")
|
35
45
|
else # executing the plugin instructions
|
@@ -44,4 +54,4 @@ module Padrino
|
|
44
54
|
end
|
45
55
|
end # Plugins
|
46
56
|
end # Generators
|
47
|
-
end # Padrino
|
57
|
+
end # Padrino
|
@@ -0,0 +1,48 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<title>
|
7
|
+
Welcome to Padrino
|
8
|
+
</title>
|
9
|
+
<style type="text/css">
|
10
|
+
body{
|
11
|
+
font-family:Helvetica,Arial,sans-serif;
|
12
|
+
line-height:150%;
|
13
|
+
}
|
14
|
+
ul,li{
|
15
|
+
list-style-type:none;
|
16
|
+
margin:0px;
|
17
|
+
padding:5px 0px 5px 0px;
|
18
|
+
margin-left:5px;
|
19
|
+
}
|
20
|
+
a{
|
21
|
+
color:#333;
|
22
|
+
}
|
23
|
+
</style>
|
24
|
+
</head>
|
25
|
+
<body>
|
26
|
+
<h1>
|
27
|
+
Welcome to Padrino.rb
|
28
|
+
</h1>
|
29
|
+
<p>
|
30
|
+
Thanks for choosing Padrino for your Development.<br />
|
31
|
+
To get you started you we collected some Tutorials and Links:<br />
|
32
|
+
</p>
|
33
|
+
<ul>
|
34
|
+
<li>
|
35
|
+
<a href="http://www.padrinorb.com/guides/blog-tutorial">Blog Tutorial</a>
|
36
|
+
</li>
|
37
|
+
<li>
|
38
|
+
<a href="http://www.padrinorb.com/guides/generators">Generators</a>
|
39
|
+
</li>
|
40
|
+
<li>
|
41
|
+
<a href="http://www.padrinorb.com/guides/development-commands">Development Commands</a>
|
42
|
+
</li>
|
43
|
+
</ul>
|
44
|
+
<p>
|
45
|
+
To define a new default site for your project please delete this <em>index.html</em> file from the <em>public</em> directory.
|
46
|
+
</p>
|
47
|
+
</body>
|
48
|
+
</html>
|
@@ -21,17 +21,17 @@ module Padrino
|
|
21
21
|
|
22
22
|
argument :name, :desc => "The name of your padrino project"
|
23
23
|
|
24
|
-
class_option :app , :desc => "The application name",
|
25
|
-
class_option :bundle, :desc => "Run bundle install",
|
26
|
-
class_option :root, :desc => "The root destination",
|
27
|
-
class_option :dev, :desc => "Use padrino from a git checkout",
|
28
|
-
class_option :tiny, :desc => "Generate tiny app skeleton",
|
29
|
-
class_option :adapter, :desc => "SQL adapter for ORM (sqlite, mysql, postgres)", :aliases => '-a', :default => "sqlite", :type => :string
|
30
|
-
class_option :template, :desc => "Generate project from template",
|
24
|
+
class_option :app , :desc => "The application name", :aliases => '-n', :default => nil, :type => :string
|
25
|
+
class_option :bundle, :desc => "Run bundle install", :aliases => '-b', :default => false, :type => :boolean
|
26
|
+
class_option :root, :desc => "The root destination", :aliases => '-r', :default => ".", :type => :string
|
27
|
+
class_option :dev, :desc => "Use padrino from a git checkout", :default => false, :type => :boolean
|
28
|
+
class_option :tiny, :desc => "Generate tiny app skeleton", :aliases => '-i', :default => false, :type => :boolean
|
29
|
+
class_option :adapter, :desc => "SQL adapter for ORM (sqlite, mysql, mysql2, postgres)", :aliases => '-a', :default => "sqlite", :type => :string
|
30
|
+
class_option :template, :desc => "Generate project from template", :aliases => '-p', :default => nil, :type => :string
|
31
31
|
|
32
32
|
# Definitions for the available customizable components
|
33
33
|
component_option :orm, "database engine", :aliases => '-d', :choices => [:activerecord, :datamapper, :mongomapper, :mongoid, :sequel, :couchrest, :ohm, :mongomatic], :default => :none
|
34
|
-
component_option :test, "testing framework", :aliases => '-t', :choices => [:rspec, :shoulda, :cucumber, :bacon, :testspec, :riot], :default => :none
|
34
|
+
component_option :test, "testing framework", :aliases => '-t', :choices => [:rspec1, :rspec, :shoulda, :cucumber, :bacon, :testspec, :riot], :default => :none
|
35
35
|
component_option :mock, "mocking library", :aliases => '-m', :choices => [:mocha, :rr], :default => :none
|
36
36
|
component_option :script, "javascript library", :aliases => '-s', :choices => [:jquery, :prototype, :rightjs, :mootools, :extcore, :dojo], :default => :none
|
37
37
|
component_option :renderer, "template engine", :aliases => '-e', :choices => [:haml, :erb, :erubis, :liquid], :default => :haml
|
@@ -80,7 +80,7 @@ module Padrino
|
|
80
80
|
=================================================================
|
81
81
|
#{name} is ready for development! Next, follow these steps:
|
82
82
|
=================================================================
|
83
|
-
1) cd #{name}
|
83
|
+
1) cd #{options[:root]}/#{name}
|
84
84
|
=================================================================
|
85
85
|
|
86
86
|
TEXT
|
@@ -90,7 +90,7 @@ module Padrino
|
|
90
90
|
=================================================================
|
91
91
|
#{name} is ready for development! Next, follow these steps:
|
92
92
|
=================================================================
|
93
|
-
1) cd #{name}
|
93
|
+
1) cd #{options[:root]}/#{name}
|
94
94
|
2) bundle install
|
95
95
|
=================================================================
|
96
96
|
|
@@ -9,7 +9,7 @@ module Padrino
|
|
9
9
|
def project(options={})
|
10
10
|
components = options.map { |component, value| "--#{component}=#{value}" }
|
11
11
|
params = [name, *components].push("-r=#{destination_root("../")}")
|
12
|
-
say "=> Executing: padrino-gen
|
12
|
+
say "=> Executing: padrino-gen project #{params.join(" ")}", :magenta
|
13
13
|
Padrino.bin_gen(*params.unshift("project"))
|
14
14
|
end
|
15
15
|
|
@@ -77,9 +77,9 @@ module Padrino
|
|
77
77
|
template_file
|
78
78
|
when template_file =~ /gist/ && template_file !~ /raw/
|
79
79
|
raw_link, _ = *open(template_file).read.scan(/<a\s+href\s?\=\"(.*?)\"\>raw/)
|
80
|
-
raw_link ? "
|
80
|
+
raw_link ? "https://gist.github.com#{raw_link[0]}" : template_file
|
81
81
|
when File.extname(template_file).blank? # referencing official plugin (i.e hoptoad)
|
82
|
-
"
|
82
|
+
"https://github.com/padrino/padrino-recipes/raw/master/#{kind.to_s.pluralize}/#{template_file}_#{kind}.rb"
|
83
83
|
else # local file on system
|
84
84
|
File.expand_path(template_file)
|
85
85
|
end
|
@@ -314,7 +314,7 @@ class TestModelGenerator < Test::Unit::TestCase
|
|
314
314
|
should "generate test file for shoulda" do
|
315
315
|
silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=shoulda', '-d=activerecord') }
|
316
316
|
silence_logger { generate(:model, 'SomePerson', "-r=#{@apptmp}/sample_project") }
|
317
|
-
assert_match_in_file(/class
|
317
|
+
assert_match_in_file(/class SomePersonTest < Test::Unit::TestCase/m, "#{@apptmp}/sample_project/test/models/some_person_test.rb")
|
318
318
|
assert_match_in_file(/context "SomePerson Model"/m, "#{@apptmp}/sample_project/test/models/some_person_test.rb")
|
319
319
|
assert_match_in_file(/@some_person = SomePerson.new/m, "#{@apptmp}/sample_project/test/models/some_person_test.rb")
|
320
320
|
assert_match_in_file(/assert_not_nil @some_person/m, "#{@apptmp}/sample_project/test/models/some_person_test.rb")
|
@@ -348,12 +348,13 @@ class TestModelGenerator < Test::Unit::TestCase
|
|
348
348
|
assert_no_file_exists("#{@apptmp}/sample_project/spec/models/user_spec.rb")
|
349
349
|
end
|
350
350
|
|
351
|
-
should "destroy the model migration" do
|
351
|
+
should "destroy the right model migration" do
|
352
352
|
silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=rspec', '-d=activerecord') }
|
353
|
-
silence_logger { generate(:model, '
|
354
|
-
silence_logger { generate(:model, '
|
355
|
-
silence_logger { generate(:model, '
|
356
|
-
assert_no_file_exists("#{@apptmp}/sample_project/db/migrate/
|
353
|
+
silence_logger { generate(:model, 'bar_foo', "-r=#{@apptmp}/sample_project") }
|
354
|
+
silence_logger { generate(:model, 'foo', "-r=#{@apptmp}/sample_project") }
|
355
|
+
silence_logger { generate(:model, 'foo', "-r=#{@apptmp}/sample_project", '-d') }
|
356
|
+
assert_no_file_exists("#{@apptmp}/sample_project/db/migrate/002_create_foos.rb")
|
357
|
+
assert_file_exists("#{@apptmp}/sample_project/db/migrate/001_create_bar_foos.rb")
|
357
358
|
end
|
358
359
|
end
|
359
360
|
end
|
@@ -51,9 +51,9 @@ class TestPluginGenerator < Test::Unit::TestCase
|
|
51
51
|
end
|
52
52
|
|
53
53
|
should "resolve gist url properly" do
|
54
|
-
FakeWeb.register_uri(:get, "
|
55
|
-
template_file = '
|
56
|
-
resolved_path = '
|
54
|
+
FakeWeb.register_uri(:get, "https://gist.github.com/357045", :body => '<a href="/raw/357045/4356/blog_template.rb">raw</a>')
|
55
|
+
template_file = 'https://gist.github.com/357045'
|
56
|
+
resolved_path = 'https://gist.github.com/raw/357045/4356/blog_template.rb'
|
57
57
|
project_gen = Padrino::Generators::Project.new(['sample_project'], ["-p=#{template_file}", "-r=#{@apptmp}"], {})
|
58
58
|
project_gen.expects(:apply).with(resolved_path).returns(true).once
|
59
59
|
silence_logger { project_gen.invoke_all }
|
@@ -61,7 +61,7 @@ class TestPluginGenerator < Test::Unit::TestCase
|
|
61
61
|
|
62
62
|
should "resolve official template" do
|
63
63
|
template_file = 'sampleblog'
|
64
|
-
resolved_path = "
|
64
|
+
resolved_path = "https://github.com/padrino/padrino-recipes/raw/master/templates/sampleblog_template.rb"
|
65
65
|
project_gen = Padrino::Generators::Project.new(['sample_project'], ["-p=#{template_file}", "-r=#{@apptmp}"], {})
|
66
66
|
project_gen.expects(:apply).with(resolved_path).returns(true).once
|
67
67
|
silence_logger { project_gen.invoke_all }
|
@@ -76,7 +76,7 @@ class TestPluginGenerator < Test::Unit::TestCase
|
|
76
76
|
|
77
77
|
should "resolve official plugin" do
|
78
78
|
template_file = 'hoptoad'
|
79
|
-
resolved_path = "
|
79
|
+
resolved_path = "https://github.com/padrino/padrino-recipes/raw/master/plugins/hoptoad_plugin.rb"
|
80
80
|
plugin_gen = Padrino::Generators::Plugin.new([ template_file], ["-r=#{@apptmp}/sample_project"],{})
|
81
81
|
plugin_gen.expects(:in_app_root?).returns(true).once
|
82
82
|
plugin_gen.expects(:apply).with(resolved_path).returns(true).once
|
@@ -8,6 +8,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
8
8
|
|
9
9
|
def teardown
|
10
10
|
`rm -rf #{@apptmp}`
|
11
|
+
`rm -rf /tmp/project`
|
11
12
|
end
|
12
13
|
|
13
14
|
context 'the project generator' do
|
@@ -18,6 +19,8 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
18
19
|
assert_match_in_file(/Padrino.mount\("SampleProject"\).to\('\/'\)/,"#{@apptmp}/sample_project/config/apps.rb")
|
19
20
|
assert_file_exists("#{@apptmp}/sample_project/config/boot.rb")
|
20
21
|
assert_file_exists("#{@apptmp}/sample_project/public/favicon.ico")
|
22
|
+
assert_dir_exists("#{@apptmp}/sample_project/app/views")
|
23
|
+
assert_dir_exists("#{@apptmp}/sample_project/app/views/layouts")
|
21
24
|
end
|
22
25
|
|
23
26
|
should "generate a valid name" do
|
@@ -26,6 +29,13 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
26
29
|
assert_match_in_file(/class ProjectCom < Padrino::Application/,"#{@apptmp}/project.com/app/app.rb")
|
27
30
|
assert_match_in_file(/Padrino.mount\("ProjectCom"\).to\('\/'\)/,"#{@apptmp}/project.com/config/apps.rb")
|
28
31
|
end
|
32
|
+
|
33
|
+
should "display the right path" do
|
34
|
+
buffer = silence_logger { generate(:project, 'project', "--root=/tmp") }
|
35
|
+
assert_file_exists("/tmp/project")
|
36
|
+
assert_match(/cd \/tmp\/project/, buffer)
|
37
|
+
end
|
38
|
+
|
29
39
|
|
30
40
|
should "allow specifying alternate application name" do
|
31
41
|
assert_nothing_raised { silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--app=base_app') } }
|
@@ -44,6 +54,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
44
54
|
assert_file_exists("#{@apptmp}/sample_project/app/helpers.rb")
|
45
55
|
assert_file_exists("#{@apptmp}/sample_project/app/mailers.rb")
|
46
56
|
assert_dir_exists("#{@apptmp}/sample_project/app/views/mailers")
|
57
|
+
assert_dir_exists("#{@apptmp}/sample_project/app/views/layouts")
|
47
58
|
assert_match_in_file(/:notifier/,"#{@apptmp}/sample_project/app/mailers.rb")
|
48
59
|
assert_no_file_exists("#{@apptmp}/sample_project/demo/helpers")
|
49
60
|
assert_no_file_exists("#{@apptmp}/sample_project/demo/controllers")
|
@@ -128,6 +139,13 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
128
139
|
assert_match_in_file(/conf.mock_with :mocha/m, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
129
140
|
end
|
130
141
|
|
142
|
+
should "properly generate for mocha and rspec1" do
|
143
|
+
buffer = silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}",'--test=rspec1', '--mock=mocha', '--script=none') }
|
144
|
+
assert_match(/Applying.*?mocha.*?mock/, buffer)
|
145
|
+
assert_match_in_file(/gem 'mocha'/, "#{@apptmp}/sample_project/Gemfile")
|
146
|
+
assert_match_in_file(/conf.mock_with :mocha/m, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
147
|
+
end
|
148
|
+
|
131
149
|
should "properly generate for rr and rspec" do
|
132
150
|
buffer = silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=rspec', '--mock=rr', '--script=none') }
|
133
151
|
assert_match(/Applying.*?rr.*?mock/, buffer)
|
@@ -135,6 +153,13 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
135
153
|
assert_match_in_file(/conf.mock_with :rr/m, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
136
154
|
end
|
137
155
|
|
156
|
+
should "properly generate for rr and rspec1" do
|
157
|
+
buffer = silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=rspec1', '--mock=rr', '--script=none') }
|
158
|
+
assert_match(/Applying.*?rr.*?mock/, buffer)
|
159
|
+
assert_match_in_file(/gem 'rr'/, "#{@apptmp}/sample_project/Gemfile")
|
160
|
+
assert_match_in_file(/conf.mock_with :rr/m, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
161
|
+
end
|
162
|
+
|
138
163
|
end
|
139
164
|
|
140
165
|
context "the generator for orm components" do
|
@@ -278,7 +303,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
278
303
|
|
279
304
|
should "properly generate for ohm" do
|
280
305
|
buffer = silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=ohm', '--script=none') }
|
281
|
-
assert_match
|
306
|
+
assert_match(/Applying.*?ohm.*?orm/, buffer)
|
282
307
|
assert_match_in_file(/gem 'json'/, "#{@apptmp}/sample_project/Gemfile")
|
283
308
|
assert_match_in_file(/gem 'ohm'/, "#{@apptmp}/sample_project/Gemfile")
|
284
309
|
assert_match_in_file(/gem 'ohm-contrib', :require => "ohm\/contrib"/, "#{@apptmp}/sample_project/Gemfile")
|
@@ -288,7 +313,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
288
313
|
|
289
314
|
should "properly generate for mongomatic" do
|
290
315
|
buffer = silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=mongomatic', '--script=none') }
|
291
|
-
assert_match
|
316
|
+
assert_match(/Applying.*?mongomatic.*?orm/, buffer)
|
292
317
|
assert_match_in_file(/gem 'bson_ext'/, "#{@apptmp}/sample_project/Gemfile")
|
293
318
|
assert_match_in_file(/gem 'mongomatic'/, "#{@apptmp}/sample_project/Gemfile")
|
294
319
|
assert_match_in_file(/Mongomatic.db = Mongo::Connection.new.db/, "#{@apptmp}/sample_project/config/database.rb")
|
@@ -396,15 +421,27 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
396
421
|
assert_file_exists("#{@apptmp}/sample_project/test/test.rake")
|
397
422
|
end
|
398
423
|
|
424
|
+
should "properly generate for rspec1" do
|
425
|
+
buffer = silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=rspec1', '--script=none') }
|
426
|
+
assert_match(/Applying.*?rspec.*?test/, buffer)
|
427
|
+
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
428
|
+
assert_match_in_file(/:require => "rack\/test"/, "#{@apptmp}/sample_project/Gemfile")
|
429
|
+
assert_match_in_file(/:group => "test"/, "#{@apptmp}/sample_project/Gemfile")
|
430
|
+
assert_match_in_file(/gem 'rspec'.*?"~>\s*1.2.3".*?:require => "spec"/, "#{@apptmp}/sample_project/Gemfile")
|
431
|
+
assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
432
|
+
assert_match_in_file(/Spec::Runner/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
433
|
+
assert_file_exists("#{@apptmp}/sample_project/spec/spec.rake")
|
434
|
+
end
|
435
|
+
|
399
436
|
should "properly generate for rspec" do
|
400
437
|
buffer = silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=rspec', '--script=none') }
|
401
438
|
assert_match(/Applying.*?rspec.*?test/, buffer)
|
402
439
|
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
403
440
|
assert_match_in_file(/:require => "rack\/test"/, "#{@apptmp}/sample_project/Gemfile")
|
404
441
|
assert_match_in_file(/:group => "test"/, "#{@apptmp}/sample_project/Gemfile")
|
405
|
-
assert_match_in_file(/gem 'rspec'
|
442
|
+
assert_match_in_file(/gem 'rspec'/, "#{@apptmp}/sample_project/Gemfile")
|
406
443
|
assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
407
|
-
assert_match_in_file(/
|
444
|
+
assert_match_in_file(/RSpec.configure/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
408
445
|
assert_file_exists("#{@apptmp}/sample_project/spec/spec.rake")
|
409
446
|
end
|
410
447
|
|
@@ -438,12 +475,12 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
438
475
|
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
439
476
|
assert_match_in_file(/:require => "rack\/test"/, "#{@apptmp}/sample_project/Gemfile")
|
440
477
|
assert_match_in_file(/:group => "test"/, "#{@apptmp}/sample_project/Gemfile")
|
441
|
-
assert_match_in_file(/gem 'rspec'
|
478
|
+
assert_match_in_file(/gem 'rspec'/, "#{@apptmp}/sample_project/Gemfile")
|
442
479
|
assert_match_in_file(/gem 'cucumber'/, "#{@apptmp}/sample_project/Gemfile")
|
443
480
|
assert_match_in_file(/gem 'capybara'/, "#{@apptmp}/sample_project/Gemfile")
|
444
481
|
assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
445
482
|
assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, "#{@apptmp}/sample_project/features/support/env.rb")
|
446
|
-
assert_match_in_file(/
|
483
|
+
assert_match_in_file(/RSpec.configure/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
447
484
|
assert_match_in_file(/Capybara.app = /, "#{@apptmp}/sample_project/features/support/env.rb")
|
448
485
|
assert_match_in_file(/World\(Cucumber::Web::URLs\)/, "#{@apptmp}/sample_project/features/support/url.rb")
|
449
486
|
assert_file_exists("#{@apptmp}/sample_project/spec/spec.rake")
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-gen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 19
|
10
|
+
version: 0.9.19
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Padrino Team
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2010-
|
21
|
+
date: 2010-11-17 00:00:00 +01:00
|
22
22
|
default_executable: padrino-gen
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
@@ -29,12 +29,12 @@ dependencies:
|
|
29
29
|
requirements:
|
30
30
|
- - "="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
hash:
|
32
|
+
hash: 29
|
33
33
|
segments:
|
34
34
|
- 0
|
35
35
|
- 9
|
36
|
-
-
|
37
|
-
version: 0.9.
|
36
|
+
- 19
|
37
|
+
version: 0.9.19
|
38
38
|
type: :runtime
|
39
39
|
version_requirements: *id001
|
40
40
|
- !ruby/object:Gem::Dependency
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- lib/padrino-gen/generators/components/tests/cucumber.rb
|
120
120
|
- lib/padrino-gen/generators/components/tests/riot.rb
|
121
121
|
- lib/padrino-gen/generators/components/tests/rspec.rb
|
122
|
+
- lib/padrino-gen/generators/components/tests/rspec1.rb
|
122
123
|
- lib/padrino-gen/generators/components/tests/shoulda.rb
|
123
124
|
- lib/padrino-gen/generators/components/tests/testspec.rb
|
124
125
|
- lib/padrino-gen/generators/controller.rb
|
@@ -130,6 +131,7 @@ files:
|
|
130
131
|
- lib/padrino-gen/generators/project/config/boot.rb
|
131
132
|
- lib/padrino-gen/generators/project/config.ru
|
132
133
|
- lib/padrino-gen/generators/project/public/favicon.ico
|
134
|
+
- lib/padrino-gen/generators/project/public/index.html
|
133
135
|
- lib/padrino-gen/generators/project.rb
|
134
136
|
- lib/padrino-gen/generators/runner.rb
|
135
137
|
- lib/padrino-gen/generators/templates/controller.rb.tt
|