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