Sha256: cabd52d4d387ef9555b16c9beb0c8872aefd7a06a974b1bffbab36c0317cec9b

Contents?: true

Size: 1.24 KB

Versions: 68

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 "net"
  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

68 entries across 68 versions & 1 rubygems

Version Path
flok-0.0.87 spec/iface/driver/timer_spec.rb
flok-0.0.86 spec/iface/driver/timer_spec.rb
flok-0.0.85 spec/iface/driver/timer_spec.rb
flok-0.0.84 spec/iface/driver/timer_spec.rb
flok-0.0.83 spec/iface/driver/timer_spec.rb
flok-0.0.82 spec/iface/driver/timer_spec.rb
flok-0.0.81 spec/iface/driver/timer_spec.rb
flok-0.0.80 spec/iface/driver/timer_spec.rb
flok-0.0.79 spec/iface/driver/timer_spec.rb
flok-0.0.78 spec/iface/driver/timer_spec.rb
flok-0.0.77 spec/iface/driver/timer_spec.rb
flok-0.0.76 spec/iface/driver/timer_spec.rb
flok-0.0.75 spec/iface/driver/timer_spec.rb
flok-0.0.74 spec/iface/driver/timer_spec.rb
flok-0.0.73 spec/iface/driver/timer_spec.rb
flok-0.0.72 spec/iface/driver/timer_spec.rb
flok-0.0.71 spec/iface/driver/timer_spec.rb
flok-0.0.70 spec/iface/driver/timer_spec.rb
flok-0.0.69 spec/iface/driver/timer_spec.rb
flok-0.0.68 spec/iface/driver/timer_spec.rb