Skip to content

Instantly share code, notes, and snippets.

@anveo
Created February 18, 2015 20:06
Show Gist options
  • Save anveo/5f201f0ead0e5f30b975 to your computer and use it in GitHub Desktop.
Save anveo/5f201f0ead0e5f30b975 to your computer and use it in GitHub Desktop.
logstash spec
$ logstash rspec spec.rb
Using Accessor#strict_set for specs
Run options: exclude {:redis=>true, :socket=>true, :performance=>true, :elasticsearch=>true, :broken=>true, :export_cypher=>true}
..
Finished in 0.11 seconds
2 examples, 0 failures
require "test_utils"
describe "dash check" do
extend LogStash::RSpec
config <<-CONFIG
filter {
if [@message] =~ /[-]/ {
mutate {
'add_tag' => ["has_dash"]
}
}
}
CONFIG
sample({'@message' => 'FOOBAR'}) do
insist { subject["tags"] } == nil
end
sample({'@message' => 'FOO-BAR'}) do
insist { subject["tags"].include?("has_dash") }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment