Sha256: e41e424a21602f05eff64850b7e34ffe754799220d4fe27c23c111b2dc79bc44

Contents?: true

Size: 1.24 KB

Versions: 15

Compression:

Stored size: 1.24 KB

Contents

Dir.chdir File.join File.dirname(__FILE__), '../../../'
require './spec/env/iface.rb'
require './spec/lib/helpers.rb'
require './spec/lib/io_extensions.rb'
require './spec/lib/rspec_extensions.rb'

RSpec.describe "iface:driver:timer" do
  module_dep "timer"
  include_context "iface:driver"

  it "Can call initiate a timer" do
    #Wait for response
    @pipe.puts [[0, 0, "ping"]].to_json; @pipe.readline_timeout

    @pipe.puts [[3, 1, "if_timer_init", 3]].to_json

    #Wait for response
    @pipe.puts [[0, 0, "ping"]].to_json; @pipe.readline_timeout
  end

  it "Does receive ticks back when timer is initiated" do
    #Wait for response
    @pipe.puts [[0, 0, "ping"]].to_json; @pipe.readline_timeout

    @pipe.puts [[3, 1, "if_timer_init", 4]].to_json

    #Wait to start until after the 1st event fires to make sure timer started up
    expect(@pipe).to readline_and_equal_json_x_within_y_seconds([0, "int_timer"], 5.seconds)
    start_time = Time.now.to_i
    25.times do
      expect(@pipe).to readline_and_equal_json_x_within_y_seconds([0, "int_timer"], 2.seconds)
    end
    end_time = Time.now.to_i

    #Just leave some room for connection latency, etc.
    expect(end_time - start_time).to be < 10 
    expect(end_time - start_time).to be > 5
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
flok-0.0.102 spec/iface/driver/timer_spec.rb
flok-0.0.101 spec/iface/driver/timer_spec.rb
flok-0.0.100 spec/iface/driver/timer_spec.rb
flok-0.0.99 spec/iface/driver/timer_spec.rb
flok-0.0.98 spec/iface/driver/timer_spec.rb
flok-0.0.97 spec/iface/driver/timer_spec.rb
flok-0.0.96 spec/iface/driver/timer_spec.rb
flok-0.0.95 spec/iface/driver/timer_spec.rb
flok-0.0.94 spec/iface/driver/timer_spec.rb
flok-0.0.93 spec/iface/driver/timer_spec.rb
flok-0.0.92 spec/iface/driver/timer_spec.rb
flok-0.0.91 spec/iface/driver/timer_spec.rb
flok-0.0.90 spec/iface/driver/timer_spec.rb
flok-0.0.89 spec/iface/driver/timer_spec.rb
flok-0.0.88 spec/iface/driver/timer_spec.rb