padrino-gen 0.10.2 → 0.10.3
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.
- data/.document +3 -3
- data/.yardopts +1 -0
- data/{LICENSE → LICENSE.txt} +0 -0
- data/README.rdoc +1 -1
- data/lib/padrino-gen/command.rb +7 -0
- data/lib/padrino-gen/generators/actions.rb +264 -24
- data/lib/padrino-gen/generators/app/app.rb.tt +11 -11
- data/lib/padrino-gen/generators/app.rb +10 -9
- data/lib/padrino-gen/generators/cli.rb +3 -0
- data/lib/padrino-gen/generators/components/actions.rb +86 -11
- data/lib/padrino-gen/generators/components/mocks/rr.rb +3 -1
- data/lib/padrino-gen/generators/components/orms/mongoid.rb +1 -1
- data/lib/padrino-gen/generators/components/orms/mongomapper.rb +1 -1
- data/lib/padrino-gen/generators/components/orms/mongomatic.rb +1 -1
- data/lib/padrino-gen/generators/components/stylesheets/less.rb +1 -1
- data/lib/padrino-gen/generators/components/tests/minitest.rb +78 -0
- data/lib/padrino-gen/generators/controller.rb +3 -0
- data/lib/padrino-gen/generators/mailer.rb +3 -0
- data/lib/padrino-gen/generators/model.rb +3 -0
- data/lib/padrino-gen/generators/plugin.rb +2 -0
- data/lib/padrino-gen/generators/project.rb +11 -3
- data/lib/padrino-gen/generators/runner.rb +85 -34
- data/lib/padrino-gen/generators/templates/Gemfile.tt +12 -21
- data/lib/padrino-gen/padrino-tasks/activerecord.rb +0 -194
- data/lib/padrino-gen.rb +21 -0
- data/test/helper.rb +2 -20
- data/test/test_app_generator.rb +17 -17
- data/test/test_cli.rb +6 -5
- data/test/test_controller_generator.rb +52 -44
- data/test/test_generator.rb +1 -1
- data/test/test_mailer_generator.rb +18 -18
- data/test/test_migration_generator.rb +44 -44
- data/test/test_model_generator.rb +140 -123
- data/test/test_plugin_generator.rb +21 -33
- data/test/test_project_generator.rb +125 -103
- metadata +10 -8
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/helper')
|
2
2
|
|
3
|
-
|
3
|
+
describe "PluginGenerator" do
|
4
4
|
def setup
|
5
5
|
@apptmp = "#{Dir.tmpdir}/padrino-tests/#{UUID.new.generate}"
|
6
6
|
`mkdir -p #{@apptmp}`
|
@@ -13,9 +13,9 @@ class TestPluginGenerator < Test::Unit::TestCase
|
|
13
13
|
context "the plugin destroy option" do
|
14
14
|
should "remove the plugin instance" do
|
15
15
|
path = File.expand_path('../fixtures/plugin_template.rb', __FILE__)
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}") }
|
17
|
+
capture_io { generate(:plugin, path, "--root=#{@apptmp}/sample_project") }
|
18
|
+
capture_io { generate(:plugin, path, "--root=#{@apptmp}/sample_project", '-d') }
|
19
19
|
assert_no_file_exists("#{@apptmp}/sample_project/lib/hoptoad_init.rb")
|
20
20
|
assert_no_match_in_file(/enable \:raise_errors/,"#{@apptmp}/sample_project/app/app.rb")
|
21
21
|
assert_no_match_in_file(/rack\_hoptoad/, "#{@apptmp}/sample_project/Gemfile")
|
@@ -23,12 +23,7 @@ class TestPluginGenerator < Test::Unit::TestCase
|
|
23
23
|
end
|
24
24
|
|
25
25
|
context 'the project generator with template' do
|
26
|
-
|
27
|
-
example_template_path = File.join(File.dirname(__FILE__), 'fixtures', 'example_template.rb')
|
28
|
-
silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", "-p=#{example_template_path}", '> /dev/null') }
|
29
|
-
end
|
30
|
-
|
31
|
-
before_should "invoke Padrino.bin_gen" do
|
26
|
+
should "invoke Padrino.bin_gen" do
|
32
27
|
expects_generated_project :name => 'sample_project', :test => :shoulda, :orm => :activerecord, :dev => true, :template => 'mongochist', :root => @apptmp
|
33
28
|
expects_generated :model, "post title:string body:text -r=#{@apptmp}/sample_project"
|
34
29
|
expects_generated :controller, "posts get:index get:new post:new -r=#{@apptmp}/sample_project"
|
@@ -39,6 +34,8 @@ class TestPluginGenerator < Test::Unit::TestCase
|
|
39
34
|
expects_initializer :test, "# Example", :root => "#{@apptmp}/sample_project"
|
40
35
|
expects_generated :app, "testapp -r=#{@apptmp}/sample_project"
|
41
36
|
expects_generated :controller, "users get:index -r=#{@apptmp}/sample_project --app=testapp"
|
37
|
+
example_template_path = File.join(File.dirname(__FILE__), 'fixtures', 'example_template.rb')
|
38
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", "-p=#{example_template_path}", '> /dev/null') }
|
42
39
|
end
|
43
40
|
end
|
44
41
|
|
@@ -48,7 +45,7 @@ class TestPluginGenerator < Test::Unit::TestCase
|
|
48
45
|
template_file = 'http://www.example.com/test.rb'
|
49
46
|
project_gen = Padrino::Generators::Project.new(['sample_project'], ["-p=#{template_file}", "-r=#{@apptmp}"], {})
|
50
47
|
project_gen.expects(:apply).with(template_file).returns(true).once
|
51
|
-
|
48
|
+
capture_io { project_gen.invoke_all }
|
52
49
|
end
|
53
50
|
|
54
51
|
should "resolve gist url properly" do
|
@@ -57,7 +54,7 @@ class TestPluginGenerator < Test::Unit::TestCase
|
|
57
54
|
resolved_path = 'https://gist.github.com/raw/357045/4356/blog_template.rb'
|
58
55
|
project_gen = Padrino::Generators::Project.new(['sample_project'], ["-p=#{template_file}", "-r=#{@apptmp}"], {})
|
59
56
|
project_gen.expects(:apply).with(resolved_path).returns(true).once
|
60
|
-
|
57
|
+
capture_io { project_gen.invoke_all }
|
61
58
|
end
|
62
59
|
|
63
60
|
should "resolve official template" do
|
@@ -65,14 +62,14 @@ class TestPluginGenerator < Test::Unit::TestCase
|
|
65
62
|
resolved_path = "https://github.com/padrino/padrino-recipes/raw/master/templates/sampleblog_template.rb"
|
66
63
|
project_gen = Padrino::Generators::Project.new(['sample_project'], ["-p=#{template_file}", "-r=#{@apptmp}"], {})
|
67
64
|
project_gen.expects(:apply).with(resolved_path).returns(true).once
|
68
|
-
|
65
|
+
capture_io { project_gen.invoke_all }
|
69
66
|
end
|
70
67
|
|
71
68
|
should "resolve local file" do
|
72
69
|
template_file = 'path/to/local/file.rb'
|
73
70
|
project_gen = Padrino::Generators::Project.new(['sample_project'], ["-p=#{template_file}", "-r=#{@apptmp}"], {})
|
74
71
|
project_gen.expects(:apply).with(File.expand_path(template_file)).returns(true).once
|
75
|
-
|
72
|
+
capture_io { project_gen.invoke_all }
|
76
73
|
end
|
77
74
|
|
78
75
|
should "resolve official plugin" do
|
@@ -81,49 +78,40 @@ class TestPluginGenerator < Test::Unit::TestCase
|
|
81
78
|
plugin_gen = Padrino::Generators::Plugin.new([ template_file], ["-r=#{@apptmp}/sample_project"],{})
|
82
79
|
plugin_gen.expects(:in_app_root?).returns(true).once
|
83
80
|
plugin_gen.expects(:apply).with(resolved_path).returns(true).once
|
84
|
-
|
81
|
+
capture_io { plugin_gen.invoke_all }
|
85
82
|
end
|
86
83
|
end
|
87
84
|
|
88
85
|
context "with git commands" do
|
89
|
-
|
90
|
-
git_template_path = File.join(File.dirname(__FILE__), 'fixtures', 'git_template.rb')
|
91
|
-
silence_logger { generate(:project, 'sample_git', "-p=#{git_template_path}", "-r=#{@apptmp}", '> /dev/null') }
|
92
|
-
end
|
93
|
-
|
94
|
-
before_should "generate a repository correctly" do
|
86
|
+
should "generate a repository correctly" do
|
95
87
|
expects_generated_project :test => :rspec, :orm => :activerecord, :name => 'sample_git', :root => "#{@apptmp}"
|
96
88
|
expects_git :init, :root => "#{@apptmp}/sample_git"
|
97
89
|
expects_git :add, :arguments => '.', :root => "#{@apptmp}/sample_git"
|
98
90
|
expects_git :commit, :arguments => 'hello', :root => "#{@apptmp}/sample_git"
|
91
|
+
git_template_path = File.join(File.dirname(__FILE__), 'fixtures', 'git_template.rb')
|
92
|
+
capture_io { generate(:project, 'sample_git', "-p=#{git_template_path}", "-r=#{@apptmp}", '> /dev/null') }
|
99
93
|
end
|
100
94
|
end
|
101
95
|
|
102
96
|
context "with rake invocations" do
|
103
|
-
|
104
|
-
rake_template_path = File.join(File.dirname(__FILE__), 'fixtures', 'rake_template.rb')
|
105
|
-
silence_logger { generate(:project, 'sample_rake', "-p=#{rake_template_path}", "-r=#{@apptmp}", '> /dev/null') }
|
106
|
-
end
|
107
|
-
|
108
|
-
before_should "Run rake task and list tasks" do
|
97
|
+
should "Run rake task and list tasks" do
|
109
98
|
expects_generated_project :test => :shoulda, :orm => :activerecord, :name => 'sample_rake', :root => "#{@apptmp}"
|
110
99
|
expects_rake "custom", :root => "#{@apptmp}/sample_rake"
|
100
|
+
rake_template_path = File.join(File.dirname(__FILE__), 'fixtures', 'rake_template.rb')
|
101
|
+
capture_io { generate(:project, 'sample_rake', "-p=#{rake_template_path}", "-r=#{@apptmp}", '> /dev/null') }
|
111
102
|
end
|
112
103
|
end
|
113
104
|
|
114
105
|
context "with admin commands" do
|
115
|
-
|
116
|
-
admin_template_path = File.join(File.dirname(__FILE__), 'fixtures', 'admin_template.rb')
|
117
|
-
silence_logger { generate(:project, 'sample_admin', "-p=#{admin_template_path}", "-r=#{@apptmp}", '> /dev/null') }
|
118
|
-
end
|
119
|
-
|
120
|
-
before_should "generate correctly an admin" do
|
106
|
+
should "generate correctly an admin" do
|
121
107
|
expects_generated_project :test => :shoulda, :orm => :activerecord, :name => 'sample_admin', :root => "#{@apptmp}"
|
122
108
|
expects_generated :model, "post title:string body:text -r=#{@apptmp}/sample_admin"
|
123
109
|
expects_rake "ar:create", :root => "#{@apptmp}/sample_admin"
|
124
110
|
expects_generated :admin, "-r=#{@apptmp}/sample_admin"
|
125
111
|
expects_rake "ar:migrate", :root => "#{@apptmp}/sample_admin"
|
126
112
|
expects_generated :admin_page, "post -r=#{@apptmp}/sample_admin"
|
113
|
+
admin_template_path = File.join(File.dirname(__FILE__), 'fixtures', 'admin_template.rb')
|
114
|
+
capture_io { generate(:project, 'sample_admin', "-p=#{admin_template_path}", "-r=#{@apptmp}", '> /dev/null') }
|
127
115
|
end
|
128
116
|
end
|
129
117
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/helper')
|
2
2
|
|
3
|
-
|
3
|
+
describe "ProjectGenerator" do
|
4
4
|
def setup
|
5
5
|
@apptmp = "#{Dir.tmpdir}/padrino-tests/#{UUID.new.generate}"
|
6
6
|
`mkdir -p #{@apptmp}`
|
@@ -13,7 +13,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
13
13
|
|
14
14
|
context 'the project generator' do
|
15
15
|
should "allow simple generator to run and create base_app with no options" do
|
16
|
-
|
16
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}") }
|
17
17
|
assert_file_exists("#{@apptmp}/sample_project")
|
18
18
|
assert_match_in_file(/class SampleProject < Padrino::Application/,"#{@apptmp}/sample_project/app/app.rb")
|
19
19
|
assert_match_in_file(/Padrino.mount\("SampleProject"\).to\('\/'\)/,"#{@apptmp}/sample_project/config/apps.rb")
|
@@ -27,29 +27,29 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
27
27
|
end
|
28
28
|
|
29
29
|
should "generate a valid name" do
|
30
|
-
|
30
|
+
capture_io { generate(:project, 'project.com', "--root=#{@apptmp}") }
|
31
31
|
assert_file_exists("#{@apptmp}/project.com")
|
32
32
|
assert_match_in_file(/class ProjectCom < Padrino::Application/, "#{@apptmp}/project.com/app/app.rb")
|
33
33
|
assert_match_in_file(/Padrino.mount\("ProjectCom"\).to\('\/'\)/, "#{@apptmp}/project.com/config/apps.rb")
|
34
|
-
|
34
|
+
capture_io { generate(:app, 'ws-dci-2011', "--root=#{@apptmp}/project.com") }
|
35
35
|
assert_file_exists("#{@apptmp}/project.com/wsdci2011")
|
36
36
|
assert_match_in_file(/class WsDci2011 < Padrino::Application/, "#{@apptmp}/project.com/wsdci2011/app.rb")
|
37
37
|
assert_match_in_file(/Padrino.mount\("WsDci2011"\).to\("\/wsdci2011"\)/, "#{@apptmp}/project.com/config/apps.rb")
|
38
38
|
end
|
39
39
|
|
40
40
|
should "raise an Error when given invalid constant names" do
|
41
|
-
|
42
|
-
|
41
|
+
assert_raises(::NameError) { capture_io { generate(:project, "123asdf", "--root=#{@apptmp}") } }
|
42
|
+
assert_raises(::NameError) { capture_io { generate(:project, "./sample_project", "--root=#{@apptmp}") } }
|
43
43
|
end
|
44
44
|
|
45
45
|
should "display the right path" do
|
46
|
-
|
46
|
+
out, err = capture_io { generate(:project, 'project', "--root=/tmp") }
|
47
47
|
assert_file_exists("/tmp/project")
|
48
|
-
assert_match(/cd \/tmp\/project/,
|
48
|
+
assert_match(/cd \/tmp\/project/, out)
|
49
49
|
end
|
50
50
|
|
51
51
|
should "allow specifying alternate application name" do
|
52
|
-
|
52
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--app=base_app') }
|
53
53
|
assert_file_exists("#{@apptmp}/sample_project")
|
54
54
|
assert_match_in_file(/class BaseApp < Padrino::Application/,"#{@apptmp}/sample_project/app/app.rb")
|
55
55
|
assert_match_in_file(/Padrino.mount\("BaseApp"\).to\('\/'\)/,"#{@apptmp}/sample_project/config/apps.rb")
|
@@ -58,7 +58,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
58
58
|
end
|
59
59
|
|
60
60
|
should "generate tiny skeleton" do
|
61
|
-
|
61
|
+
capture_io { generate(:project,'sample_project', '--tiny',"--root=#{@apptmp}") }
|
62
62
|
assert_file_exists("#{@apptmp}/sample_project")
|
63
63
|
assert_file_exists("#{@apptmp}/sample_project/app")
|
64
64
|
assert_file_exists("#{@apptmp}/sample_project/app/controllers.rb")
|
@@ -74,28 +74,28 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
74
74
|
end
|
75
75
|
|
76
76
|
should "not create models folder if no orm is chosen" do
|
77
|
-
|
77
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '--orm=none') }
|
78
78
|
assert_no_dir_exists("#{@apptmp}/sample_project/models")
|
79
79
|
end
|
80
80
|
|
81
81
|
should "not create tests folder if no test framework is chosen" do
|
82
|
-
|
82
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '--test=none') }
|
83
83
|
assert_no_dir_exists("#{@apptmp}/sample_project/test")
|
84
84
|
end
|
85
85
|
|
86
86
|
should "place app specific names into correct files" do
|
87
|
-
|
87
|
+
capture_io { generate(:project, 'warepedia', "--root=#{@apptmp}", '--script=none') }
|
88
88
|
assert_match_in_file(/class Warepedia < Padrino::Application/m, "#{@apptmp}/warepedia/app/app.rb")
|
89
89
|
assert_match_in_file(/Padrino.mount\("Warepedia"\).to\('\/'\)/m, "#{@apptmp}/warepedia/config/apps.rb")
|
90
90
|
end
|
91
91
|
|
92
92
|
should "store and apply session_secret" do
|
93
|
-
|
93
|
+
capture_io { generate(:project,'sample_project', '--tiny',"--root=#{@apptmp}") }
|
94
94
|
assert_match_in_file(/set :session_secret, '[0-9A-z]*'/, "#{@apptmp}/sample_project/config/apps.rb")
|
95
95
|
end
|
96
96
|
|
97
97
|
should "create components file containing options chosen with defaults" do
|
98
|
-
|
98
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}") }
|
99
99
|
components_chosen = YAML.load_file("#{@apptmp}/sample_project/.components")
|
100
100
|
assert_equal 'none', components_chosen[:orm]
|
101
101
|
assert_equal 'none', components_chosen[:test]
|
@@ -106,7 +106,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
106
106
|
|
107
107
|
should "create components file containing options chosen" do
|
108
108
|
component_options = ['--orm=datamapper', '--test=riot', '--mock=mocha', '--script=prototype', '--renderer=erb', '--stylesheet=less']
|
109
|
-
|
109
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", *component_options) }
|
110
110
|
components_chosen = YAML.load_file("#{@apptmp}/sample_project/.components")
|
111
111
|
assert_equal 'datamapper', components_chosen[:orm]
|
112
112
|
assert_equal 'riot', components_chosen[:test]
|
@@ -118,50 +118,57 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
118
118
|
|
119
119
|
should "output to log components being applied" do
|
120
120
|
component_options = ['--orm=datamapper', '--test=riot', '--mock=mocha', '--script=prototype', '--renderer=erb','--stylesheet=less']
|
121
|
-
|
122
|
-
assert_match(/
|
123
|
-
assert_match(/
|
124
|
-
assert_match(/
|
125
|
-
assert_match(/
|
126
|
-
assert_match(/
|
127
|
-
assert_match(/
|
121
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", *component_options) }
|
122
|
+
assert_match(/applying.*?datamapper.*?orm/, out)
|
123
|
+
assert_match(/applying.*?riot.*?test/, out)
|
124
|
+
assert_match(/applying.*?mocha.*?mock/, out)
|
125
|
+
assert_match(/applying.*?prototype.*?script/, out)
|
126
|
+
assert_match(/applying.*?erb.*?renderer/, out)
|
127
|
+
assert_match(/applying.*?less.*?stylesheet/, out)
|
128
128
|
end
|
129
129
|
|
130
130
|
should "output gem files for base app" do
|
131
|
-
|
131
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none') }
|
132
132
|
assert_match_in_file(/gem 'padrino'/, "#{@apptmp}/sample_project/Gemfile")
|
133
|
-
assert_match_in_file(/gem '
|
133
|
+
assert_match_in_file(/gem 'sinatra-flash'/, "#{@apptmp}/sample_project/Gemfile")
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
137
|
context "a generator for mock component" do
|
138
138
|
should "properly generate for rr and riot" do
|
139
|
-
|
140
|
-
assert_match(/
|
139
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--mock=rr', '--test=riot', '--script=none') }
|
140
|
+
assert_match(/applying.*?rr.*?mock/, out)
|
141
141
|
assert_match_in_file(/gem 'rr'/, "#{@apptmp}/sample_project/Gemfile")
|
142
142
|
assert_match_in_file(/require 'riot\/rr'/, "#{@apptmp}/sample_project/test/test_config.rb")
|
143
143
|
end
|
144
144
|
|
145
|
-
should "properly
|
146
|
-
|
147
|
-
assert_match(/
|
145
|
+
should "properly generate for rr and minitest" do
|
146
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--mock=rr', '--test=minitest', '--script=none') }
|
147
|
+
assert_match(/applying.*?rr.*?mock/, out)
|
148
148
|
assert_match_in_file(/gem 'rr'/, "#{@apptmp}/sample_project/Gemfile")
|
149
|
-
assert_match_in_file(/RR::Adapters::
|
149
|
+
assert_match_in_file(/include RR::Adapters::MiniTest/, "#{@apptmp}/sample_project/test/test_config.rb")
|
150
150
|
end
|
151
151
|
|
152
|
-
should "properly
|
153
|
-
|
154
|
-
assert_match(/
|
155
|
-
assert_match_in_file(/gem '
|
156
|
-
assert_match_in_file(/
|
152
|
+
should "properly generater for rr and bacon" do
|
153
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--mock=rr', '--test=bacon', '--script=none') }
|
154
|
+
assert_match(/applying.*?rr.*?mock/, out)
|
155
|
+
assert_match_in_file(/gem 'rr'/, "#{@apptmp}/sample_project/Gemfile")
|
156
|
+
assert_match_in_file(/include RR::Adapters::RRMethods/m, "#{@apptmp}/sample_project/test/test_config.rb")
|
157
157
|
end
|
158
158
|
|
159
159
|
should "properly generate for rr and rspec" do
|
160
|
-
|
161
|
-
assert_match(/
|
160
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=rspec', '--mock=rr', '--script=none') }
|
161
|
+
assert_match(/applying.*?rr.*?mock/, out)
|
162
162
|
assert_match_in_file(/gem 'rr'/, "#{@apptmp}/sample_project/Gemfile")
|
163
163
|
assert_match_in_file(/conf.mock_with :rr/m, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
164
164
|
end
|
165
|
+
|
166
|
+
should "properly generate for mocha and rspec" do
|
167
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}",'--test=rspec', '--mock=mocha', '--script=none') }
|
168
|
+
assert_match(/applying.*?mocha.*?mock/, out)
|
169
|
+
assert_match_in_file(/gem 'mocha'/, "#{@apptmp}/sample_project/Gemfile")
|
170
|
+
assert_match_in_file(/conf.mock_with :mocha/m, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
171
|
+
end
|
165
172
|
end
|
166
173
|
|
167
174
|
context "the generator for orm components" do
|
@@ -169,8 +176,8 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
169
176
|
context "for sequel" do
|
170
177
|
should "properly generate default" do
|
171
178
|
@app.instance_eval("undef setup_orm if respond_to?('setup_orm')")
|
172
|
-
|
173
|
-
assert_match(/
|
179
|
+
out, err = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=sequel', '--script=none') }
|
180
|
+
assert_match(/applying.*?sequel.*?orm/, out)
|
174
181
|
assert_match_in_file(/gem 'sequel'/, "#{@apptmp}/project.com/Gemfile")
|
175
182
|
assert_match_in_file(/gem 'sqlite3'/, "#{@apptmp}/project.com/Gemfile")
|
176
183
|
assert_match_in_file(/Sequel.connect/, "#{@apptmp}/project.com/config/database.rb")
|
@@ -179,21 +186,21 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
179
186
|
end
|
180
187
|
|
181
188
|
should "properly generate mysql" do
|
182
|
-
|
189
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=sequel', '--adapter=mysql') }
|
183
190
|
assert_match_in_file(/gem 'mysql'/, "#{@apptmp}/sample_project/Gemfile")
|
184
191
|
assert_match_in_file(%r{"mysql://}, "#{@apptmp}/sample_project/config/database.rb")
|
185
192
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
186
193
|
end
|
187
194
|
|
188
195
|
should "properly generate sqlite3" do
|
189
|
-
|
196
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=sequel', '--adapter=sqlite') }
|
190
197
|
assert_match_in_file(/gem 'sqlite3'/, "#{@apptmp}/sample_project/Gemfile")
|
191
198
|
assert_match_in_file(%r{sqlite://}, "#{@apptmp}/sample_project/config/database.rb")
|
192
199
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
193
200
|
end
|
194
201
|
|
195
202
|
should "properly generate postgres" do
|
196
|
-
|
203
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=sequel', '--adapter=postgres') }
|
197
204
|
assert_match_in_file(/gem 'pg'/, "#{@apptmp}/sample_project/Gemfile")
|
198
205
|
assert_match_in_file(%r{"postgres://}, "#{@apptmp}/sample_project/config/database.rb")
|
199
206
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
@@ -202,8 +209,8 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
202
209
|
|
203
210
|
context "for activerecord" do
|
204
211
|
should "properly generate default" do
|
205
|
-
|
206
|
-
assert_match(/
|
212
|
+
out, err = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=activerecord', '--script=none') }
|
213
|
+
assert_match(/applying.*?activerecord.*?orm/, out)
|
207
214
|
assert_match_in_file(/gem 'activerecord', :require => "active_record"/, "#{@apptmp}/project.com/Gemfile")
|
208
215
|
assert_match_in_file(/gem 'sqlite3'/, "#{@apptmp}/project.com/Gemfile")
|
209
216
|
assert_match_in_file(/ActiveRecord::Base.establish_connection/, "#{@apptmp}/project.com/config/database.rb")
|
@@ -211,28 +218,28 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
211
218
|
end
|
212
219
|
|
213
220
|
should "properly generate mysql" do
|
214
|
-
|
221
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=activerecord','--adapter=mysql') }
|
215
222
|
assert_match_in_file(/gem 'mysql'/, "#{@apptmp}/sample_project/Gemfile")
|
216
223
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
217
224
|
assert_match_in_file(%r{:adapter => 'mysql'}, "#{@apptmp}/sample_project/config/database.rb")
|
218
225
|
end
|
219
226
|
|
220
227
|
should "properly generate mysql2" do
|
221
|
-
|
228
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=activerecord','--adapter=mysql2') }
|
222
229
|
assert_match_in_file(/gem 'mysql2'/, "#{@apptmp}/sample_project/Gemfile")
|
223
230
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
224
231
|
assert_match_in_file(%r{:adapter => 'mysql2'}, "#{@apptmp}/sample_project/config/database.rb")
|
225
232
|
end
|
226
233
|
|
227
234
|
should "properly generate sqlite3" do
|
228
|
-
|
235
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=activerecord', '--adapter=sqlite3') }
|
229
236
|
assert_match_in_file(/gem 'sqlite3'/, "#{@apptmp}/sample_project/Gemfile")
|
230
237
|
assert_match_in_file(/sample_project_development.db/, "#{@apptmp}/sample_project/config/database.rb")
|
231
238
|
assert_match_in_file(%r{:adapter => 'sqlite3'}, "#{@apptmp}/sample_project/config/database.rb")
|
232
239
|
end
|
233
240
|
|
234
241
|
should "properly generate postgres" do
|
235
|
-
|
242
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=activerecord', '--adapter=postgres') }
|
236
243
|
assert_match_in_file(/gem 'pg', :require => "postgres"/, "#{@apptmp}/sample_project/Gemfile")
|
237
244
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
238
245
|
assert_match_in_file(%r{:adapter => 'postgresql'}, "#{@apptmp}/sample_project/config/database.rb")
|
@@ -241,8 +248,8 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
241
248
|
|
242
249
|
context "for datamapper" do
|
243
250
|
should "properly generate default" do
|
244
|
-
|
245
|
-
assert_match(/
|
251
|
+
out, err = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=datamapper', '--script=none') }
|
252
|
+
assert_match(/applying.*?datamapper.*?orm/, out)
|
246
253
|
assert_match_in_file(/gem 'dm-core'/, "#{@apptmp}/project.com/Gemfile")
|
247
254
|
assert_match_in_file(/gem 'dm-sqlite-adapter'/, "#{@apptmp}/project.com/Gemfile")
|
248
255
|
assert_match_in_file(/DataMapper.setup/, "#{@apptmp}/project.com/config/database.rb")
|
@@ -250,20 +257,20 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
250
257
|
end
|
251
258
|
|
252
259
|
should "properly generate for mysql" do
|
253
|
-
|
260
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=datamapper', '--adapter=mysql') }
|
254
261
|
assert_match_in_file(/gem 'dm-mysql-adapter'/, "#{@apptmp}/sample_project/Gemfile")
|
255
262
|
assert_match_in_file(%r{"mysql://}, "#{@apptmp}/sample_project/config/database.rb")
|
256
263
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
257
264
|
end
|
258
265
|
|
259
266
|
should "properly generate for sqlite" do
|
260
|
-
|
267
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=datamapper', '--adapter=sqlite') }
|
261
268
|
assert_match_in_file(/gem 'dm-sqlite-adapter'/, "#{@apptmp}/sample_project/Gemfile")
|
262
269
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
263
270
|
end
|
264
271
|
|
265
272
|
should "properly generate for postgres" do
|
266
|
-
|
273
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=datamapper', '--adapter=postgres') }
|
267
274
|
assert_match_in_file(/gem 'dm-postgres-adapter'/, "#{@apptmp}/sample_project/Gemfile")
|
268
275
|
assert_match_in_file(%r{"postgres://}, "#{@apptmp}/sample_project/config/database.rb")
|
269
276
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
@@ -271,8 +278,8 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
271
278
|
end
|
272
279
|
|
273
280
|
should "properly generate for mongomapper" do
|
274
|
-
|
275
|
-
assert_match(/
|
281
|
+
out, err = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=mongomapper', '--script=none') }
|
282
|
+
assert_match(/applying.*?mongomapper.*?orm/, out)
|
276
283
|
assert_match_in_file(/gem 'mongo_mapper'/, "#{@apptmp}/project.com/Gemfile")
|
277
284
|
assert_match_in_file(/gem 'bson_ext'/, "#{@apptmp}/project.com/Gemfile")
|
278
285
|
assert_match_in_file(/MongoMapper.database/, "#{@apptmp}/project.com/config/database.rb")
|
@@ -280,8 +287,8 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
280
287
|
end
|
281
288
|
|
282
289
|
should "properly generate for mongoid" do
|
283
|
-
|
284
|
-
assert_match(/
|
290
|
+
out, err = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=mongoid', '--script=none') }
|
291
|
+
assert_match(/applying.*?mongoid.*?orm/, out)
|
285
292
|
assert_match_in_file(/gem 'mongoid'/, "#{@apptmp}/project.com/Gemfile")
|
286
293
|
assert_match_in_file(/gem 'bson_ext'/, "#{@apptmp}/project.com/Gemfile")
|
287
294
|
assert_match_in_file(/Mongoid.database/, "#{@apptmp}/project.com/config/database.rb")
|
@@ -290,16 +297,16 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
290
297
|
|
291
298
|
|
292
299
|
should "properly generate for couchrest" do
|
293
|
-
|
294
|
-
assert_match(/
|
300
|
+
out, err = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=couchrest', '--script=none') }
|
301
|
+
assert_match(/applying.*?couchrest.*?orm/, out)
|
295
302
|
assert_match_in_file(/gem 'couchrest_model'/, "#{@apptmp}/project.com/Gemfile")
|
296
303
|
assert_match_in_file(/CouchRest.database!/, "#{@apptmp}/project.com/config/database.rb")
|
297
304
|
assert_match_in_file(/project_com/, "#{@apptmp}/project.com/config/database.rb")
|
298
305
|
end
|
299
306
|
|
300
307
|
should "properly generate for ohm" do
|
301
|
-
|
302
|
-
assert_match(/
|
308
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=ohm', '--script=none') }
|
309
|
+
assert_match(/applying.*?ohm.*?orm/, out)
|
303
310
|
assert_match_in_file(/gem 'json'/, "#{@apptmp}/sample_project/Gemfile")
|
304
311
|
assert_match_in_file(/gem 'ohm'/, "#{@apptmp}/sample_project/Gemfile")
|
305
312
|
assert_match_in_file(/gem 'ohm-contrib', :require => "ohm\/contrib"/, "#{@apptmp}/sample_project/Gemfile")
|
@@ -307,16 +314,16 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
307
314
|
end
|
308
315
|
|
309
316
|
should "properly generate for mongomatic" do
|
310
|
-
|
311
|
-
assert_match(/
|
317
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=mongomatic', '--script=none') }
|
318
|
+
assert_match(/applying.*?mongomatic.*?orm/, out)
|
312
319
|
assert_match_in_file(/gem 'bson_ext'/, "#{@apptmp}/sample_project/Gemfile")
|
313
320
|
assert_match_in_file(/gem 'mongomatic'/, "#{@apptmp}/sample_project/Gemfile")
|
314
321
|
assert_match_in_file(/Mongomatic.db = Mongo::Connection.new.db/, "#{@apptmp}/sample_project/config/database.rb")
|
315
322
|
end
|
316
323
|
|
317
324
|
should "properly generate for ripple" do
|
318
|
-
|
319
|
-
assert_match(/
|
325
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=ripple', '--script=none') }
|
326
|
+
assert_match(/applying.*?ripple.*?orm/, out)
|
320
327
|
assert_match_in_file(/gem 'ripple'/, "#{@apptmp}/sample_project/Gemfile")
|
321
328
|
assert_match_in_file(/Ripple.load_configuration/, "#{@apptmp}/sample_project/config/database.rb")
|
322
329
|
assert_match_in_file(/http_port: 8098/, "#{@apptmp}/sample_project/config/riak.yml")
|
@@ -326,50 +333,50 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
326
333
|
|
327
334
|
context "the generator for renderer component" do
|
328
335
|
should "properly generate for erb" do
|
329
|
-
|
330
|
-
assert_match(/
|
336
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=erb', '--script=none') }
|
337
|
+
assert_match(/applying.*?erb.*?renderer/, out)
|
331
338
|
assert_match_in_file(/gem 'erubis'/, "#{@apptmp}/sample_project/Gemfile")
|
332
339
|
end
|
333
340
|
|
334
341
|
should "properly generate for haml" do
|
335
|
-
|
336
|
-
assert_match(/
|
342
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=haml','--script=none') }
|
343
|
+
assert_match(/applying.*?haml.*?renderer/, out)
|
337
344
|
assert_match_in_file(/gem 'haml'/, "#{@apptmp}/sample_project/Gemfile")
|
338
345
|
end
|
339
346
|
|
340
347
|
should "properly generate for liquid" do
|
341
|
-
|
342
|
-
assert_match(/
|
348
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=liquid','--script=none') }
|
349
|
+
assert_match(/applying.*?liquid.*?renderer/, out)
|
343
350
|
assert_match_in_file(/gem 'liquid'/, "#{@apptmp}/sample_project/Gemfile")
|
344
351
|
end
|
345
352
|
|
346
353
|
should "properly generate for slim" do
|
347
|
-
|
348
|
-
assert_match(/
|
354
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=slim','--script=none') }
|
355
|
+
assert_match(/applying.*?slim.*?renderer/, out)
|
349
356
|
assert_match_in_file(/gem 'slim'/, "#{@apptmp}/sample_project/Gemfile")
|
350
357
|
end
|
351
358
|
end
|
352
359
|
|
353
360
|
context "the generator for script component" do
|
354
361
|
should "properly generate for jquery" do
|
355
|
-
|
356
|
-
assert_match(/
|
362
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=jquery') }
|
363
|
+
assert_match(/applying.*?jquery.*?script/, out)
|
357
364
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/jquery.js")
|
358
365
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/jquery-ujs.js")
|
359
366
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/application.js")
|
360
367
|
end
|
361
368
|
|
362
369
|
should "properly generate for mootools" do
|
363
|
-
|
364
|
-
assert_match(/
|
370
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=mootools') }
|
371
|
+
assert_match(/applying.*?mootools.*?script/, out)
|
365
372
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/mootools.js")
|
366
373
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/mootools-ujs.js")
|
367
374
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/application.js")
|
368
375
|
end
|
369
376
|
|
370
377
|
should "properly generate for prototype" do
|
371
|
-
|
372
|
-
assert_match(/
|
378
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=prototype') }
|
379
|
+
assert_match(/applying.*?prototype.*?script/, out)
|
373
380
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/protopak.js")
|
374
381
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/lowpro.js")
|
375
382
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/prototype-ujs.js")
|
@@ -377,24 +384,24 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
377
384
|
end
|
378
385
|
|
379
386
|
should "properly generate for rightjs" do
|
380
|
-
|
381
|
-
assert_match(/
|
387
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=rightjs') }
|
388
|
+
assert_match(/applying.*?rightjs.*?script/, out)
|
382
389
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/right.js")
|
383
390
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/right-ujs.js")
|
384
391
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/application.js")
|
385
392
|
end
|
386
393
|
|
387
394
|
should "properly generate for ext-core" do
|
388
|
-
|
389
|
-
assert_match(/
|
395
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=extcore') }
|
396
|
+
assert_match(/applying.*?extcore.*?script/, out)
|
390
397
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/ext.js")
|
391
398
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/ext-ujs.js")
|
392
399
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/application.js")
|
393
400
|
end
|
394
401
|
|
395
402
|
should "properly generate for dojo" do
|
396
|
-
|
397
|
-
assert_match(/
|
403
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=dojo') }
|
404
|
+
assert_match(/applying.*?dojo.*?script/, out)
|
398
405
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/dojo.js")
|
399
406
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/dojo-ujs.js")
|
400
407
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/application.js")
|
@@ -403,8 +410,8 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
403
410
|
|
404
411
|
context "the generator for test component" do
|
405
412
|
should "properly generate for bacon" do
|
406
|
-
|
407
|
-
assert_match(/
|
413
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=bacon', '--script=none') }
|
414
|
+
assert_match(/applying.*?bacon.*?test/, out)
|
408
415
|
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
409
416
|
assert_match_in_file(/:require => "rack\/test"/, "#{@apptmp}/sample_project/Gemfile")
|
410
417
|
assert_match_in_file(/:group => "test"/, "#{@apptmp}/sample_project/Gemfile")
|
@@ -417,8 +424,8 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
417
424
|
end
|
418
425
|
|
419
426
|
should "properly generate for riot" do
|
420
|
-
|
421
|
-
assert_match(/
|
427
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=riot', '--script=none') }
|
428
|
+
assert_match(/applying.*?riot.*?test/, out)
|
422
429
|
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
423
430
|
assert_match_in_file(/:require => "rack\/test"/, "#{@apptmp}/sample_project/Gemfile")
|
424
431
|
assert_match_in_file(/:group => "test"/, "#{@apptmp}/sample_project/Gemfile")
|
@@ -434,8 +441,8 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
434
441
|
end
|
435
442
|
|
436
443
|
should "properly generate for rspec" do
|
437
|
-
|
438
|
-
assert_match(/
|
444
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=rspec', '--script=none') }
|
445
|
+
assert_match(/applying.*?rspec.*?test/, out)
|
439
446
|
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
440
447
|
assert_match_in_file(/:require => "rack\/test"/, "#{@apptmp}/sample_project/Gemfile")
|
441
448
|
assert_match_in_file(/:group => "test"/, "#{@apptmp}/sample_project/Gemfile")
|
@@ -448,8 +455,8 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
448
455
|
end
|
449
456
|
|
450
457
|
should "properly generate for shoulda" do
|
451
|
-
|
452
|
-
assert_match(/
|
458
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=shoulda', '--script=none') }
|
459
|
+
assert_match(/applying.*?shoulda.*?test/, out)
|
453
460
|
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
454
461
|
assert_match_in_file(/:require => "rack\/test"/, "#{@apptmp}/sample_project/Gemfile")
|
455
462
|
assert_match_in_file(/:group => "test"/, "#{@apptmp}/sample_project/Gemfile")
|
@@ -461,9 +468,25 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
461
468
|
assert_match_in_file(/task 'test' => test_tasks/,"#{@apptmp}/sample_project/test/test.rake")
|
462
469
|
end
|
463
470
|
|
471
|
+
should "properly generate for minitest" do
|
472
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=minitest', '--script=none') }
|
473
|
+
assert_match(/applying.*?minitest.*?test/, out)
|
474
|
+
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
475
|
+
assert_match_in_file(/:require => "rack\/test"/, "#{@apptmp}/sample_project/Gemfile")
|
476
|
+
assert_match_in_file(/:group => "test"/, "#{@apptmp}/sample_project/Gemfile")
|
477
|
+
assert_match_in_file(/gem 'minitest'/, "#{@apptmp}/sample_project/Gemfile")
|
478
|
+
assert_match_in_file(/include Rack::Test::Methods/, "#{@apptmp}/sample_project/test/test_config.rb")
|
479
|
+
assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
480
|
+
assert_match_in_file(/MiniTest::Unit::TestCase/, "#{@apptmp}/sample_project/test/test_config.rb")
|
481
|
+
assert_match_in_file(/SampleProject\.tap/, "#{@apptmp}/sample_project/test/test_config.rb")
|
482
|
+
assert_file_exists("#{@apptmp}/sample_project/test/test.rake")
|
483
|
+
assert_match_in_file(/Rake::TestTask\.new\("test:\#/,"#{@apptmp}/sample_project/test/test.rake")
|
484
|
+
assert_match_in_file(/task 'test' => test_tasks/,"#{@apptmp}/sample_project/test/test.rake")
|
485
|
+
end # minitest
|
486
|
+
|
464
487
|
should "properly generate for testspec" do
|
465
|
-
|
466
|
-
assert_match(/
|
488
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=testspec', '--script=none') }
|
489
|
+
assert_match(/applying.*?testspec.*?test/, out)
|
467
490
|
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
468
491
|
assert_match_in_file(/:require => "rack\/test"/, "#{@apptmp}/sample_project/Gemfile")
|
469
492
|
assert_match_in_file(/:group => "test"/, "#{@apptmp}/sample_project/Gemfile")
|
@@ -477,8 +500,8 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
477
500
|
end
|
478
501
|
|
479
502
|
should "properly generate for cucumber" do
|
480
|
-
|
481
|
-
assert_match(/
|
503
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=cucumber', '--script=none') }
|
504
|
+
assert_match(/applying.*?cucumber.*?test/, out)
|
482
505
|
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
483
506
|
assert_match_in_file(/:require => "rack\/test"/, "#{@apptmp}/sample_project/Gemfile")
|
484
507
|
assert_match_in_file(/:group => "test"/, "#{@apptmp}/sample_project/Gemfile")
|
@@ -501,7 +524,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
501
524
|
|
502
525
|
context "the generator for stylesheet component" do
|
503
526
|
should "properly generate for sass" do
|
504
|
-
|
527
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=haml','--script=none','--stylesheet=sass') }
|
505
528
|
assert_match_in_file(/gem 'sass'/, "#{@apptmp}/sample_project/Gemfile")
|
506
529
|
assert_match_in_file(/module SassInitializer.*Sass::Plugin::Rack/m, "#{@apptmp}/sample_project/lib/sass_init.rb")
|
507
530
|
assert_match_in_file(/register SassInitializer/m, "#{@apptmp}/sample_project/app/app.rb")
|
@@ -509,8 +532,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
509
532
|
end
|
510
533
|
|
511
534
|
should "properly generate for less" do
|
512
|
-
|
513
|
-
assert_match_in_file(/gem 'less'/, "#{@apptmp}/sample_project/Gemfile")
|
535
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=haml','--script=none','--stylesheet=less') }
|
514
536
|
assert_match_in_file(/gem 'rack-less'/, "#{@apptmp}/sample_project/Gemfile")
|
515
537
|
assert_match_in_file(/module LessInitializer.*Rack::Less/m, "#{@apptmp}/sample_project/lib/less_init.rb")
|
516
538
|
assert_match_in_file(/register LessInitializer/m, "#{@apptmp}/sample_project/app/app.rb")
|
@@ -518,7 +540,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
518
540
|
end
|
519
541
|
|
520
542
|
should "properly generate for compass" do
|
521
|
-
|
543
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=haml','--script=none','--stylesheet=compass') }
|
522
544
|
assert_match_in_file(/gem 'compass'/, "#{@apptmp}/sample_project/Gemfile")
|
523
545
|
assert_match_in_file(/Compass.configure_sass_plugin\!/, "#{@apptmp}/sample_project/lib/compass_plugin.rb")
|
524
546
|
assert_match_in_file(/module CompassInitializer.*Sass::Plugin::Rack/m, "#{@apptmp}/sample_project/lib/compass_plugin.rb")
|
@@ -529,7 +551,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
529
551
|
end
|
530
552
|
|
531
553
|
should "properly generate for scss" do
|
532
|
-
|
554
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=haml','--script=none','--stylesheet=scss') }
|
533
555
|
assert_match_in_file(/gem 'haml'/, "#{@apptmp}/sample_project/Gemfile")
|
534
556
|
assert_match_in_file(/module ScssInitializer.*Sass::Plugin::Rack/m, "#{@apptmp}/sample_project/lib/scss_init.rb")
|
535
557
|
assert_match_in_file(/Sass::Plugin.options\[:syntax\] = :scss/m, "#{@apptmp}/sample_project/lib/scss_init.rb")
|