mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-16 03:41:41 +00:00
Make to_xpath
stringize a non-string operand as the standard filters do.
This commit is contained in:
parent
d378795176
commit
4c938f14e5
2 changed files with 6 additions and 1 deletions
|
@ -52,7 +52,7 @@ module LiquidInterpolatable
|
|||
|
||||
# Escape a string for use in XPath expression
|
||||
def to_xpath(string)
|
||||
subs = string.scan(/\G(?:\A\z|[^"]+|[^']+)/).map { |x|
|
||||
subs = string.to_s.scan(/\G(?:\A\z|[^"]+|[^']+)/).map { |x|
|
||||
case x
|
||||
when /"/
|
||||
%Q{'#{x}'}
|
||||
|
|
|
@ -53,5 +53,10 @@ describe LiquidInterpolatable::Filters do
|
|||
@filter.to_xpath_roundtrip(string).should == string
|
||||
}
|
||||
end
|
||||
|
||||
it 'should stringize a non-string operand' do
|
||||
@filter.to_xpath_roundtrip(nil).should == ''
|
||||
@filter.to_xpath_roundtrip(1).should == '1'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue