Sha256: 0b893299e5d653418b9c53906d5dc328d0fd7d7909ea4c75d8b58821aaf9453e

Contents?: true

Size: 1.94 KB

Versions: 2

Compression:

Stored size: 1.94 KB

Contents

require 'helper'

describe Twitter::DirectMessage do

  describe "#==" do
    it "returns true when objects IDs are the same" do
      direct_message = Twitter::DirectMessage.new(:id => 1, :text => "foo")
      other = Twitter::DirectMessage.new(:id => 1, :text => "bar")
      (direct_message == other).should be_true
    end
    it "returns false when objects IDs are different" do
      direct_message = Twitter::DirectMessage.new(:id => 1)
      other = Twitter::DirectMessage.new(:id => 2)
      (direct_message == other).should be_false
    end
    it "returns false when classes are different" do
      direct_message = Twitter::DirectMessage.new(:id => 1)
      other = Twitter::Identity.new(:id => 1)
      (direct_message == other).should be_false
    end
  end

  describe "#created_at" do
    it "returns a Time when created_at is set" do
      direct_message = Twitter::DirectMessage.new(:id => 1825786345, :created_at => "Mon Jul 16 12:59:01 +0000 2007")
      direct_message.created_at.should be_a Time
    end
    it "returns nil when created_at is not set" do
      direct_message = Twitter::DirectMessage.new(:id => 1825786345)
      direct_message.created_at.should be_nil
    end
  end

  describe "#recipient" do
    it "returns a User when recipient is set" do
      recipient = Twitter::DirectMessage.new(:id => 1825786345, :recipient => {:id => 7505382}).recipient
      recipient.should be_a Twitter::User
    end
    it "returns nil when recipient is not set" do
      recipient = Twitter::DirectMessage.new(:id => 1825786345).recipient
      recipient.should be_nil
    end
  end

  describe "#sender" do
    it "returns a User when sender is set" do
      sender = Twitter::DirectMessage.new(:id => 1825786345, :sender => {:id => 7505382}).sender
      sender.should be_a Twitter::User
    end
    it "returns nil when sender is not set" do
      sender = Twitter::DirectMessage.new(:id => 1825786345).sender
      sender.should be_nil
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
twitter-4.1.0 spec/twitter/direct_message_spec.rb
twitter-4.0.0 spec/twitter/direct_message_spec.rb