# Logstash Filter Rspec testing

**URL:** <https://discuss.elastic.co/t/logstash-filter-rspec-testing/61452>\
**Category:** Logstash\
**Created:** [September 25, 2016, 2:25am UTC](https://discuss.elastic.co/t/logstash-filter-rspec-testing/61452 "2016-09-25T02:25:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahahtyler](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@ahahtyler](https://discuss.elastic.co/u/ahahtyler)\
**Post date:** [September 25, 2016, 2:25am UTC](https://discuss.elastic.co/t/logstash-filter-rspec-testing/61452/1 "2016-09-25T02:25:52Z")

</div>

Hey all,

I'm in the process of creating a logstash filter for CloudFoundry. I want to put a suite of rspec test together, however I'm having an increasingly difficult time.

Here's my current issue: when I execute the rspec test the filter isn't being executed. The filter creates new fields upon receiving an event. Whenever I try to validate that field it's value is set to nil.

You can check out the current rspec file I have here: [https://github.com/ahahtyler/logstash-filter-cloudfoundry/blob/master/spec/filters/cloudfoundry\_spec.rb](https://github.com/ahahtyler/logstash-filter-cloudfoundry/blob/master/spec/filters/cloudfoundry_spec.rb)

From my logstash home directory the command I'm kicking off is: bin/rspec path/to/rspec.rb

Any thoughts or input would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![ahahtyler](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@ahahtyler](https://discuss.elastic.co/u/ahahtyler)\
**Post date:** [September 25, 2016, 3:50am UTC](https://discuss.elastic.co/t/logstash-filter-rspec-testing/61452/2 "2016-09-25T03:50:08Z")

</div>

Looks like I the way I was calling the filter wasn't calling the "register" method and some class variables where left uninitialized.

Will update the spec.rb at the github link when I finish if anyone else stumbles upon this thread.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 4:37am UTC](https://discuss.elastic.co/t/logstash-filter-rspec-testing/61452/3 "2017-07-06T04:37:08Z")

</div>


