Sha256: db48e301d96e2809108fa6a5797fb6bb22c044426b94b3a70f50d3fe60606c93

Contents?: true

Size: 977 Bytes

Versions: 3

Compression:

Stored size: 977 Bytes

Contents

require 'spec_helper'
require 'json'
require 'livefyre/dto/topic'
require 'livefyre'

include Livefyre

describe Livefyre::Topic do
  it 'should correctly form a hash' do
    topic = Topic.new('a', 'b')
    h = topic.to_hash
    expect(h[:id]).to eq('a')
    expect(h[:label]).to eq('b')
    expect(h.has_key?(:createdAt)).to be false
    expect(h.has_key?(:modifiedAt)).to be false

    topic.created_at=0
    topic.modified_at=1
    h = topic.to_hash
    expect(h[:createdAt]).to eq(0)
    expect(h[:modifiedAt]).to eq(1)
  end

  it 'should produce the expected json and serialize from it' do
    topic = Topic.new('a', 'b', 0, 1)
    json = topic.to_json
    topic2 = JSON.parse(json)
    expect(topic.to_hash).to eq(Topic::serialize_from_json(topic2).to_hash)
  end

  it 'should retrieve the correct truncated id from a Topic' do
    topic = Topic.create(Livefyre.get_network(NETWORK_NAME, NETWORK_KEY), 'ID', 'LABEL')
    expect(topic.truncated_id).to eq('ID')
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
livefyre-2.0.2 spec/livefyre/dto/topic_spec.rb
livefyre-2.0.1 spec/livefyre/dto/topic_spec.rb
livefyre-2.0.0 spec/livefyre/dto/topic_spec.rb