Sha256: 8bb69aa24e94b3dbe75f76ef3ea49b9ad695c6c9e62b3383435a20750d31afb8

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'

class RFlow
  describe ForwardToInputPort do
    before(:each) do
      ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
      Configuration.migrate_database
    end

    let(:filtered_messages) { [] }
    let(:dropped_messages) { [] }

    let(:generator) do
      RFlow::Components::GenerateIntegerSequence.new.tap do |c|
        c.configure!({})
        c.out.direct_connect ruby_proc_filter.in
      end
    end

    let(:ruby_proc_filter) do
      RFlow::Components::RubyProcFilter.new.tap do |c|
        c.configure! 'filter_proc_string' => 'message.data.data_object % 2 == 0'
      end
    end

    it 'should forward generated integers to be filtered by the proc filter' do
      ruby_proc_filter.filtered.collect_messages(nil, filtered_messages) do
        ruby_proc_filter.dropped.collect_messages(nil, dropped_messages) do
          5.times { generator.generate }
        end
      end

      expect(filtered_messages).to have(3).messages
      expect(filtered_messages.map(&:data).map(&:data_object)).to eq([0, 2, 4])
      expect(dropped_messages).to have(2).messages
      expect(dropped_messages.map(&:data).map(&:data_object)).to eq([1, 3])
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rflow-1.0.1 spec/rflow/forward_to_input_port_spec.rb
rflow-1.0.0 spec/rflow/forward_to_input_port_spec.rb
rflow-1.0.0a6 spec/rflow/forward_to_input_port_spec.rb
rflow-1.0.0a5 spec/rflow/forward_to_input_port_spec.rb