Sha256: ea3854680d7e1d6b8e49b7175a18b93cd7a63ca8acdedb5e4362fadde02f9a39

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

describe Centrifuge::Client do
  let(:options) { { scheme: :https, host: 'centrifugo.herokuapp.com', port: 443, project_key: 'development', secret: 'secret' } }
  let(:client) { Centrifuge::Client.new(options) }
  let(:data) { { action: :test } }

  it 'generates url' do
    expect(client.url.to_s).to eq "https://centrifugo.herokuapp.com:443/api/#{client.project_key}"
  end

  it 'publishes data' do
    channel = SecureRandom.hex
    expect(client.publish(channel, data)).to eq [{"body" => nil, "error" => nil, "method" => "publish"}]
  end

  it 'unsubscribes user' do
    channel = SecureRandom.hex
    expect(client.unsubscribe(channel, "23")).to eq [{"body"=>nil, "error"=>nil, "method"=>"unsubscribe"}]
  end

  it 'disconnects user' do
    expect(client.disconnect("23")).to eq [{"body" => nil, "error" => nil, "method" => "disconnect"}]
  end

  it 'fetches presence info' do
    channel = SecureRandom.hex
    expect(client.presence(channel)).to eq [{"body" => {"channel" => channel, "data" => {}}, "error" => nil, "method" => "presence"}]
  end

  it 'fetches history' do
    channel = SecureRandom.hex
    expect(client.history(channel)).to eq [{"body" => {"channel" => channel, "data" => []}, "error" => nil, "method"=>"history"}]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
centrifuge-0.1.0 spec/client_spec.rb