Sha256: 847998776c541f5c32b958978c04708039bdc0eda7290fd8f911fe0d81deb745

Contents?: true

Size: 955 Bytes

Versions: 4

Compression:

Stored size: 955 Bytes

Contents

require 'spec_helper'

describe PulseMeter::CommandAggregator::UDP do
  let(:host){'127.0.0.1'}
  let(:port){33333}
  let(:udp_sock){mock(:socket)}
  before do 
    UDPSocket.stub!(:new).and_return(udp_sock)
    udp_sock.stub!(:fcntl).and_return(nil)
    @ca = described_class.new([[host, port]])
  end

  describe "#multi" do
    it "should accumulate redis commands and send them in a bulk" do
      data = [
        ["set", "xxxx", "zzzz"],
        ["set", "yyyy", "zzzz"]
      ].to_json
      udp_sock.should_receive(:send).with(data, 0, host, port).and_return(0)
      @ca.multi do
        @ca.set("xxxx", "zzzz")
        @ca.set("yyyy", "zzzz")
      end
    end
  end

  describe "any other redis instance method" do
    it "should send data imediately" do
      data = [
        ["set", "xxxx", "zzzz"]
      ].to_json
      udp_sock.should_receive(:send).with(data, 0, host, port).and_return(0)
      @ca.set("xxxx", "zzzz")
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pulse-meter-0.4.7 spec/pulse_meter/command_aggregator/udp_spec.rb
pulse-meter-0.4.6 spec/pulse_meter/command_aggregator/udp_spec.rb
pulse-meter-0.4.5 spec/pulse_meter/command_aggregator/udp_spec.rb
pulse-meter-0.4.4 spec/pulse_meter/command_aggregator/udp_spec.rb