tennpipes-init 3.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +163 -0
- data/Rakefile +1 -0
- data/bin/tennpipes-init +16 -0
- data/lib/tennpipes-init.rb +73 -0
- data/lib/tennpipes-init/command.rb +18 -0
- data/lib/tennpipes-init/generators/actions.rb +630 -0
- data/lib/tennpipes-init/generators/app.rb +75 -0
- data/lib/tennpipes-init/generators/app/app.rb.tt +72 -0
- data/lib/tennpipes-init/generators/app/app.rb.tt~ +72 -0
- data/lib/tennpipes-init/generators/cli.rb +57 -0
- data/lib/tennpipes-init/generators/component.rb +73 -0
- data/lib/tennpipes-init/generators/components/actions.rb +208 -0
- data/lib/tennpipes-init/generators/components/mocks/mocha.rb +10 -0
- data/lib/tennpipes-init/generators/components/mocks/rr.rb +13 -0
- data/lib/tennpipes-init/generators/components/orms/activerecord.rb +201 -0
- data/lib/tennpipes-init/generators/components/orms/couchrest.rb +55 -0
- data/lib/tennpipes-init/generators/components/orms/datamapper.rb +140 -0
- data/lib/tennpipes-init/generators/components/orms/dynamoid.rb +67 -0
- data/lib/tennpipes-init/generators/components/orms/minirecord.rb +165 -0
- data/lib/tennpipes-init/generators/components/orms/mongoid.rb +113 -0
- data/lib/tennpipes-init/generators/components/orms/mongomapper.rb +43 -0
- data/lib/tennpipes-init/generators/components/orms/mongomatic.rb +84 -0
- data/lib/tennpipes-init/generators/components/orms/ohm.rb +65 -0
- data/lib/tennpipes-init/generators/components/orms/ripple.rb +75 -0
- data/lib/tennpipes-init/generators/components/orms/sequel.rb +99 -0
- data/lib/tennpipes-init/generators/components/renderers/erb.rb +3 -0
- data/lib/tennpipes-init/generators/components/renderers/haml.rb +3 -0
- data/lib/tennpipes-init/generators/components/renderers/liquid.rb +4 -0
- data/lib/tennpipes-init/generators/components/renderers/slim.rb +3 -0
- data/lib/tennpipes-init/generators/components/scripts/dojo.rb +10 -0
- data/lib/tennpipes-init/generators/components/scripts/extcore.rb +10 -0
- data/lib/tennpipes-init/generators/components/scripts/jquery.rb +10 -0
- data/lib/tennpipes-init/generators/components/scripts/mootools.rb +10 -0
- data/lib/tennpipes-init/generators/components/scripts/prototype.rb +12 -0
- data/lib/tennpipes-init/generators/components/scripts/rightjs.rb +10 -0
- data/lib/tennpipes-init/generators/components/stylesheets/compass.rb +39 -0
- data/lib/tennpipes-init/generators/components/stylesheets/compass/application.scss +43 -0
- data/lib/tennpipes-init/generators/components/stylesheets/compass/partials/_base.scss +12 -0
- data/lib/tennpipes-init/generators/components/stylesheets/less.rb +25 -0
- data/lib/tennpipes-init/generators/components/stylesheets/sass.rb +15 -0
- data/lib/tennpipes-init/generators/components/stylesheets/scss.rb +16 -0
- data/lib/tennpipes-init/generators/components/tests/bacon.rb +103 -0
- data/lib/tennpipes-init/generators/components/tests/cucumber.rb +86 -0
- data/lib/tennpipes-init/generators/components/tests/minitest.rb +110 -0
- data/lib/tennpipes-init/generators/components/tests/riot.rb +117 -0
- data/lib/tennpipes-init/generators/components/tests/rspec.rb +111 -0
- data/lib/tennpipes-init/generators/components/tests/shoulda.rb +114 -0
- data/lib/tennpipes-init/generators/components/tests/steak.rb +114 -0
- data/lib/tennpipes-init/generators/controller.rb +77 -0
- data/lib/tennpipes-init/generators/helper.rb +50 -0
- data/lib/tennpipes-init/generators/mailer.rb +52 -0
- data/lib/tennpipes-init/generators/migration.rb +43 -0
- data/lib/tennpipes-init/generators/model.rb +113 -0
- data/lib/tennpipes-init/generators/plugin.rb +67 -0
- data/lib/tennpipes-init/generators/project.rb +160 -0
- data/lib/tennpipes-init/generators/project/config.ru +9 -0
- data/lib/tennpipes-init/generators/project/config/apps.rb.tt +35 -0
- data/lib/tennpipes-init/generators/project/config/boot.rb +49 -0
- data/lib/tennpipes-init/generators/project/public/favicon.ico +0 -0
- data/lib/tennpipes-init/generators/project/public/images/booking.com.png +0 -0
- data/lib/tennpipes-init/generators/project/public/images/causes.png +0 -0
- data/lib/tennpipes-init/generators/project/public/images/ennkeypee_bg.jpg +0 -0
- data/lib/tennpipes-init/generators/project/public/images/ennkeypee_bluelogo.png +0 -0
- data/lib/tennpipes-init/generators/project/public/images/ennkeypee_bluelogo.svg +68 -0
- data/lib/tennpipes-init/generators/project/public/images/ennkeypee_whitelogo.png +0 -0
- data/lib/tennpipes-init/generators/project/public/images/ennkeypee_whitelogo.svg +65 -0
- data/lib/tennpipes-init/generators/project/public/images/forever21.png +0 -0
- data/lib/tennpipes-init/generators/project/public/images/icons/foundation-icons.eot +0 -0
- data/lib/tennpipes-init/generators/project/public/images/icons/foundation-icons.svg +970 -0
- data/lib/tennpipes-init/generators/project/public/images/icons/foundation-icons.ttf +0 -0
- data/lib/tennpipes-init/generators/project/public/images/icons/foundation-icons.woff +0 -0
- data/lib/tennpipes-init/generators/project/public/images/icons/tennpipes-icons.css +598 -0
- data/lib/tennpipes-init/generators/project/public/images/image1.jpg +0 -0
- data/lib/tennpipes-init/generators/project/public/images/image11.jpg +0 -0
- data/lib/tennpipes-init/generators/project/public/images/image2.jpg +0 -0
- data/lib/tennpipes-init/generators/project/public/images/image3.jpg +0 -0
- data/lib/tennpipes-init/generators/project/public/images/intuit.png +0 -0
- data/lib/tennpipes-init/generators/project/public/images/krispykreme.png +0 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/README.md +302 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/bower.json +4 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/composer.json +34 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/gulpfile.js +92 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/holder.js +1920 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/holder.min.js +12 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/package.json +46 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/src/holder.js +1411 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/src/lib/augment.js +27 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/src/lib/ondomready.js +155 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/src/lib/polyfills.js +177 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/src/scenegraph.js +101 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/src/utils.js +129 -0
- data/lib/tennpipes-init/generators/project/public/images/priceline.com.png +0 -0
- data/lib/tennpipes-init/generators/project/public/images/stripe.png +0 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes.min.js +6081 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.abide.js +340 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.accordion.js +67 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.alert.js +43 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.clearing.js +556 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.dropdown.js +448 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.equalizer.js +77 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.interchange.js +354 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.joyride.js +932 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.js +703 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.magellan.js +203 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.offcanvas.js +152 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.orbit.js +476 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.reveal.js +471 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.slider.js +263 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.tab.js +237 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.tooltip.js +307 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.topbar.js +452 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/vendor/fastclick.js +8 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/vendor/jquery.cookie.js +8 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/vendor/jquery.js +26 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/vendor/modernizr.js +8 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/vendor/placeholder.js +2 -0
- data/lib/tennpipes-init/generators/project/public/stylesheets/app.css~ +178 -0
- data/lib/tennpipes-init/generators/project/public/stylesheets/app1.css~ +177 -0
- data/lib/tennpipes-init/generators/project/public/stylesheets/ennkeypee.css +214 -0
- data/lib/tennpipes-init/generators/project/public/stylesheets/ennkeypee.css~ +214 -0
- data/lib/tennpipes-init/generators/project/public/stylesheets/normalize.css +427 -0
- data/lib/tennpipes-init/generators/project/public/stylesheets/tennpipes.css +6201 -0
- data/lib/tennpipes-init/generators/project/public/stylesheets/tennpipes.css~ +6201 -0
- data/lib/tennpipes-init/generators/project/public/stylesheets/tennpipes.min.css +1 -0
- data/lib/tennpipes-init/generators/runner.rb +139 -0
- data/lib/tennpipes-init/generators/task.rb +45 -0
- data/lib/tennpipes-init/generators/templates/Gemfile.tt +32 -0
- data/lib/tennpipes-init/generators/templates/Rakefile.tt +8 -0
- data/lib/tennpipes-init/generators/templates/controller.rb.tt +22 -0
- data/lib/tennpipes-init/generators/templates/gem/README.md.tt +29 -0
- data/lib/tennpipes-init/generators/templates/gem/gemspec.tt +19 -0
- data/lib/tennpipes-init/generators/templates/gem/lib/libname.tt +6 -0
- data/lib/tennpipes-init/generators/templates/gem/lib/libname/version.tt +3 -0
- data/lib/tennpipes-init/generators/templates/helper.rb.tt +13 -0
- data/lib/tennpipes-init/generators/templates/initializer.rb.tt +5 -0
- data/lib/tennpipes-init/generators/templates/mailer.rb.tt +54 -0
- data/lib/tennpipes-init/generators/templates/project_bin.tt +14 -0
- data/lib/tennpipes-init/generators/templates/task.rb.tt +7 -0
- data/lib/tennpipes-init/tennpipes-tasks/activerecord.rb +377 -0
- data/lib/tennpipes-init/tennpipes-tasks/database.rb +12 -0
- data/lib/tennpipes-init/tennpipes-tasks/datamapper.rb +94 -0
- data/lib/tennpipes-init/tennpipes-tasks/minirecord.rb +19 -0
- data/lib/tennpipes-init/tennpipes-tasks/mongoid.rb +215 -0
- data/lib/tennpipes-init/tennpipes-tasks/mongomapper.rb +55 -0
- data/lib/tennpipes-init/tennpipes-tasks/sequel.rb +85 -0
- data/lib/tennpipes-init/tennpipes-tasks/sql-helpers.rb +72 -0
- data/test/fixtures/admin_template.rb +7 -0
- data/test/fixtures/example_template.rb +15 -0
- data/test/fixtures/git_template.rb +4 -0
- data/test/fixtures/plugin_template.rb +13 -0
- data/test/fixtures/rake_template.rb +9 -0
- data/test/helper.rb +103 -0
- data/test/test_app_generator.rb +142 -0
- data/test/test_cli.rb +27 -0
- data/test/test_component_generator.rb +98 -0
- data/test/test_controller_generator.rb +272 -0
- data/test/test_generator.rb +13 -0
- data/test/test_helper_generator.rb +133 -0
- data/test/test_mailer_generator.rb +69 -0
- data/test/test_migration_generator.rb +222 -0
- data/test/test_model_generator.rb +553 -0
- data/test/test_plugin_generator.rb +152 -0
- data/test/test_project_generator.rb +757 -0
- data/test/test_task_generator.rb +53 -0
- metadata +285 -0
@@ -0,0 +1,152 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/helper')
|
2
|
+
|
3
|
+
describe "PluginGenerator" do
|
4
|
+
def setup
|
5
|
+
@apptmp = "#{Dir.tmpdir}/tennpipes-tests/#{SecureRandom.hex}"
|
6
|
+
`mkdir -p #{@apptmp}`
|
7
|
+
end
|
8
|
+
|
9
|
+
def teardown
|
10
|
+
`rm -rf #{@apptmp}`
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "the plugin generator" do
|
14
|
+
it 'should respect --root option' do
|
15
|
+
path = File.expand_path('../fixtures/plugin_template.rb', __FILE__)
|
16
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}") }
|
17
|
+
out, err = capture_io { generate(:plugin, path, "--root=#{@apptmp}/sample_project") }
|
18
|
+
refute_match /You are not at the root/, out
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "the plugin destroy option" do
|
23
|
+
it 'should remove the plugin instance' do
|
24
|
+
path = File.expand_path('../fixtures/plugin_template.rb', __FILE__)
|
25
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}") }
|
26
|
+
capture_io { generate(:plugin, path, "--root=#{@apptmp}/sample_project") }
|
27
|
+
capture_io { generate(:plugin, path, "--root=#{@apptmp}/sample_project", '-d') }
|
28
|
+
assert_no_file_exists("#{@apptmp}/sample_project/lib/hoptoad_initializer.rb")
|
29
|
+
assert_no_match_in_file(/enable \:raise_errors/,"#{@apptmp}/sample_project/app/app.rb")
|
30
|
+
assert_no_match_in_file(/rack\_hoptoad/, "#{@apptmp}/sample_project/Gemfile")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'the project generator with template' do
|
35
|
+
it 'should invoke Tennpipes.bin_gen' do
|
36
|
+
expects_generated_project :name => 'sample_project', :test => :shoulda, :orm => :activerecord, :dev => true, :template => 'mongochist', :root => @apptmp
|
37
|
+
expects_generated :model, "post title:string body:text -r=#{@apptmp}/sample_project"
|
38
|
+
expects_generated :controller, "posts get:index get:new post:new -r=#{@apptmp}/sample_project"
|
39
|
+
expects_generated :migration, "AddEmailToUser email:string -r=#{@apptmp}/sample_project"
|
40
|
+
expects_generated :fake, "foo bar -r=#{@apptmp}/sample_project"
|
41
|
+
expects_generated :plugin, "carrierwave -r=#{@apptmp}/sample_project"
|
42
|
+
File.stubs(:exist?).returns(true)
|
43
|
+
expects_dependencies 'nokogiri'
|
44
|
+
expects_initializer :test, "# Example", :root => "#{@apptmp}/sample_project"
|
45
|
+
expects_generated :app, "testapp -r=#{@apptmp}/sample_project"
|
46
|
+
expects_generated :controller, "users get:index -r=#{@apptmp}/sample_project --app=testapp"
|
47
|
+
example_template_path = File.join(File.dirname(__FILE__), 'fixtures', 'example_template.rb')
|
48
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", "-p=#{example_template_path}", '> /dev/null') }
|
49
|
+
File.unstub(:exist?)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "with resolving urls" do
|
54
|
+
|
55
|
+
it 'should resolve generic url properly' do
|
56
|
+
template_file = 'http://www.example.com/test.rb'
|
57
|
+
project_gen = Tennpipes::Generators::Project.new(['sample_project'], ["-p=#{template_file}", "-r=#{@apptmp}"], {})
|
58
|
+
project_gen.expects(:apply).with(template_file).returns(true).once
|
59
|
+
capture_io { project_gen.invoke_all }
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should resolve gist url properly' do
|
63
|
+
FakeWeb.register_uri(:get, "https://gist.github.com/357045", :body => '<a href="/raw/357045/4356/blog_template.rb">raw</a>')
|
64
|
+
template_file = 'https://gist.github.com/357045'
|
65
|
+
resolved_path = 'https://gist.github.com/raw/357045/4356/blog_template.rb'
|
66
|
+
project_gen = Tennpipes::Generators::Project.new(['sample_project'], ["-p=#{template_file}", "-r=#{@apptmp}"], {})
|
67
|
+
project_gen.expects(:apply).with(resolved_path).returns(true).once
|
68
|
+
capture_io { project_gen.invoke_all }
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should resolve official template' do
|
72
|
+
template_file = 'sampleblog'
|
73
|
+
resolved_path = "https://raw.github.com/tennpipes/tennpipes-recipes/master/templates/sampleblog_template.rb"
|
74
|
+
project_gen = Tennpipes::Generators::Project.new(['sample_project'], ["-p=#{template_file}", "-r=#{@apptmp}"], {})
|
75
|
+
project_gen.expects(:apply).with(resolved_path).returns(true).once
|
76
|
+
capture_io { project_gen.invoke_all }
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should resolve local file' do
|
80
|
+
template_file = 'path/to/local/file.rb'
|
81
|
+
project_gen = Tennpipes::Generators::Project.new(['sample_project'], ["-p=#{template_file}", "-r=#{@apptmp}"], {})
|
82
|
+
project_gen.expects(:apply).with(File.expand_path(template_file)).returns(true).once
|
83
|
+
capture_io { project_gen.invoke_all }
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should resolve official plugin' do
|
87
|
+
template_file = 'hoptoad'
|
88
|
+
resolved_path = "https://raw.github.com/tennpipes/tennpipes-recipes/master/plugins/hoptoad_plugin.rb"
|
89
|
+
plugin_gen = Tennpipes::Generators::Plugin.new([ template_file], ["-r=#{@apptmp}/sample_project"],{})
|
90
|
+
plugin_gen.expects(:in_app_root?).returns(true).once
|
91
|
+
plugin_gen.expects(:apply).with(resolved_path).returns(true).once
|
92
|
+
capture_io { plugin_gen.invoke_all }
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'should print a warning if template cannot be found' do
|
96
|
+
template_file = 'hwat'
|
97
|
+
resolved_path = "https://raw.github.com/tennpipes/tennpipes-recipes/master/plugins/hwat_plugin.rb"
|
98
|
+
plugin_gen = Tennpipes::Generators::Plugin.new([ template_file], ["-r=#{@apptmp}/sample_project"],{})
|
99
|
+
plugin_gen.expects(:in_app_root?).returns(true).once
|
100
|
+
plugin_gen.expects(:say).with("The template at #{resolved_path} could not be found!", :red).returns(true).once
|
101
|
+
capture_io { plugin_gen.invoke_all }
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "with list option" do
|
106
|
+
it 'should return a list of available plugins with no parameter' do
|
107
|
+
plugin_gen = Tennpipes::Generators::Plugin.new([], [],{})
|
108
|
+
plugin_gen.expects(:list_plugins).returns(true).once
|
109
|
+
capture_io { plugin_gen.invoke_all }
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'should return a list of available plugins with list option' do
|
113
|
+
plugin_gen = Tennpipes::Generators::Plugin.new(['some_plugin'], ["-l", "-r=#{@apptmp}/sample_project"],{})
|
114
|
+
plugin_gen.expects(:list_plugins).returns(true).once
|
115
|
+
capture_io { plugin_gen.invoke_all }
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "with git commands" do
|
120
|
+
it 'should generate a repository correctly' do
|
121
|
+
skip 'Change stubs here'
|
122
|
+
expects_generated_project :test => :rspec, :orm => :activerecord, :name => 'sample_git', :root => "#{@apptmp}"
|
123
|
+
expects_git :init, :root => "#{@apptmp}/sample_git"
|
124
|
+
expects_git :add, :arguments => '.', :root => "#{@apptmp}/sample_git"
|
125
|
+
expects_git :commit, :arguments => 'hello', :root => "#{@apptmp}/sample_git"
|
126
|
+
git_template_path = File.join(File.dirname(__FILE__), 'fixtures', 'git_template.rb')
|
127
|
+
capture_io { generate(:project, 'sample_git', "-p=#{git_template_path}", "-r=#{@apptmp}", '2>&1 /dev/null') }
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe "with rake invocations" do
|
132
|
+
it 'should Run rake task and list tasks' do
|
133
|
+
expects_generated_project :test => :shoulda, :orm => :activerecord, :name => 'sample_rake', :root => "#{@apptmp}"
|
134
|
+
expects_rake "custom", :root => "#{@apptmp}/sample_rake"
|
135
|
+
rake_template_path = File.join(File.dirname(__FILE__), 'fixtures', 'rake_template.rb')
|
136
|
+
capture_io { generate(:project, 'sample_rake', "-p=#{rake_template_path}", "-r=#{@apptmp}", '> /dev/null') }
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe "with admin commands" do
|
141
|
+
it 'should generate correctly an admin' do
|
142
|
+
expects_generated_project :test => :shoulda, :orm => :activerecord, :name => 'sample_admin', :root => "#{@apptmp}"
|
143
|
+
expects_generated :model, "post title:string body:text -r=#{@apptmp}/sample_admin"
|
144
|
+
expects_rake "ar:create", :root => "#{@apptmp}/sample_admin"
|
145
|
+
expects_generated :admin, "-r=#{@apptmp}/sample_admin"
|
146
|
+
expects_rake "ar:migrate", :root => "#{@apptmp}/sample_admin"
|
147
|
+
expects_generated :admin_page, "post -r=#{@apptmp}/sample_admin"
|
148
|
+
admin_template_path = File.join(File.dirname(__FILE__), 'fixtures', 'admin_template.rb')
|
149
|
+
capture_io { generate(:project, 'sample_admin', "-p=#{admin_template_path}", "-r=#{@apptmp}", '> /dev/null') }
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
@@ -0,0 +1,757 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/helper')
|
2
|
+
|
3
|
+
describe "ProjectGenerator" do
|
4
|
+
def setup
|
5
|
+
@apptmp = "#{Dir.tmpdir}/tennpipes-tests/#{SecureRandom.hex}"
|
6
|
+
`mkdir -p #{@apptmp}`
|
7
|
+
end
|
8
|
+
|
9
|
+
def teardown
|
10
|
+
`rm -rf #{@apptmp}`
|
11
|
+
`rm -rf /tmp/project`
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'the project generator' do
|
15
|
+
it 'should allow simple generator to run and create base_app with no options' do
|
16
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}") }
|
17
|
+
assert_dir_exists("#{@apptmp}/sample_project")
|
18
|
+
assert_match_in_file(/module SampleProject/,"#{@apptmp}/sample_project/app/app.rb")
|
19
|
+
assert_match_in_file(/class App < Tennpipes::Application/,"#{@apptmp}/sample_project/app/app.rb")
|
20
|
+
assert_match_in_file("Tennpipes.mount('SampleProject::App', :app_file => Tennpipes.root('app/app.rb')).to('/')", "#{@apptmp}/sample_project/config/apps.rb")
|
21
|
+
assert_file_exists("#{@apptmp}/sample_project/config/boot.rb")
|
22
|
+
assert_file_exists("#{@apptmp}/sample_project/Rakefile")
|
23
|
+
assert_file_exists("#{@apptmp}/sample_project/bin/sample_project")
|
24
|
+
assert_file_exists("#{@apptmp}/sample_project/public/favicon.ico")
|
25
|
+
assert_dir_exists("#{@apptmp}/sample_project/public/images")
|
26
|
+
assert_dir_exists("#{@apptmp}/sample_project/public/javascripts")
|
27
|
+
assert_dir_exists("#{@apptmp}/sample_project/public/stylesheets")
|
28
|
+
assert_dir_exists("#{@apptmp}/sample_project/app/views")
|
29
|
+
assert_dir_exists("#{@apptmp}/sample_project/app/views/layouts")
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should generate a valid name' do
|
33
|
+
capture_io { generate(:project, 'project.com', "--root=#{@apptmp}") }
|
34
|
+
assert_dir_exists("#{@apptmp}/project.com")
|
35
|
+
assert_match_in_file(/module ProjectCom/, "#{@apptmp}/project.com/app/app.rb")
|
36
|
+
assert_match_in_file(/class App < Tennpipes::Application/, "#{@apptmp}/project.com/app/app.rb")
|
37
|
+
assert_match_in_file("Tennpipes.mount('ProjectCom::App', :app_file => Tennpipes.root('app/app.rb')).to('/')", "#{@apptmp}/project.com/config/apps.rb")
|
38
|
+
capture_io { generate(:app, 'ws-dci-2011', "--root=#{@apptmp}/project.com") }
|
39
|
+
assert_dir_exists("#{@apptmp}/project.com/ws_dci_2011")
|
40
|
+
assert_match_in_file(/module ProjectCom/, "#{@apptmp}/project.com/ws_dci_2011/app.rb")
|
41
|
+
assert_match_in_file(/class WsDci2011 < Tennpipes::Application/, "#{@apptmp}/project.com/ws_dci_2011/app.rb")
|
42
|
+
assert_match_in_file("Tennpipes.mount('ProjectCom::WsDci2011', :app_file => Tennpipes.root('ws_dci_2011/app.rb')).to('/ws_dci_2011')", "#{@apptmp}/project.com/config/apps.rb")
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should generate nested path with dashes in name' do
|
46
|
+
capture_io { generate(:project, 'sample-project', "--root=#{@apptmp}") }
|
47
|
+
assert_dir_exists("#{@apptmp}/sample-project")
|
48
|
+
assert_match_in_file(/module SampleProject/, "#{@apptmp}/sample-project/app/app.rb")
|
49
|
+
assert_match_in_file(/class App < Tennpipes::Application/, "#{@apptmp}/sample-project/app/app.rb")
|
50
|
+
assert_match_in_file("Tennpipes.mount('SampleProject::App', :app_file => Tennpipes.root('app/app.rb')).to('/')", "#{@apptmp}/sample-project/config/apps.rb")
|
51
|
+
capture_io { generate(:app, 'ws-dci-2011', "--root=#{@apptmp}/sample-project") }
|
52
|
+
assert_dir_exists("#{@apptmp}/sample-project/ws_dci_2011")
|
53
|
+
assert_match_in_file(/module SampleProject/, "#{@apptmp}/sample-project/ws_dci_2011/app.rb")
|
54
|
+
assert_match_in_file(/class WsDci2011 < Tennpipes::Application/, "#{@apptmp}/sample-project/ws_dci_2011/app.rb")
|
55
|
+
assert_match_in_file("Tennpipes.mount('SampleProject::WsDci2011', :app_file => Tennpipes.root('ws_dci_2011/app.rb')).to('/ws_dci_2011')", "#{@apptmp}/sample-project/config/apps.rb")
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should raise an Error when given invalid constant names' do
|
59
|
+
assert_raises(::NameError) { capture_io { generate(:project, "123asdf", "--root=#{@apptmp}") } }
|
60
|
+
assert_raises(::NameError) { capture_io { generate(:project, "./sample_project", "--root=#{@apptmp}") } }
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should display the right path' do
|
64
|
+
out, err = capture_io { generate(:project, 'project', "--root=/tmp") }
|
65
|
+
assert_dir_exists("/tmp/project")
|
66
|
+
assert_match(/cd \/tmp\/project/, out)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should allow specifying alternate application name' do
|
70
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--app=base_app') }
|
71
|
+
assert_dir_exists("#{@apptmp}/sample_project")
|
72
|
+
assert_match_in_file(/module SampleProject/,"#{@apptmp}/sample_project/app/app.rb")
|
73
|
+
assert_match_in_file(/class BaseApp < Tennpipes::Application/,"#{@apptmp}/sample_project/app/app.rb")
|
74
|
+
assert_match_in_file("Tennpipes.mount('SampleProject::BaseApp', :app_file => Tennpipes.root('app/app.rb')).to('/')", "#{@apptmp}/sample_project/config/apps.rb")
|
75
|
+
assert_file_exists("#{@apptmp}/sample_project/config/boot.rb")
|
76
|
+
assert_file_exists("#{@apptmp}/sample_project/public/favicon.ico")
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should add database tasks to Rakefile if an ORM is defined' do
|
80
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--app=base_app', '--orm=activerecord') }
|
81
|
+
assert_match_in_file('TennpipesTasks.use(:database)',"#{@apptmp}/sample_project/Rakefile")
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should avoid add database tasks on Rakefile if no ORM is specified' do
|
85
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--app=base_app') }
|
86
|
+
assert_no_match_in_file('TennpipesTasks.use(:database)',"#{@apptmp}/sample_project/Rakefile")
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should generate lean project' do
|
90
|
+
capture_io { generate(:project,'sample_project', '--lean', "--root=#{@apptmp}") }
|
91
|
+
assert_file_exists("#{@apptmp}/sample_project/public/favicon.ico")
|
92
|
+
assert_file_exists("#{@apptmp}/sample_project/config/boot.rb")
|
93
|
+
assert_no_file_exists("#{@apptmp}/sample_project/app/app.rb")
|
94
|
+
assert_no_match_in_file(/Tennpipes.mount\('SampleProject::App'/, "#{@apptmp}/sample_project/config/apps.rb")
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'should generate lean project correctly even if the component is specified' do
|
98
|
+
out, err = capture_io { generate(:project,'sample_project', '--lean', "--root=#{@apptmp}", "--orm=activerecord", "--stylesheet=compass") }
|
99
|
+
assert_match("", err)
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should generate tiny skeleton' do
|
103
|
+
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}") }
|
104
|
+
assert_dir_exists("#{@apptmp}/sample_project")
|
105
|
+
assert_dir_exists("#{@apptmp}/sample_project/app")
|
106
|
+
assert_file_exists("#{@apptmp}/sample_project/app/controllers.rb")
|
107
|
+
assert_file_exists("#{@apptmp}/sample_project/app/helpers.rb")
|
108
|
+
assert_file_exists("#{@apptmp}/sample_project/app/mailers.rb")
|
109
|
+
assert_dir_exists("#{@apptmp}/sample_project/public/images")
|
110
|
+
assert_dir_exists("#{@apptmp}/sample_project/public/javascripts")
|
111
|
+
assert_dir_exists("#{@apptmp}/sample_project/public/stylesheets")
|
112
|
+
assert_match_in_file(/:notifier/,"#{@apptmp}/sample_project/app/mailers.rb")
|
113
|
+
assert_match_in_file(/module Helper/, "#{@apptmp}/sample_project/app/helpers.rb")
|
114
|
+
assert_match_in_file(/helpers Helper/, "#{@apptmp}/sample_project/app/helpers.rb")
|
115
|
+
assert_no_file_exists("#{@apptmp}/sample_project/demo/helpers")
|
116
|
+
assert_no_file_exists("#{@apptmp}/sample_project/demo/controllers")
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'should generate gemspec and special files if gem is expected' do
|
120
|
+
capture_io { generate(:project,'sample_gem', '--gem', "--root=#{@apptmp}") }
|
121
|
+
assert_file_exists("#{@apptmp}/sample_gem/sample_gem.gemspec")
|
122
|
+
assert_match_in_file(/^gemspec/,"#{@apptmp}/sample_gem/Gemfile")
|
123
|
+
assert_match_in_file(/^module SampleGem/,"#{@apptmp}/sample_gem/app/app.rb")
|
124
|
+
assert_match_in_file(/class App/,"#{@apptmp}/sample_gem/app/app.rb")
|
125
|
+
assert_file_exists("#{@apptmp}/sample_gem/README.md")
|
126
|
+
assert_no_file_exists("#{@apptmp}/sample_gem/tmp/.keep")
|
127
|
+
assert_no_file_exists("#{@apptmp}/sample_gem/log/.keep")
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should generate gemspec and special files with dashes in name' do
|
131
|
+
capture_io { generate(:project,'sample-gem', '--gem', "--root=#{@apptmp}") }
|
132
|
+
assert_file_exists("#{@apptmp}/sample-gem/sample-gem.gemspec")
|
133
|
+
assert_file_exists("#{@apptmp}/sample-gem/README.md")
|
134
|
+
assert_match_in_file(/\/lib\/sample-gem\/version/,"#{@apptmp}/sample-gem/sample-gem.gemspec")
|
135
|
+
assert_match_in_file(/"sample-gem"/,"#{@apptmp}/sample-gem/sample-gem.gemspec")
|
136
|
+
assert_match_in_file(/SampleGem::VERSION/,"#{@apptmp}/sample-gem/sample-gem.gemspec")
|
137
|
+
assert_match_in_file(/^# SampleGem/,"#{@apptmp}/sample-gem/README.md")
|
138
|
+
assert_match_in_file(/SampleGem::App/,"#{@apptmp}/sample-gem/README.md")
|
139
|
+
assert_match_in_file(/^module SampleGem/,"#{@apptmp}/sample-gem/lib/sample-gem.rb")
|
140
|
+
assert_match_in_file(/gem! "sample-gem"/,"#{@apptmp}/sample-gem/lib/sample-gem.rb")
|
141
|
+
assert_match_in_file(/^module SampleGem/,"#{@apptmp}/sample-gem/lib/sample-gem/version.rb")
|
142
|
+
assert_match_in_file(/^module SampleGem/,"#{@apptmp}/sample-gem/app/app.rb")
|
143
|
+
assert_match_in_file(/class App/,"#{@apptmp}/sample-gem/app/app.rb")
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'should not create models folder if no orm is chosen' do
|
147
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '--orm=none') }
|
148
|
+
assert_no_dir_exists("#{@apptmp}/sample_project/models")
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'should not create tests folder if no test framework is chosen' do
|
152
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '--test=none') }
|
153
|
+
assert_no_dir_exists("#{@apptmp}/sample_project/test")
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'should place app specific names into correct files' do
|
157
|
+
capture_io { generate(:project, 'warepedia', "--root=#{@apptmp}", '--script=none') }
|
158
|
+
assert_match_in_file(/module Warepedia/m, "#{@apptmp}/warepedia/app/app.rb")
|
159
|
+
assert_match_in_file(/class App < Tennpipes::Application/m, "#{@apptmp}/warepedia/app/app.rb")
|
160
|
+
assert_match_in_file("Tennpipes.mount('Warepedia::App', :app_file => Tennpipes.root('app/app.rb')).to('/')", "#{@apptmp}/warepedia/config/apps.rb")
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'should store and apply session_secret' do
|
164
|
+
capture_io { generate(:project,'sample_project', '--tiny',"--root=#{@apptmp}") }
|
165
|
+
assert_match_in_file(/set :session_secret, '[0-9A-z]*'/, "#{@apptmp}/sample_project/config/apps.rb")
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'should create components file containing options chosen with defaults' do
|
169
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}") }
|
170
|
+
components_chosen = YAML.load_file("#{@apptmp}/sample_project/.components")
|
171
|
+
assert_equal 'none', components_chosen[:orm]
|
172
|
+
assert_equal 'none', components_chosen[:test]
|
173
|
+
assert_equal 'none', components_chosen[:mock]
|
174
|
+
assert_equal 'none', components_chosen[:script]
|
175
|
+
assert_equal 'none', components_chosen[:renderer]
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'should create components file containing options chosen' do
|
179
|
+
component_options = ['--orm=datamapper', '--test=riot', '--mock=mocha', '--script=prototype', '--renderer=erb', '--stylesheet=less']
|
180
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", *component_options) }
|
181
|
+
components_chosen = YAML.load_file("#{@apptmp}/sample_project/.components")
|
182
|
+
assert_equal 'datamapper', components_chosen[:orm]
|
183
|
+
assert_equal 'riot', components_chosen[:test]
|
184
|
+
assert_equal 'mocha', components_chosen[:mock]
|
185
|
+
assert_equal 'prototype', components_chosen[:script]
|
186
|
+
assert_equal 'erb', components_chosen[:renderer]
|
187
|
+
assert_equal 'less', components_chosen[:stylesheet]
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'should output to log components being applied' do
|
191
|
+
component_options = ['--orm=datamapper', '--test=riot', '--mock=mocha', '--script=prototype', '--renderer=erb','--stylesheet=less']
|
192
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", *component_options) }
|
193
|
+
assert_match(/applying.*?datamapper.*?orm/, out)
|
194
|
+
assert_match(/applying.*?riot.*?test/, out)
|
195
|
+
assert_match(/applying.*?mocha.*?mock/, out)
|
196
|
+
assert_match(/applying.*?prototype.*?script/, out)
|
197
|
+
assert_match(/applying.*?erb.*?renderer/, out)
|
198
|
+
assert_match(/applying.*?less.*?stylesheet/, out)
|
199
|
+
end
|
200
|
+
|
201
|
+
it 'should output gem files for base app' do
|
202
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none') }
|
203
|
+
assert_match_in_file(/gem 'tennpipes'/, "#{@apptmp}/sample_project/Gemfile")
|
204
|
+
end
|
205
|
+
|
206
|
+
it 'should create .keep files for empty directories that are required for running application' do
|
207
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", "--stylesheet=sass", "--orm=sequel") }
|
208
|
+
assert_file_exists("#{@apptmp}/sample_project/tmp/.keep")
|
209
|
+
assert_file_exists("#{@apptmp}/sample_project/log/.keep")
|
210
|
+
end
|
211
|
+
|
212
|
+
it 'should allow to pass upcased name as the app name' do
|
213
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", "--app=API") }
|
214
|
+
assert_file_exists("#{@apptmp}/sample_project/app/app.rb")
|
215
|
+
assert_match_in_file(/class API < Tennpipes::Application/, "#{@apptmp}/sample_project/app/app.rb")
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
describe "a generator for mock component" do
|
220
|
+
it 'should properly generate for rr and riot' do
|
221
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--mock=rr', '--test=riot', '--script=none') }
|
222
|
+
assert_match(/applying.*?rr.*?mock/, out)
|
223
|
+
assert_match_in_file(/gem 'rr'/, "#{@apptmp}/sample_project/Gemfile")
|
224
|
+
assert_match_in_file(/require 'riot\/rr'/, "#{@apptmp}/sample_project/test/test_config.rb")
|
225
|
+
end
|
226
|
+
|
227
|
+
it 'should properly generate for rr and minitest' do
|
228
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--mock=rr', '--test=minitest', '--script=none') }
|
229
|
+
assert_match(/applying.*?rr.*?mock/, out)
|
230
|
+
assert_match_in_file(/gem 'rr'/, "#{@apptmp}/sample_project/Gemfile")
|
231
|
+
assert_match_in_file(/include RR::Adapters::MiniTest/, "#{@apptmp}/sample_project/test/test_config.rb")
|
232
|
+
end
|
233
|
+
|
234
|
+
it 'should properly generater for rr and bacon' do
|
235
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--mock=rr', '--test=bacon', '--script=none') }
|
236
|
+
assert_match(/applying.*?rr.*?mock/, out)
|
237
|
+
assert_match_in_file(/gem 'rr'/, "#{@apptmp}/sample_project/Gemfile")
|
238
|
+
assert_match_in_file(/include RR::Adapters::TestUnit/m, "#{@apptmp}/sample_project/test/test_config.rb")
|
239
|
+
end
|
240
|
+
|
241
|
+
it 'should properly generate for rr and rspec' do
|
242
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=rspec', '--mock=rr', '--script=none') }
|
243
|
+
assert_match(/applying.*?rr.*?mock/, out)
|
244
|
+
assert_match_in_file(/gem 'rr', :require => false/, "#{@apptmp}/sample_project/Gemfile")
|
245
|
+
assert_match_in_file(/require 'rr'/m, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
246
|
+
end
|
247
|
+
|
248
|
+
it 'should properly generate for mocha and rspec' do
|
249
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}",'--test=rspec', '--mock=mocha', '--script=none') }
|
250
|
+
assert_match(/applying.*?mocha.*?mock/, out)
|
251
|
+
assert_match_in_file(/gem 'mocha'/, "#{@apptmp}/sample_project/Gemfile")
|
252
|
+
assert_match_in_file(/conf.mock_with :mocha/m, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
253
|
+
end
|
254
|
+
|
255
|
+
it 'should properly generate for mocha and riot' do
|
256
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=riot', '--mock=mocha', '--script=none') }
|
257
|
+
assert_match(/applying.*?mocha.*?mock/, out)
|
258
|
+
assert_match_in_file(/gem 'mocha'.*require => false/, "#{@apptmp}/sample_project/Gemfile")
|
259
|
+
assert_match_in_file(/require 'mocha\/api'/, "#{@apptmp}/sample_project/test/test_config.rb")
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
describe "the generator for orm components" do
|
264
|
+
|
265
|
+
describe "for sequel" do
|
266
|
+
it 'should properly generate default' do
|
267
|
+
@app.instance_eval("undef setup_orm if respond_to?('setup_orm')")
|
268
|
+
out, err = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=sequel', '--script=none') }
|
269
|
+
assert_match(/applying.*?sequel.*?orm/, out)
|
270
|
+
assert_match_in_file(/gem 'sequel'/, "#{@apptmp}/project.com/Gemfile")
|
271
|
+
assert_match_in_file(/gem 'sqlite3'/, "#{@apptmp}/project.com/Gemfile")
|
272
|
+
assert_match_in_file(/Sequel.connect/, "#{@apptmp}/project.com/config/database.rb")
|
273
|
+
assert_match_in_file(%r{sqlite://}, "#{@apptmp}/project.com/config/database.rb")
|
274
|
+
assert_match_in_file(%r{project_com}, "#{@apptmp}/project.com/config/database.rb")
|
275
|
+
end
|
276
|
+
|
277
|
+
it 'should properly generate mysql (default to mysql2)' do
|
278
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=sequel', '--adapter=mysql') }
|
279
|
+
assert_match_in_file(/gem 'mysql2'/, "#{@apptmp}/sample_project/Gemfile")
|
280
|
+
assert_match_in_file(%r{"mysql2://}, "#{@apptmp}/sample_project/config/database.rb")
|
281
|
+
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
282
|
+
end
|
283
|
+
|
284
|
+
it 'should properly generate mysql2' do
|
285
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=sequel', '--adapter=mysql2') }
|
286
|
+
assert_match_in_file(/gem 'mysql2'/, "#{@apptmp}/sample_project/Gemfile")
|
287
|
+
assert_match_in_file(%r{"mysql2://}, "#{@apptmp}/sample_project/config/database.rb")
|
288
|
+
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
289
|
+
end
|
290
|
+
|
291
|
+
it 'should properly generate mysql-gem' do
|
292
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=sequel', '--adapter=mysql-gem') }
|
293
|
+
assert_match_in_file(/gem 'mysql'/, "#{@apptmp}/sample_project/Gemfile")
|
294
|
+
assert_match_in_file(%r{"mysql://}, "#{@apptmp}/sample_project/config/database.rb")
|
295
|
+
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
296
|
+
end
|
297
|
+
|
298
|
+
it 'should properly generate sqlite3' do
|
299
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=sequel', '--adapter=sqlite') }
|
300
|
+
assert_match_in_file(/gem 'sqlite3'/, "#{@apptmp}/sample_project/Gemfile")
|
301
|
+
assert_match_in_file(%r{sqlite://}, "#{@apptmp}/sample_project/config/database.rb")
|
302
|
+
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
303
|
+
end
|
304
|
+
|
305
|
+
it 'should properly generate postgres' do
|
306
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=sequel', '--adapter=postgres') }
|
307
|
+
assert_match_in_file(/gem 'pg'/, "#{@apptmp}/sample_project/Gemfile")
|
308
|
+
assert_match_in_file(%r{"postgres://}, "#{@apptmp}/sample_project/config/database.rb")
|
309
|
+
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
describe "for activerecord" do
|
314
|
+
it 'should properly generate default' do
|
315
|
+
out, err = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=activerecord', '--script=none') }
|
316
|
+
assert_match(/applying.*?activerecord.*?orm/, out)
|
317
|
+
assert_match_in_file(/gem 'activerecord', '>= 3.1', :require => 'active_record'/, "#{@apptmp}/project.com/Gemfile")
|
318
|
+
assert_match_in_file(/gem 'sqlite3'/, "#{@apptmp}/project.com/Gemfile")
|
319
|
+
assert_match_in_file(/ActiveRecord::Base.establish_connection/, "#{@apptmp}/project.com/config/database.rb")
|
320
|
+
assert_match_in_file(/project_com/, "#{@apptmp}/project.com/config/database.rb")
|
321
|
+
end
|
322
|
+
|
323
|
+
it 'should properly generate mysql (default to mysql2)' do
|
324
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=activerecord','--adapter=mysql') }
|
325
|
+
assert_match_in_file(/gem 'mysql2'/, "#{@apptmp}/sample_project/Gemfile")
|
326
|
+
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
327
|
+
assert_match_in_file(%r{:adapter => 'mysql2'}, "#{@apptmp}/sample_project/config/database.rb")
|
328
|
+
end
|
329
|
+
|
330
|
+
it 'should properly generate mysql2' do
|
331
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=activerecord','--adapter=mysql2') }
|
332
|
+
assert_match_in_file(/gem 'mysql2'/, "#{@apptmp}/sample_project/Gemfile")
|
333
|
+
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
334
|
+
assert_match_in_file(%r{:adapter => 'mysql2'}, "#{@apptmp}/sample_project/config/database.rb")
|
335
|
+
end
|
336
|
+
|
337
|
+
it 'should properly generate mysql-gem' do
|
338
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=activerecord','--adapter=mysql-gem') }
|
339
|
+
assert_match_in_file(/gem 'mysql', '~> 2.8.1'/, "#{@apptmp}/sample_project/Gemfile")
|
340
|
+
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
341
|
+
assert_match_in_file(%r{:adapter => 'mysql'}, "#{@apptmp}/sample_project/config/database.rb")
|
342
|
+
end
|
343
|
+
|
344
|
+
it 'should properly generate sqlite3' do
|
345
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=activerecord', '--adapter=sqlite3') }
|
346
|
+
assert_match_in_file(/gem 'sqlite3'/, "#{@apptmp}/sample_project/Gemfile")
|
347
|
+
assert_match_in_file(/sample_project_development.db/, "#{@apptmp}/sample_project/config/database.rb")
|
348
|
+
assert_match_in_file(%r{:adapter => 'sqlite3'}, "#{@apptmp}/sample_project/config/database.rb")
|
349
|
+
end
|
350
|
+
|
351
|
+
it 'should properly generate postgres' do
|
352
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=activerecord', '--adapter=postgres') }
|
353
|
+
assert_match_in_file(/gem 'pg'$/, "#{@apptmp}/sample_project/Gemfile")
|
354
|
+
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
355
|
+
assert_match_in_file(%r{:adapter => 'postgresql'}, "#{@apptmp}/sample_project/config/database.rb")
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
describe "for datamapper" do
|
360
|
+
it 'should properly generate default' do
|
361
|
+
out, err = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=datamapper', '--script=none') }
|
362
|
+
assert_match(/applying.*?datamapper.*?orm/, out)
|
363
|
+
assert_match_in_file(/gem 'dm-core'/, "#{@apptmp}/project.com/Gemfile")
|
364
|
+
assert_match_in_file(/gem 'dm-sqlite-adapter'/, "#{@apptmp}/project.com/Gemfile")
|
365
|
+
assert_match_in_file(/DataMapper.setup/, "#{@apptmp}/project.com/config/database.rb")
|
366
|
+
assert_match_in_file(/project_com/, "#{@apptmp}/project.com/config/database.rb")
|
367
|
+
end
|
368
|
+
|
369
|
+
it 'should properly generate for mysql' do
|
370
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=datamapper', '--adapter=mysql') }
|
371
|
+
assert_match_in_file(/gem 'dm-mysql-adapter'/, "#{@apptmp}/sample_project/Gemfile")
|
372
|
+
assert_match_in_file(%r{"mysql://}, "#{@apptmp}/sample_project/config/database.rb")
|
373
|
+
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
374
|
+
end
|
375
|
+
|
376
|
+
# DataMapper has do_mysql that is the version of MySQL driver.
|
377
|
+
it 'should properly generate for mysql2' do
|
378
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=datamapper', '--adapter=mysql2') }
|
379
|
+
assert_match_in_file(/gem 'dm-mysql-adapter'/, "#{@apptmp}/sample_project/Gemfile")
|
380
|
+
assert_match_in_file(%r{"mysql://}, "#{@apptmp}/sample_project/config/database.rb")
|
381
|
+
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
382
|
+
end
|
383
|
+
|
384
|
+
it 'should properly generate for sqlite' do
|
385
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=datamapper', '--adapter=sqlite') }
|
386
|
+
assert_match_in_file(/gem 'dm-sqlite-adapter'/, "#{@apptmp}/sample_project/Gemfile")
|
387
|
+
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
388
|
+
end
|
389
|
+
|
390
|
+
it 'should properly generate for postgres' do
|
391
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=datamapper', '--adapter=postgres') }
|
392
|
+
assert_match_in_file(/gem 'dm-postgres-adapter'/, "#{@apptmp}/sample_project/Gemfile")
|
393
|
+
assert_match_in_file(%r{"postgres://}, "#{@apptmp}/sample_project/config/database.rb")
|
394
|
+
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
395
|
+
end
|
396
|
+
end
|
397
|
+
|
398
|
+
it 'should properly generate for mongomapper' do
|
399
|
+
out, err = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=mongomapper', '--script=none') }
|
400
|
+
assert_match(/applying.*?mongomapper.*?orm/, out)
|
401
|
+
assert_match_in_file(/gem 'mongo_mapper'/, "#{@apptmp}/project.com/Gemfile")
|
402
|
+
assert_match_in_file(/gem 'bson_ext'/, "#{@apptmp}/project.com/Gemfile")
|
403
|
+
assert_match_in_file(/MongoMapper.database/, "#{@apptmp}/project.com/config/database.rb")
|
404
|
+
assert_match_in_file(/project_com/, "#{@apptmp}/project.com/config/database.rb")
|
405
|
+
end
|
406
|
+
|
407
|
+
it 'should properly generate for mongoid' do
|
408
|
+
out, err = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=mongoid', '--script=none') }
|
409
|
+
assert_match(/applying.*?mongoid.*?orm/, out)
|
410
|
+
assert_match_in_file(/gem 'mongoid'/, "#{@apptmp}/project.com/Gemfile")
|
411
|
+
assert_match_in_file(/Mongoid::Config.sessions =/, "#{@apptmp}/project.com/config/database.rb")
|
412
|
+
end
|
413
|
+
|
414
|
+
|
415
|
+
it 'should properly generate for couchrest' do
|
416
|
+
out, err = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=couchrest', '--script=none') }
|
417
|
+
assert_match(/applying.*?couchrest.*?orm/, out)
|
418
|
+
assert_match_in_file(/gem 'couchrest_model'/, "#{@apptmp}/project.com/Gemfile")
|
419
|
+
assert_match_in_file(/CouchRest.database!/, "#{@apptmp}/project.com/config/database.rb")
|
420
|
+
assert_match_in_file(/project_com/, "#{@apptmp}/project.com/config/database.rb")
|
421
|
+
end
|
422
|
+
|
423
|
+
it 'should properly generate for ohm' do
|
424
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=ohm', '--script=none') }
|
425
|
+
assert_match(/applying.*?ohm.*?orm/, out)
|
426
|
+
assert_match_in_file(/gem 'ohm'/, "#{@apptmp}/sample_project/Gemfile")
|
427
|
+
assert_match_in_file(/Ohm.connect/, "#{@apptmp}/sample_project/config/database.rb")
|
428
|
+
end
|
429
|
+
|
430
|
+
it 'should properly generate for mongomatic' do
|
431
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=mongomatic', '--script=none') }
|
432
|
+
assert_match(/applying.*?mongomatic.*?orm/, out)
|
433
|
+
assert_match_in_file(/gem 'bson_ext'/, "#{@apptmp}/sample_project/Gemfile")
|
434
|
+
assert_match_in_file(/gem 'mongomatic'/, "#{@apptmp}/sample_project/Gemfile")
|
435
|
+
assert_match_in_file(/Mongomatic.db = Mongo::Connection.new.db/, "#{@apptmp}/sample_project/config/database.rb")
|
436
|
+
end
|
437
|
+
|
438
|
+
it 'should properly generate for ripple' do
|
439
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=ripple', '--script=none') }
|
440
|
+
assert_match(/applying.*?ripple.*?orm/, out)
|
441
|
+
assert_match_in_file(/gem 'ripple'/, "#{@apptmp}/sample_project/Gemfile")
|
442
|
+
assert_match_in_file(/Ripple.load_configuration/, "#{@apptmp}/sample_project/config/database.rb")
|
443
|
+
assert_match_in_file(/http_port: 8098/, "#{@apptmp}/sample_project/config/riak.yml")
|
444
|
+
end
|
445
|
+
|
446
|
+
it 'should properly generate for dynamoid' do
|
447
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=dynamoid', '--script=none') }
|
448
|
+
assert_match(/applying.*?dynamoid.*?orm/, out)
|
449
|
+
assert_match_in_file(/gem 'aws-sdk'/, "#{@apptmp}/sample_project/Gemfile")
|
450
|
+
assert_match_in_file(/gem 'dynamoid', '~>0.7.1'/, "#{@apptmp}/sample_project/Gemfile")
|
451
|
+
assert_match_in_file(/AWS.config/, "#{@apptmp}/sample_project/config/database.rb")
|
452
|
+
assert_match_in_file(/Dynamoid.configure/, "#{@apptmp}/sample_project/config/database.rb")
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
456
|
+
|
457
|
+
describe "the generator for renderer component" do
|
458
|
+
it 'should properly generate for erb' do
|
459
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=erb', '--script=none') }
|
460
|
+
assert_match(/applying.*?erb.*?renderer/, out)
|
461
|
+
assert_match_in_file(/gem 'erubis'/, "#{@apptmp}/sample_project/Gemfile")
|
462
|
+
end
|
463
|
+
|
464
|
+
it 'should properly generate for haml' do
|
465
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=haml','--script=none') }
|
466
|
+
assert_match(/applying.*?haml.*?renderer/, out)
|
467
|
+
assert_match_in_file(/gem 'haml'/, "#{@apptmp}/sample_project/Gemfile")
|
468
|
+
end
|
469
|
+
|
470
|
+
it 'should properly generate for liquid' do
|
471
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=liquid','--script=none') }
|
472
|
+
assert_match(/applying.*?liquid.*?renderer/, out)
|
473
|
+
assert_match_in_file(/gem 'liquid'/, "#{@apptmp}/sample_project/Gemfile")
|
474
|
+
end
|
475
|
+
|
476
|
+
it 'should properly generate for slim' do
|
477
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=slim','--script=none') }
|
478
|
+
assert_match(/applying.*?slim.*?renderer/, out)
|
479
|
+
assert_match_in_file(/gem 'slim'/, "#{@apptmp}/sample_project/Gemfile")
|
480
|
+
end
|
481
|
+
end
|
482
|
+
|
483
|
+
describe "the generator for script component" do
|
484
|
+
it 'should properly generate for jquery' do
|
485
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=jquery') }
|
486
|
+
assert_match(/applying.*?jquery.*?script/, out)
|
487
|
+
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/jquery.js")
|
488
|
+
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/jquery-ujs.js")
|
489
|
+
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/application.js")
|
490
|
+
end
|
491
|
+
|
492
|
+
it 'should properly generate for mootools' do
|
493
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=mootools') }
|
494
|
+
assert_match(/applying.*?mootools.*?script/, out)
|
495
|
+
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/mootools.js")
|
496
|
+
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/mootools-ujs.js")
|
497
|
+
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/application.js")
|
498
|
+
end
|
499
|
+
|
500
|
+
it 'should properly generate for prototype' do
|
501
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=prototype') }
|
502
|
+
assert_match(/applying.*?prototype.*?script/, out)
|
503
|
+
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/protopak.js")
|
504
|
+
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/lowpro.js")
|
505
|
+
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/prototype-ujs.js")
|
506
|
+
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/application.js")
|
507
|
+
end
|
508
|
+
|
509
|
+
it 'should properly generate for rightjs' do
|
510
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=rightjs') }
|
511
|
+
assert_match(/applying.*?rightjs.*?script/, out)
|
512
|
+
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/right.js")
|
513
|
+
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/right-ujs.js")
|
514
|
+
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/application.js")
|
515
|
+
end
|
516
|
+
|
517
|
+
it 'should properly generate for ext-core' do
|
518
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=extcore') }
|
519
|
+
assert_match(/applying.*?extcore.*?script/, out)
|
520
|
+
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/ext.js")
|
521
|
+
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/ext-ujs.js")
|
522
|
+
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/application.js")
|
523
|
+
end
|
524
|
+
|
525
|
+
it 'should properly generate for dojo' do
|
526
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=dojo') }
|
527
|
+
assert_match(/applying.*?dojo.*?script/, out)
|
528
|
+
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/dojo.js")
|
529
|
+
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/dojo-ujs.js")
|
530
|
+
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/application.js")
|
531
|
+
end
|
532
|
+
end
|
533
|
+
|
534
|
+
describe "the generator for test component" do
|
535
|
+
it 'should properly generate for bacon' do
|
536
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=bacon', '--script=none') }
|
537
|
+
assert_match(/applying.*?bacon.*?test/, out)
|
538
|
+
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
539
|
+
assert_match_in_file(/:require => 'rack\/test'/, "#{@apptmp}/sample_project/Gemfile")
|
540
|
+
assert_match_in_file(/:group => 'test'/, "#{@apptmp}/sample_project/Gemfile")
|
541
|
+
assert_match_in_file(/gem 'bacon'/, "#{@apptmp}/sample_project/Gemfile")
|
542
|
+
assert_match_in_file(/Bacon::Context/, "#{@apptmp}/sample_project/test/test_config.rb")
|
543
|
+
assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
544
|
+
assert_file_exists("#{@apptmp}/sample_project/test/test.rake")
|
545
|
+
assert_match_in_file(/Rake::TestTask.new\("test:\#/,"#{@apptmp}/sample_project/test/test.rake")
|
546
|
+
assert_match_in_file(/task 'test' => test_tasks/,"#{@apptmp}/sample_project/test/test.rake")
|
547
|
+
end
|
548
|
+
|
549
|
+
it 'should properly generate for riot' do
|
550
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=riot', '--script=none') }
|
551
|
+
assert_match(/applying.*?riot.*?test/, out)
|
552
|
+
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
553
|
+
assert_match_in_file(/:require => 'rack\/test'/, "#{@apptmp}/sample_project/Gemfile")
|
554
|
+
assert_match_in_file(/:group => 'test'/, "#{@apptmp}/sample_project/Gemfile")
|
555
|
+
assert_match_in_file(/gem 'riot'/, "#{@apptmp}/sample_project/Gemfile")
|
556
|
+
assert_match_in_file(/include Rack::Test::Methods/, "#{@apptmp}/sample_project/test/test_config.rb")
|
557
|
+
assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
558
|
+
assert_match_in_file(/Riot::Situation/, "#{@apptmp}/sample_project/test/test_config.rb")
|
559
|
+
assert_match_in_file(/Riot::Context/, "#{@apptmp}/sample_project/test/test_config.rb")
|
560
|
+
assert_match_in_file(/SampleProject::App\.tap/, "#{@apptmp}/sample_project/test/test_config.rb")
|
561
|
+
assert_file_exists("#{@apptmp}/sample_project/test/test.rake")
|
562
|
+
assert_match_in_file(/Rake::TestTask\.new\("test:\#/,"#{@apptmp}/sample_project/test/test.rake")
|
563
|
+
assert_match_in_file(/task 'test' => test_tasks/,"#{@apptmp}/sample_project/test/test.rake")
|
564
|
+
end
|
565
|
+
|
566
|
+
it 'should properly generate for rspec' do
|
567
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=rspec', '--script=none') }
|
568
|
+
assert_match(/applying.*?rspec.*?test/, out)
|
569
|
+
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
570
|
+
assert_match_in_file(/:require => 'rack\/test'/, "#{@apptmp}/sample_project/Gemfile")
|
571
|
+
assert_match_in_file(/:group => 'test'/, "#{@apptmp}/sample_project/Gemfile")
|
572
|
+
assert_match_in_file(/gem 'rspec'/, "#{@apptmp}/sample_project/Gemfile")
|
573
|
+
assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
574
|
+
assert_match_in_file(/RSpec.configure/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
575
|
+
assert_file_exists("#{@apptmp}/sample_project/spec/spec.rake")
|
576
|
+
assert_match_in_file(/RSpec::Core::RakeTask\.new\("spec:\#/,"#{@apptmp}/sample_project/spec/spec.rake")
|
577
|
+
assert_match_in_file(/task 'spec' => spec_tasks/,"#{@apptmp}/sample_project/spec/spec.rake")
|
578
|
+
end
|
579
|
+
|
580
|
+
it 'should properly generate for shoulda' do
|
581
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=shoulda', '--script=none') }
|
582
|
+
assert_match(/applying.*?shoulda.*?test/, out)
|
583
|
+
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
584
|
+
assert_match_in_file(/:require => 'rack\/test'/, "#{@apptmp}/sample_project/Gemfile")
|
585
|
+
assert_match_in_file(/:group => 'test'/, "#{@apptmp}/sample_project/Gemfile")
|
586
|
+
assert_match_in_file(/gem 'shoulda'/, "#{@apptmp}/sample_project/Gemfile")
|
587
|
+
assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
588
|
+
assert_match_in_file(/Test::Unit::TestCase/, "#{@apptmp}/sample_project/test/test_config.rb")
|
589
|
+
assert_file_exists("#{@apptmp}/sample_project/test/test.rake")
|
590
|
+
assert_match_in_file(/Rake::TestTask\.new\("test:\#/,"#{@apptmp}/sample_project/test/test.rake")
|
591
|
+
assert_match_in_file(/task 'test' => test_tasks/,"#{@apptmp}/sample_project/test/test.rake")
|
592
|
+
end
|
593
|
+
|
594
|
+
it 'should properly generate for steak' do
|
595
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=steak', '--script=none') }
|
596
|
+
assert_match(/applying.*?steak.*?test/, out)
|
597
|
+
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
598
|
+
assert_match_in_file(/:require => 'rack\/test'/, "#{@apptmp}/sample_project/Gemfile")
|
599
|
+
assert_match_in_file(/:group => 'test'/, "#{@apptmp}/sample_project/Gemfile")
|
600
|
+
assert_match_in_file(/gem 'steak'/, "#{@apptmp}/sample_project/Gemfile")
|
601
|
+
assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
602
|
+
assert_match_in_file(/RSpec.configure/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
603
|
+
assert_file_exists("#{@apptmp}/sample_project/spec/spec.rake")
|
604
|
+
assert_match_in_file(/RSpec::Core::RakeTask\.new\("spec:\#/,"#{@apptmp}/sample_project/spec/spec.rake")
|
605
|
+
assert_match_in_file(/task 'spec' => spec_tasks/,"#{@apptmp}/sample_project/spec/spec.rake")
|
606
|
+
end
|
607
|
+
|
608
|
+
it 'should properly generate for minitest' do
|
609
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=minitest', '--script=none') }
|
610
|
+
assert_match(/applying.*?minitest.*?test/, out)
|
611
|
+
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
612
|
+
assert_match_in_file(/:require => 'rack\/test'/, "#{@apptmp}/sample_project/Gemfile")
|
613
|
+
assert_match_in_file(/:group => 'test'/, "#{@apptmp}/sample_project/Gemfile")
|
614
|
+
assert_match_in_file(/gem 'minitest'/, "#{@apptmp}/sample_project/Gemfile")
|
615
|
+
assert_match_in_file(/include Rack::Test::Methods/, "#{@apptmp}/sample_project/test/test_config.rb")
|
616
|
+
assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
617
|
+
assert_match_in_file(/MiniTest::Spec/, "#{@apptmp}/sample_project/test/test_config.rb")
|
618
|
+
assert_match_in_file(/SampleProject::App\.tap/, "#{@apptmp}/sample_project/test/test_config.rb")
|
619
|
+
assert_file_exists("#{@apptmp}/sample_project/test/test.rake")
|
620
|
+
assert_match_in_file(/Rake::TestTask\.new\("test:\#/,"#{@apptmp}/sample_project/test/test.rake")
|
621
|
+
assert_match_in_file(/task 'test' => test_tasks/,"#{@apptmp}/sample_project/test/test.rake")
|
622
|
+
end # minitest
|
623
|
+
|
624
|
+
it 'should properly generate for cucumber' do
|
625
|
+
out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=cucumber', '--script=none') }
|
626
|
+
assert_match(/applying.*?cucumber.*?test/, out)
|
627
|
+
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
628
|
+
assert_match_in_file(/:require => 'rack\/test'/, "#{@apptmp}/sample_project/Gemfile")
|
629
|
+
assert_match_in_file(/:group => 'test'/, "#{@apptmp}/sample_project/Gemfile")
|
630
|
+
assert_match_in_file(/gem 'rspec'/, "#{@apptmp}/sample_project/Gemfile")
|
631
|
+
assert_match_in_file(/gem 'cucumber'/, "#{@apptmp}/sample_project/Gemfile")
|
632
|
+
assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
633
|
+
assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/features/support/env.rb")
|
634
|
+
assert_match_in_file(/gem 'capybara'/, "#{@apptmp}/sample_project/Gemfile")
|
635
|
+
assert_match_in_file(/RSpec.configure/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
636
|
+
assert_match_in_file(/Capybara.app = /, "#{@apptmp}/sample_project/features/support/env.rb")
|
637
|
+
assert_match_in_file(/World\(Cucumber::Web::URLs\)/, "#{@apptmp}/sample_project/features/support/url.rb")
|
638
|
+
assert_file_exists("#{@apptmp}/sample_project/spec/spec.rake")
|
639
|
+
assert_match_in_file(/RSpec::Core::RakeTask\.new\("spec:\#/,"#{@apptmp}/sample_project/spec/spec.rake")
|
640
|
+
assert_match_in_file(/task 'spec' => spec_tasks/,"#{@apptmp}/sample_project/spec/spec.rake")
|
641
|
+
assert_file_exists("#{@apptmp}/sample_project/features/support/env.rb")
|
642
|
+
assert_file_exists("#{@apptmp}/sample_project/features/add.feature")
|
643
|
+
assert_file_exists("#{@apptmp}/sample_project/features/step_definitions/add_steps.rb")
|
644
|
+
end
|
645
|
+
end
|
646
|
+
|
647
|
+
describe "the generator for stylesheet component" do
|
648
|
+
it 'should properly generate for sass' do
|
649
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=haml','--script=none','--stylesheet=sass') }
|
650
|
+
assert_match_in_file(/gem 'sass'/, "#{@apptmp}/sample_project/Gemfile")
|
651
|
+
assert_match_in_file(/module SassInitializer.*Sass::Plugin::Rack/m, "#{@apptmp}/sample_project/lib/sass_initializer.rb")
|
652
|
+
assert_match_in_file(/register SassInitializer/m, "#{@apptmp}/sample_project/app/app.rb")
|
653
|
+
assert_dir_exists("#{@apptmp}/sample_project/app/stylesheets")
|
654
|
+
end
|
655
|
+
|
656
|
+
it 'should properly generate for less' do
|
657
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=haml','--script=none','--stylesheet=less') }
|
658
|
+
assert_match_in_file(/gem 'rack-less'/, "#{@apptmp}/sample_project/Gemfile")
|
659
|
+
assert_match_in_file(/module LessInitializer.*Rack::Less/m, "#{@apptmp}/sample_project/lib/less_initializer.rb")
|
660
|
+
assert_match_in_file(/register LessInitializer/m, "#{@apptmp}/sample_project/app/app.rb")
|
661
|
+
assert_dir_exists("#{@apptmp}/sample_project/app/stylesheets")
|
662
|
+
end
|
663
|
+
|
664
|
+
it 'should properly generate for compass' do
|
665
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=haml','--script=none','--stylesheet=compass') }
|
666
|
+
assert_match_in_file(/gem 'compass'/, "#{@apptmp}/sample_project/Gemfile")
|
667
|
+
assert_match_in_file(/Compass.configure_sass_plugin\!/, "#{@apptmp}/sample_project/lib/compass_plugin.rb")
|
668
|
+
assert_match_in_file(/module CompassInitializer.*Sass::Plugin::Rack/m, "#{@apptmp}/sample_project/lib/compass_plugin.rb")
|
669
|
+
assert_match_in_file(/register CompassInitializer/m, "#{@apptmp}/sample_project/app/app.rb")
|
670
|
+
|
671
|
+
assert_file_exists("#{@apptmp}/sample_project/app/stylesheets/application.scss")
|
672
|
+
assert_file_exists("#{@apptmp}/sample_project/app/stylesheets/partials/_base.scss")
|
673
|
+
end
|
674
|
+
|
675
|
+
it 'should properly generate for scss' do
|
676
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=haml','--script=none','--stylesheet=scss') }
|
677
|
+
assert_match_in_file(/gem 'haml'/, "#{@apptmp}/sample_project/Gemfile")
|
678
|
+
assert_match_in_file(/module ScssInitializer.*Sass::Plugin::Rack/m, "#{@apptmp}/sample_project/lib/scss_initializer.rb")
|
679
|
+
assert_match_in_file(/Sass::Plugin.options\[:syntax\] = :scss/m, "#{@apptmp}/sample_project/lib/scss_initializer.rb")
|
680
|
+
assert_match_in_file(/register ScssInitializer/m, "#{@apptmp}/sample_project/app/app.rb")
|
681
|
+
assert_dir_exists("#{@apptmp}/sample_project/app/stylesheets")
|
682
|
+
end
|
683
|
+
end
|
684
|
+
|
685
|
+
describe "tiny app skeleton generator for test component" do
|
686
|
+
it "should properly generate for rspec" do
|
687
|
+
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}", "--test=rspec") }
|
688
|
+
assert_dir_exists("#{@apptmp}/sample_project/spec/")
|
689
|
+
assert_file_exists("#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
690
|
+
assert_file_exists("#{@apptmp}/sample_project/spec/app/helpers/helpers_spec.rb")
|
691
|
+
assert_match_in_file(/Dir\[File\.expand_path\(File\.dirname\(__FILE__\) \+ "\/\.\.\/app\/helpers\.rb"\)\]\.each\(&method\(:require\)\)/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
692
|
+
assert_match_in_file(/RSpec\.describe "Controller" do/, "#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
693
|
+
assert_match_in_file(/get "\/"/, "#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
694
|
+
assert_match_in_file(/RSpec.describe "SampleProject::App::Helper" do/, "#{@apptmp}/sample_project/spec/app/helpers/helpers_spec.rb")
|
695
|
+
end
|
696
|
+
|
697
|
+
it "should properly generate for steak" do
|
698
|
+
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}", "--test=steak") }
|
699
|
+
assert_dir_exists("#{@apptmp}/sample_project/spec/")
|
700
|
+
assert_file_exists("#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
701
|
+
assert_file_exists("#{@apptmp}/sample_project/spec/app/helpers/helpers_spec.rb")
|
702
|
+
assert_match_in_file(/Dir\[File\.expand_path\(File\.dirname\(__FILE__\) \+ "\/\.\.\/app\/helpers\.rb"\)\]\.each\(&method\(:require\)\)/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
703
|
+
assert_match_in_file(/describe "Controller" do/, "#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
704
|
+
assert_match_in_file(/describe "SampleProject::App::Helper" do/, "#{@apptmp}/sample_project/spec/app/helpers/helpers_spec.rb")
|
705
|
+
end
|
706
|
+
|
707
|
+
it "should properly generate for cucumber" do
|
708
|
+
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}", "--test=cucumber") }
|
709
|
+
assert_dir_exists("#{@apptmp}/sample_project/spec/")
|
710
|
+
assert_file_exists("#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
711
|
+
assert_file_exists("#{@apptmp}/sample_project/spec/app/helpers/helpers_spec.rb")
|
712
|
+
assert_match_in_file(/Dir\[File\.expand_path\(File\.dirname\(__FILE__\) \+ "\/\.\.\/app\/helpers\.rb"\)\]\.each\(&method\(:require\)\)/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
713
|
+
assert_match_in_file(/describe "Controller" do/, "#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
714
|
+
assert_match_in_file(/describe "SampleProject::App::Helper" do/, "#{@apptmp}/sample_project/spec/app/helpers/helpers_spec.rb")
|
715
|
+
end
|
716
|
+
|
717
|
+
it "should properly generate for bacon" do
|
718
|
+
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}", "--test=bacon") }
|
719
|
+
assert_dir_exists("#{@apptmp}/sample_project/test/")
|
720
|
+
assert_file_exists("#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
721
|
+
assert_file_exists("#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
722
|
+
assert_match_in_file(/Dir\[File\.expand_path\(File\.dirname\(__FILE__\) \+ "\/\.\.\/app\/helpers\.rb"\)\]\.each\(&method\(:require\)\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
723
|
+
assert_match_in_file(/describe "Controller" do/, "#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
724
|
+
assert_match_in_file(/describe "SampleProject::App::Helper"/, "#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
725
|
+
end
|
726
|
+
|
727
|
+
it "should properly generate for minitest" do
|
728
|
+
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}", "--test=minitest") }
|
729
|
+
assert_dir_exists("#{@apptmp}/sample_project/test/")
|
730
|
+
assert_file_exists("#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
731
|
+
assert_file_exists("#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
732
|
+
assert_match_in_file(/Dir\[File\.expand_path\(File\.dirname\(__FILE__\) \+ "\/\.\.\/app\/helpers\.rb"\)\]\.each\(&method\(:require\)\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
733
|
+
assert_match_in_file(/describe "Controller" do/, "#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
734
|
+
assert_match_in_file(/describe "SampleProject::App::Helper"/, "#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
735
|
+
end
|
736
|
+
|
737
|
+
it "should properly generate for riot" do
|
738
|
+
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}", "--test=riot") }
|
739
|
+
assert_dir_exists("#{@apptmp}/sample_project/test/")
|
740
|
+
assert_file_exists("#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
741
|
+
assert_file_exists("#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
742
|
+
assert_match_in_file(/Dir\[File\.expand_path\(File\.dirname\(__FILE__\) \+ "\/\.\.\/app\/helpers\.rb"\)\]\.each\(&method\(:require\)\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
743
|
+
assert_match_in_file(/context "Controller" do/, "#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
744
|
+
assert_match_in_file(/describe "SampleProject::App::Helper"/, "#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
745
|
+
end
|
746
|
+
|
747
|
+
it "should properly generate for shoulda" do
|
748
|
+
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}", "--test=shoulda") }
|
749
|
+
assert_dir_exists("#{@apptmp}/sample_project/test/")
|
750
|
+
assert_file_exists("#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
751
|
+
assert_file_exists("#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
752
|
+
assert_match_in_file(/Dir\[File\.expand_path\(File\.dirname\(__FILE__\) \+ "\/\.\.\/app\/helpers\.rb"\)\]\.each\(&method\(:require\)\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
753
|
+
assert_match_in_file(/class ControllerTest < Test::Unit::TestCase/, "#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
754
|
+
assert_match_in_file(/class SampleProject::App::HelperTest < Test::Unit::TestCase/, "#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
755
|
+
end
|
756
|
+
end
|
757
|
+
end
|