Permalink
Browse files

Downcase enum values on validation

When trying to assign an enum value, downcase it. Tidy does not seem to
mind mixed-caseness of enum values. Who are we to enfore that in the
bindings?
  • Loading branch information...
1 parent acf0787 commit 94fc091aedb5bef9a2760c62d2344a36a6f2824d @libc committed Dec 11, 2012
Showing with 7 additions and 2 deletions.
  1. +1 −1 lib/tidy_ffi/interface.rb
  2. +6 −1 spec/simple_spec.rb
@@ -186,7 +186,7 @@ def self.option_valid?(option, value)
if Integer === value
!!spec[:values][value]
else
- spec[:values].include?(value)
+ spec[:values].include?(value.downcase)
end
when :string
String === value || Symbol === value
View
@@ -49,5 +49,10 @@
TidyFFI::Tidy.default_options = {:force_output => "utter garbage"}
end.should raise_error(TidyFFI::Tidy::InvalidOptionValue)
end
+
+ it 'accepts UTF-8 writter in uppercase' do
+ TidyFFI::Tidy.validate_options = true
+ expect { TidyFFI::Tidy.default_options = {:char_encoding => "UTF8"} }.not_to raise_error
+ end
end
-end
+end

0 comments on commit 94fc091

Please sign in to comment.