Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/logstash/config/grammar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3453,7 +3453,7 @@ def _nt_selector_element
if r1
s2, i2 = [], index
loop do
if has_terminal?('\G[^\\], ]', true, index)
if has_terminal?('\G[^\\],]', true, index)
r3 = true
@index += 1
else
Expand Down
2 changes: 1 addition & 1 deletion lib/logstash/config/grammar.treetop
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ grammar LogStashConfig
end

rule selector_element
"[" [^\], ]+ "]"
"[" [^\],]+ "]"
<LogStash::Config::AST::SelectorElement>
end

Expand Down
24 changes: 22 additions & 2 deletions spec/conditionals/test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "test_utils"

module ConditionalFancines
module ConditionalFanciness
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a typo correction :P

def description
return example.metadata[:example_group][:description_args][0]
end
Expand All @@ -23,7 +23,7 @@ def conditional(expression, &block)

describe "conditionals" do
extend LogStash::RSpec
extend ConditionalFancines
extend ConditionalFanciness

describe "simple" do
config <<-CONFIG
Expand Down Expand Up @@ -320,4 +320,24 @@ def conditional(expression, &block)
end
end
end

describe "field references" do
conditional "[field with space]" do
sample("field with space" => "hurray") do
insist { subject["tags"].include?("success") }
end
end

conditional "[field with space] == 'hurray'" do
sample("field with space" => "hurray") do
insist { subject["tags"].include?("success") }
end
end

conditional "[nested field][reference with][some spaces] == 'hurray'" do
sample({"nested field" => { "reference with" => { "some spaces" => "hurray" } } }) do
insist { subject["tags"].include?("success") }
end
end
end
end