Sha256: fa7714ee9f70e255c3531dfd66f40f8b25231f32a6dd2212e142449072614ebe

Contents?: true

Size: 1.53 KB

Versions: 8

Compression:

Stored size: 1.53 KB

Contents

# encoding: utf-8
require "logstash/devutils/rspec/spec_helper"
require "logstash/inputs/yasuri"

describe LogStash::Inputs::Yasuri do

  let(:input) {
    input = LogStash::Plugin.lookup("input", "yasuri").new(
      "split" => true,
      "url" => "https://news.ycombinator.com/",
      "parse_tree" => %Q|
        {
          "node": "struct",
          "name": "titles",
          "path": "//td[@class='title'][not(@align)]",
          "children": [
            {
              "node": "text",
              "name": "title",
              "path": "./a"
            },
            {
              "node": "text",
              "name": "url",
              "path": "./a/@href"
            }
          ]
        }
      | # end of "parse_tree"
    )
  }

  let(:input_from_parse_tree_file) {
    input_from_parse_tree_file = LogStash::Plugin.lookup("input", "yasuri").new(
      "split" => true,
      "url" => "https://news.ycombinator.com/",
      "parse_tree_path" => "spec/inputs/res/parse_tree.json"
    )
  }

  it "should register" do
    # register will try to load jars and raise if it cannot find jars or if org.apache.log4j.spi.LoggingEvent class is not present
    expect {input.register}.to_not raise_error
  end

  let(:queue) { [] }
  it "enqueues some events" do
    input.register
    input.inner_run(queue)
    expect(queue.size).not_to be_zero
  end

  it "enqueues some events from input_from_parse_tree_file" do
    input_from_parse_tree_file.register
    input_from_parse_tree_file.inner_run(queue)
    expect(queue.size).not_to be_zero
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
logstash-input-yasuri-2.0.7 spec/inputs/yasuri_spec.rb
logstash-input-yasuri-5.0.7 spec/inputs/yasuri_spec.rb
logstash-input-yasuri-2.0.6 spec/inputs/yasuri_spec.rb
logstash-input-yasuri-5.0.6 spec/inputs/yasuri_spec.rb
logstash-input-yasuri-5.0.5 spec/inputs/yasuri_spec.rb
logstash-input-yasuri-2.0.5 spec/inputs/yasuri_spec.rb
logstash-input-yasuri-2.0.4 spec/inputs/yasuri_spec.rb
logstash-input-yasuri-5.0.4 spec/inputs/yasuri_spec.rb