Sha256: f4190b2e8dbb15db57bcfcf51581925e3497ff228a932b7a8dd066d26ce80b9f

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'

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

    let(:message_connection) { RFlow::MessageCollectingConnection.new }

    let(:generator) do
      config = RFlow::Configuration::Component.new.tap do |c|
        c.output_ports << RFlow::Configuration::OutputPort.new(name: 'out')
      end
      RFlow::Components::GenerateIntegerSequence.new(config).tap do |c|
        c.configure! config.options
        c.out.add_connection nil, ForwardToOutputPort.new(ruby_proc_filter, 'filtered')
      end
    end

    let(:ruby_proc_filter) do
      config = RFlow::Configuration::Component.new.tap do |c|
        c.output_ports << RFlow::Configuration::OutputPort.new(name: 'filtered')
        c.options = {'filter_proc_string' => 'message % 2 == 0'}
      end
      RFlow::Components::RubyProcFilter.new(config).tap do |c|
        c.configure! config.options
        c.filtered.add_connection nil, message_connection
      end
    end

    def messages; message_connection.messages; end

    it 'should place the messages on the output port, regardless of the filter' do
      5.times { generator.generate }
      messages.map(&:data).map(&:data_object).should == [0, 1, 2, 3, 4]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rflow-1.0.0a2 spec/rflow/forward_to_output_port_spec.rb