test/test_skeleton_generator.rb in padrino-gen-0.1.3 vs test/test_skeleton_generator.rb in padrino-gen-0.1.4
- old
+ new
@@ -8,19 +8,28 @@
end
context 'the skeleton generator' do
should "allow simple generator to run and create base_app with no options" do
assert_nothing_raised { silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=none']) } }
- assert File.exist?('/tmp/sample_app')
- assert File.exist?('/tmp/sample_app/app')
- assert File.exist?('/tmp/sample_app/config/boot.rb')
- assert File.exist?('/tmp/sample_app/test/test_config.rb')
+ assert_file_exists('/tmp/sample_app')
+ assert_file_exists('/tmp/sample_app/app')
+ assert_file_exists('/tmp/sample_app/config/boot.rb')
+ assert_dir_exists('/tmp/sample_app/app/models')
+ assert_file_exists('/tmp/sample_app/test/test_config.rb')
end
+ should "not create models folder if no orm is chosen" do
+ silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=none', '--orm=none']) }
+ assert_no_dir_exists('/tmp/sample_app/app/models')
+ end
+ should "not create tests folder if no test framework is chosen" do
+ silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=none', '--test=none']) }
+ assert_no_dir_exists('/tmp/sample_app/test')
+ end
should "place app specific names into correct files" do
silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=none']) }
assert_match_in_file(/class SampleApp < Padrino::Application/m, '/tmp/sample_app/app/app.rb')
- assert_match_in_file(/Padrino.mount_core\(:app_class => "SampleApp"\)/m, '/tmp/sample_app/config/apps.rb')
+ assert_match_in_file(/Padrino.mount_core\("SampleApp"\)/m, '/tmp/sample_app/config/apps.rb')
assert_match_in_file(/SampleApp.urls do/m, '/tmp/sample_app/config/urls.rb')
end
should "create components file containing options chosen with defaults" do
silence_logger { @skeleton.start(['sample_app', '/tmp']) }
components_chosen = YAML.load_file('/tmp/sample_app/.components')
@@ -79,39 +88,44 @@
@skeleton.instance_eval("undef setup_orm if respond_to?('setup_orm')")
buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--orm=sequel', '--script=none']) }
assert_match /Applying.*?sequel.*?orm/, buffer
assert_match_in_file(/gem 'sequel'/, '/tmp/sample_app/Gemfile')
assert_match_in_file(/Sequel.connect/, '/tmp/sample_app/config/database.rb')
+ assert_dir_exists('/tmp/sample_app/app/models')
end
should "properly generate for activerecord" do
buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--orm=activerecord', '--script=none']) }
assert_match /Applying.*?activerecord.*?orm/, buffer
assert_match_in_file(/gem 'activerecord'/, '/tmp/sample_app/Gemfile')
assert_match_in_file(/Migrate the database/, '/tmp/sample_app/Rakefile')
assert_match_in_file(/ActiveRecord::Base.establish_connection/, '/tmp/sample_app/config/database.rb')
+ assert_dir_exists('/tmp/sample_app/app/models')
end
should "properly generate default for datamapper" do
buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--orm=datamapper', '--script=none']) }
assert_match /Applying.*?datamapper.*?orm/, buffer
assert_match_in_file(/gem 'dm-core'/, '/tmp/sample_app/Gemfile')
assert_match_in_file(/DataMapper.setup/, '/tmp/sample_app/config/database.rb')
+ assert_dir_exists('/tmp/sample_app/app/models')
end
should "properly generate for mongomapper" do
buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--orm=mongomapper', '--script=none']) }
assert_match /Applying.*?mongomapper.*?orm/, buffer
assert_match_in_file(/gem 'mongo_mapper'/, '/tmp/sample_app/Gemfile')
assert_match_in_file(/MongoMapper.database/, '/tmp/sample_app/config/database.rb')
+ assert_dir_exists('/tmp/sample_app/app/models')
end
should "properly generate for couchrest" do
buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--orm=couchrest', '--script=none']) }
assert_match /Applying.*?couchrest.*?orm/, buffer
assert_match_in_file(/gem 'couchrest'/, '/tmp/sample_app/Gemfile')
assert_match_in_file(/CouchRest.database!/, '/tmp/sample_app/config/database.rb')
+ assert_dir_exists('/tmp/sample_app/app/models')
end
end
context "the generator for renderer component" do
should "properly generate default for erb" do
@@ -122,66 +136,76 @@
should "properly generate for haml" do
buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--renderer=haml','--script=none']) }
assert_match /Applying.*?haml.*?renderer/, buffer
assert_match_in_file(/gem 'haml'/, '/tmp/sample_app/Gemfile')
+ assert_match_in_file(/module SassInitializer.*Sass::Plugin::Rack/m, '/tmp/sample_app/config/initializers/sass.rb')
+ assert_file_exists('/tmp/sample_app/public/stylesheets/sass')
end
end
context "the generator for script component" do
should "properly generate for jquery" do
buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=jquery']) }
assert_match /Applying.*?jquery.*?script/, buffer
- assert File.exist?('/tmp/sample_app/public/javascripts/jquery.min.js')
+ assert_file_exists('/tmp/sample_app/public/javascripts/jquery.min.js')
+ assert_file_exists('/tmp/sample_app/public/javascripts/application.js')
end
should "properly generate for prototype" do
buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=prototype']) }
assert_match /Applying.*?prototype.*?script/, buffer
- assert File.exist?('/tmp/sample_app/public/javascripts/prototype.js')
- assert File.exist?('/tmp/sample_app/public/javascripts/lowpro.js')
+ assert_file_exists('/tmp/sample_app/public/javascripts/prototype.js')
+ assert_file_exists('/tmp/sample_app/public/javascripts/lowpro.js')
+ assert_file_exists('/tmp/sample_app/public/javascripts/application.js')
end
should "properly generate for rightjs" do
buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--script=rightjs']) }
assert_match /Applying.*?rightjs.*?script/, buffer
- assert File.exist?('/tmp/sample_app/public/javascripts/right-min.js')
+ assert_file_exists('/tmp/sample_app/public/javascripts/right-min.js')
+ assert_file_exists('/tmp/sample_app/public/javascripts/application.js')
end
end
context "the generator for test component" do
should "properly default generate for bacon" do
buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--test=bacon', '--script=none']) }
assert_match /Applying.*?bacon.*?test/, buffer
assert_match_in_file(/gem 'bacon'/, '/tmp/sample_app/Gemfile')
+ assert_match_in_file(/Bundler.require_env\(:testing\)/, '/tmp/sample_app/test/test_config.rb')
assert_match_in_file(/Bacon::Context/, '/tmp/sample_app/test/test_config.rb')
end
should "properly generate for riot" do
buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--test=riot', '--script=none']) }
assert_match /Applying.*?riot.*?test/, buffer
assert_match_in_file(/gem 'riot'/, '/tmp/sample_app/Gemfile')
+ assert_match_in_file(/Bundler.require_env\(:testing\)/, '/tmp/sample_app/test/test_config.rb')
assert_match_in_file(/Riot::Situation/, '/tmp/sample_app/test/test_config.rb')
end
should "properly generate for rspec" do
buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--test=rspec', '--script=none']) }
assert_match /Applying.*?rspec.*?test/, buffer
assert_match_in_file(/gem 'spec'/, '/tmp/sample_app/Gemfile')
+ assert_match_in_file(/Bundler.require_env\(:testing\)/, '/tmp/sample_app/test/test_config.rb')
assert_match_in_file(/Spec::Runner/, '/tmp/sample_app/test/test_config.rb')
end
should "properly generate for shoulda" do
buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--test=shoulda', '--script=none']) }
assert_match /Applying.*?shoulda.*?test/, buffer
assert_match_in_file(/gem 'shoulda'/, '/tmp/sample_app/Gemfile')
+ assert_match_in_file(/Bundler.require_env\(:testing\)/, '/tmp/sample_app/test/test_config.rb')
assert_match_in_file(/Test::Unit::TestCase/, '/tmp/sample_app/test/test_config.rb')
end
should "properly generate for testspec" do
buffer = silence_logger { @skeleton.start(['sample_app', '/tmp', '--test=testspec', '--script=none']) }
assert_match /Applying.*?testspec.*?test/, buffer
assert_match_in_file(/gem 'test\/spec'/, '/tmp/sample_app/Gemfile')
+ assert_match_in_file(/Bundler.require_env\(:testing\)/, '/tmp/sample_app/test/test_config.rb')
assert_match_in_file(/Test::Unit::TestCase/, '/tmp/sample_app/test/test_config.rb')
end
end
end