spec/rflow/components/clock_spec.rb in rflow-1.0.0a4 vs spec/rflow/components/clock_spec.rb in rflow-1.0.0a5

- old
+ new

@@ -5,22 +5,19 @@ describe Clock do before(:each) do ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:" Configuration.migrate_database end - let(:message_connection) { RFlow::MessageCollectingConnection.new } + let(:messages) { [] } + def clock(args = {}) Clock.new.tap do |c| c.configure! args - c.tick_port.connect! - c.tick_port.add_connection nil, message_connection end end - def messages; message_connection.messages; end - it 'defaults configuration nicely' do clock.tap do |c| expect(c.clock_name).to eq('Clock') expect(c.tick_interval).to eq(1) end @@ -49,17 +46,19 @@ clock.run! end it 'should generate a tick message when asked' do clock.tap do |c| - now = Integer(Time.now.to_f * 1000) - expect(messages).to be_empty - c.tick - expect(messages).to have(1).message - messages.first.tap do |m| - expect(m.data_type_name).to eq('RFlow::Message::Clock::Tick') - expect(m.data.name).to eq('Clock') - expect(m.data.timestamp).to be >= now + c.tick_port.collect_messages(nil, messages) do + now = Integer(Time.now.to_f * 1000) + expect(messages).to be_empty + c.tick + expect(messages).to have(1).message + messages.first.tap do |m| + expect(m.data_type_name).to eq('RFlow::Message::Clock::Tick') + expect(m.data.name).to eq('Clock') + expect(m.data.timestamp).to be >= now + end end end end end end