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
4747 options [ 'help' ] ||= ''
4848 end
4949
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-
5950 def method_missing ( method_name , *arguments , &block )
6051 key = method_name . to_s
6152 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")"
45 exit 1
56fi
7+
68% 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")"
45 exit 1
56fi
7+
68% end
Original file line number Diff line number Diff line change 3939 end
4040 end
4141 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
6442end
You can’t perform that action at this time.
0 commit comments