# Plugin test failing

**URL:** <https://discuss.elastic.co/t/plugin-test-failing/143612>\
**Category:** Logstash\
**Created:** [August 8, 2018, 11:49pm UTC](https://discuss.elastic.co/t/plugin-test-failing/143612 "2018-08-08T23:49:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mandi](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@mandi](https://discuss.elastic.co/u/mandi)\
**Post date:** [August 8, 2018, 11:49pm UTC](https://discuss.elastic.co/t/plugin-test-failing/143612/1 "2018-08-08T23:49:16Z")

</div>

This might be a stupid question, but I can't seem to figure it out.

I'm trying to write a filter plugin for logstash and started by generating the default "Hello, world!" plugin and going through the basic development process. But I get stuck when running the _rspec_ testing process.

These are the steps I followed:

1. Downloaded logstash to my local machine from [https://www.elastic.co/downloads/logstash](https://www.elastic.co/downloads/logstash).

2. Ran the `bin/logstash-plugin generate --type filter --name new-plugin --path <path to a new repo I created>`

3. Figured out that I needed JRuby, so I installed _rvm_ then ran `rvm install jruby` and `rvm use jruby`.

4. Finally got `bundle install` working.

5. Woops! I still need _rspec_ so I `gem install rspec`.

6. Run `bundle exec rspec`, but I get the following result:

What could be causing this?

Thanks

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [August 9, 2018, 7:43am UTC](https://discuss.elastic.co/t/plugin-test-failing/143612/2 "2018-08-09T07:43:57Z")

</div>

What does the generated code look like?

---

<div class="post-metadata">

**Author:** ![mandi](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@mandi](https://discuss.elastic.co/u/mandi)\
**Post date:** [August 9, 2018, 12:21pm UTC](https://discuss.elastic.co/t/plugin-test-failing/143612/3 "2018-08-09T12:21:19Z")

</div>

I just updated the config files. I messed a bit with the \*\_spec.rb file, but didn't get it to work.

lib/logstash/filters/clean-job.rb

```
# encoding: utf-8
require "logstash/filters/base"
require "logstash/namespace"

# This filter will replace the contents of the default 
# message field with whatever you specify in the configuration.
#
# It is only intended to be used as an .
class LogStash::Filters::CleanJob < LogStash::Filters::Base

# Setting the config_name here is required. This is how you
# configure this filter from your Logstash config.
#
# filter {
# {
# message => "My message..."
# }
# }
#
config_name "clean-job"

# Replace the message with this value.
config :message, :validate => :string, :default => "Hello World!"

public
def register
    # Add instance variables 
end # def register

public
def filter(event)

    if @message
    # Replace the event message with our message as configured in the
    # config file.
    event.set("message", @message)
    end

    # filter_matched should go in the last line of our successful code
    filter_matched(event)
end # def filter
end # class LogStash::Filters::CleanJob

```

spec/filters/clean-job\_spec.rb

```
# encoding: utf-8
require_relative '../spec_helper'
require "logstash/filters/clean-job"

describe LogStash::Filters::CleanJob do
describe "Set to Hello World" do
    let(:config) do <<-CONFIG
    filter {
        clean-job {
        message => "Hello World"
        }
    }
    CONFIG
    end
    
    sample("message" => "some text") do
    expect(subject).to include("message")
    expect(subject.get('message')).to eq('Hello World')
    end
end
end

```

logstash-filter-clean-job.gemspec

```
Gem::Specification.new do |s|
s.name = 'logstash-filter-clean-job'
s.version = '0.1.0'
s.licenses = ['Apache-2.0']
s.summary = 'A summary'
s.description = 'A description'
s.homepage = 'https://homepage.com'
s.authors = ['mandi']
s.email = 'mandi@email.com'
s.require_paths = ['lib']

# Files
s.files = Dir['lib/ **/*','spec/** /*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
# Tests
s.test_files = s.files.grep(%r{^(test|spec|features)/})

# Special flag to let us know this is actually a logstash plugin
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }

# Gem dependencies
s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
s.add_development_dependency 'logstash-devutils'
end

```

Gemfile

```
source 'https://rubygems.org'

gemspec
```

---

<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:** [September 6, 2018, 12:21pm UTC](https://discuss.elastic.co/t/plugin-test-failing/143612/4 "2018-09-06T12:21:19Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
