Sha256: 141632bdc9f7ff72dbeac8da87e6c9cc3dbbceb51ee861a61d06caa67ad78353

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

describe Pipio::StatusMessage, '#to_s' do
  it 'has the correct sender' do
    sender_screen_name = 'bob'
    result = create_status_message(sender_screen_name: sender_screen_name).to_s
    expect(result).to include %(sender="#{sender_screen_name}")
  end

  it 'has the correct time' do
    time = Time.now
    formatted_time = time.xmlschema
    result = create_status_message(time: time).to_s
    expect(result).to include %(time="#{formatted_time}")
  end

  it 'has the correct alias' do
    sender_alias = 'jane_alias'
    result = create_status_message(sender_alias: sender_alias).to_s
    expect(result).to include %(alias="#{sender_alias}")
  end

  it 'has the correct status' do
    status = 'status'
    result = create_status_message(status: status).to_s
    expect(result).to include %(type="#{status}")
  end

  it 'is a status tag' do
    expect(create_status_message.to_s).to match(/^<status/)
  end

  it 'ends in a newline' do
    expect(create_status_message.to_s).to match(/\n$/)
  end

  def create_status_message(opts = {})
    opts[:sender_screen_name] ||= 'jim_sender'
    opts[:time] ||= Time.now
    opts[:sender_alias] ||= 'jane_alias'
    opts[:status] ||= 'status'

    Pipio::StatusMessage.new(opts[:sender_screen_name], opts[:time], opts[:sender_alias], opts[:status])
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pipio-0.0.1 spec/pipio/messages/status_message_spec.rb