-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
simple_form_generator_test.rb
42 lines (36 loc) · 1.56 KB
/
simple_form_generator_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require 'test_helper'
class SimpleFormGeneratorTest < Rails::Generators::TestCase
tests SimpleForm::Generators::InstallGenerator
destination File.expand_path('../../tmp', __FILE__)
setup :prepare_destination
teardown { rm_rf(destination_root) }
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
assert_file 'config/initializers/simple_form.rb',
/config\.default_wrapper = :default/, /config\.boolean_style = :nested/
end
test 'generates the simple_form initializer with the bootstrap wrappers' do
run_generator %w(--bootstrap)
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/,
/config\.default_wrapper = :bootstrap/
end
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
%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
end