Skip to content

Commit 364e2c9

Browse files
[WIP] Enforce options
1 parent 30c2d9f commit 364e2c9

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

lib/install/web.rb

+27
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1+
def enforce_options!
2+
if incorrect_database? && default_test_suite?
3+
message = <<~ERROR
4+
5+
6+
=== Please use use the correct options ===
7+
8+
rails new <app_name> \
9+
--skip-test \
10+
-d=postgresql \
11+
-m=https://raw.githubusercontent.com/thoughtbot/suspenders/suspenders-3-0-0-web-generator/lib/install/web.rb
12+
ERROR
13+
14+
fail Rails::Generators::Error, message
15+
end
16+
end
17+
18+
def incorrect_database?
19+
options[:database] != "postgresql"
20+
end
21+
22+
def default_test_suite?
23+
!options[:skip_test]
24+
end
25+
26+
enforce_options!
27+
128
after_bundle do
229
gem_group :development, :test do
330
gem "suspenders", github: "thoughtbot/suspenders", branch: "suspenders-3-0-0-web-generator"

0 commit comments

Comments
 (0)