2012-01-24 18:23:50 +00:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class SimpleFormGeneratorTest < Rails::Generators::TestCase
|
|
|
|
tests SimpleForm::Generators::InstallGenerator
|
|
|
|
destination File.expand_path('../../tmp', __FILE__)
|
|
|
|
setup :prepare_destination
|
2012-01-26 12:55:36 +00:00
|
|
|
teardown { rm_rf(destination_root) }
|
2012-01-24 18:23:50 +00:00
|
|
|
|
|
|
|
test 'generates example locale file' do
|
|
|
|
run_generator
|
|
|
|
assert_file 'config/locales/simple_form.en.yml'
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'generates the simple_form initializer' do
|
|
|
|
run_generator
|
2012-01-26 20:20:41 +00:00
|
|
|
assert_file 'config/initializers/simple_form.rb',
|
2012-01-27 18:49:06 +00:00
|
|
|
/config\.default_wrapper = :default/, /config\.boolean_style = :nested/
|
2012-01-24 18:23:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
test 'generates the simple_form initializer with the bootstrap wrappers' do
|
|
|
|
run_generator %w(--bootstrap)
|
2012-04-24 18:54:06 +00:00
|
|
|
assert_file 'config/initializers/simple_form.rb',
|
|
|
|
/config\.default_wrapper = :default/, /config\.boolean_style = :nested/
|
|
|
|
assert_file 'config/initializers/simple_form_bootstrap.rb', /config\.wrappers :bootstrap/,
|
2012-01-27 18:49:06 +00:00
|
|
|
/config\.default_wrapper = :bootstrap/
|
2012-01-24 18:23:50 +00:00
|
|
|
end
|
|
|
|
|
2012-11-04 02:15:44 +00:00
|
|
|
test 'generates the simple_form initializer with the foundation wrappers' do
|
|
|
|
run_generator %w(--foundation)
|
|
|
|
assert_file 'config/initializers/simple_form.rb',
|
|
|
|
/config\.default_wrapper = :default/, /config\.boolean_style = :nested/
|
|
|
|
assert_file 'config/initializers/simple_form_foundation.rb', /config\.wrappers :foundation/,
|
|
|
|
/config\.default_wrapper = :foundation/
|
|
|
|
end
|
|
|
|
|
2012-01-24 18:23:50 +00:00
|
|
|
%W(erb haml slim).each do |engine|
|
|
|
|
test "generates the scaffold template when using #{engine}" do
|
|
|
|
run_generator ['-e', engine]
|
|
|
|
assert_file "lib/templates/#{engine}/scaffold/_form.html.#{engine}"
|
|
|
|
end
|
|
|
|
end
|
2012-01-26 12:55:36 +00:00
|
|
|
end
|