File tree Expand file tree Collapse file tree 4 files changed +10
-37
lines changed Expand file tree Collapse file tree 4 files changed +10
-37
lines changed Original file line number Diff line number Diff line change @@ -47,15 +47,6 @@ def help
47
47
options [ 'help' ] ||= ''
48
48
end
49
49
50
- def validations
51
- return [ ] unless options [ 'validate' ]
52
- if options [ 'validate' ] . is_a? String
53
- [ options [ 'validate' ] ]
54
- else
55
- options [ 'validate' ]
56
- end
57
- end
58
-
59
50
def method_missing ( method_name , *arguments , &block )
60
51
key = method_name . to_s
61
52
respond_to? ( method_name ) ? options [ key ] : super
Original file line number Diff line number Diff line change 1
- % validations.each do |validation_function|
2
- if [[ -n $(validate_<%= validation_function %> "$1") ]]; then
3
- printf "<%= strings[:validation_error] %> \n" "<%= name.upcase %> " "$(validate_<%= validation_function %> "$1")"
1
+ # :argument.validations
2
+ % if validate
3
+ if [[ -n $(validate_<%= validate %> "$1") ]]; then
4
+ printf "<%= strings[:validation_error] %> \n" "<%= name.upcase %> " "$(validate_<%= validate %> "$1")"
4
5
exit 1
5
6
fi
7
+
6
8
% end
Original file line number Diff line number Diff line change 1
- % validations.each do |validation_function|
2
- if [[ -n $(validate_<%= validation_function %> "$2") ]]; then
3
- printf "<%= strings[:validation_error] %> \n" "<%= usage_string %> " "$(validate_<%= validation_function %> "$2")"
1
+ # :flag.validations
2
+ % if validate
3
+ if [[ -n $(validate_<%= validate %> "$2") ]]; then
4
+ printf "<%= strings[:validation_error] %> \n" "<%= usage_string %> " "$(validate_<%= validate %> "$2")"
4
5
exit 1
5
6
fi
7
+
6
8
% end
Original file line number Diff line number Diff line change 39
39
end
40
40
end
41
41
end
42
-
43
- describe '#validations' do
44
- context "when validate is empty" do
45
- it "returns an empty array" do
46
- expect ( subject . validations ) . to eq [ ]
47
- end
48
- end
49
-
50
- context "when validate is a String" do
51
- let ( :options ) { { "validate" => "integer" } }
52
- it "returns an array of validation names" do
53
- expect ( subject . validations ) . to eq [ "integer" ]
54
- end
55
- end
56
-
57
- context "when validate is an array" do
58
- let ( :options ) { { "validate" => [ "black" , "white" ] } }
59
- it "returns an array of validation names" do
60
- expect ( subject . validations ) . to eq [ "black" , "white" ]
61
- end
62
- end
63
- end
64
42
end
You can’t perform that action at this time.
0 commit comments