Sha256: 861647c76b38a025700703c05e1526a26ca3ed2f12c1d3af3672e8a6376746d1

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

describe 'Handling notifications' do
  before(:all) do
    @project = @sync_client.projects.last || @sync_client.projects.create(name: 'Test project')
    @collection = @project.collections.last || @project.collections.create(name: 'Test collection')
    @object = @collection.data_objects.last || @collection.data_objects.create(title: 'Test object')
    @object.update(title: 'Test object')
    sleep 3

    @sync_client.append_callback(:test) do |notification|
      p "Notification received: #{notification.inspect}" if ENV['VERBOSE']
    end
  end

  it 'should subscribe to project' do
    @project.subscribe
    p 'Notification should be seen' if ENV['VERBOSE']
    @object.update(title: 'Test object 2')
    sleep 3
  end

  it 'should unsubscribe from project' do
    @project.unsubscribe
    p 'Notification should not be seen' if ENV['VERBOSE']
    @object.update(title: 'Test object 3')
    sleep 3
  end

  it 'should subscribe to collection' do
    @collection.subscribe
    p 'Notification should be seen' if ENV['VERBOSE']
    @object.update(title: 'Test object 4')
    sleep 3
  end

  it 'should unsubscribe from collection' do
    @collection.unsubscribe
    p 'Notification should not be seen' if ENV['VERBOSE']
    @object.update(title: 'Test object 5')
    sleep 3
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
syncano-3.1.4 spec/notifications_spec.rb
syncano-3.1.3 spec/notifications_spec.rb