Sha256: b826d78ae6c221f5cdade3e82ba27ed737e57ea1e9fcb8c0b0857e75da34f007

Contents?: true

Size: 1.95 KB

Versions: 5

Compression:

Stored size: 1.95 KB

Contents

require 'spec_helper'

describe Weeter::TweetItem do

  describe "deletion?" do
    it "should be true if it is a deletion request" do
      item = Weeter::TweetItem.new({"delete"=>{"status"=>{"id"=>234, "user_id"=>34555}}})
      item.should be_deletion
    end

    it "should be false if it is not a deletion request" do
      item = Weeter::TweetItem.new({'text' => "Hey", 'id_str' => "123", 'user' => {'id_str' => "1"}})
      item.should_not be_deletion
    end
  end

  describe "publishable" do

    before do
      @tweet_json = {'text' => "Hey", 'id_str' => "123", 'user' => {'id_str' => '1'}}
    end

    it "should be publishable if not a reply or a retweet" do
      item = Weeter::TweetItem.new(@tweet_json)
      item.should be_publishable
    end

    it "should not be publishable if implicitly retweeted" do
      item = Weeter::TweetItem.new(@tweet_json.merge({'text' => 'RT @joe Hey'}))
      item.should_not be_publishable
    end

    it "should not be publishable if explicitly retweeted" do
      item = Weeter::TweetItem.new(@tweet_json.merge('retweeted_status' => {'id_str' => '111', 'text' => 'Hey', 'user' => {'id_str' => "1"}}))
      item.should_not be_publishable
    end

    it "should not be publishable if implicit reply" do
      item = Weeter::TweetItem.new(@tweet_json.merge('text' => '@joe Hey'))
      item.should_not be_publishable
    end

    it "should not be publishable if explicit reply" do
      item = Weeter::TweetItem.new(@tweet_json.merge('text' => '@joe Hey', 'in_reply_to_user_id_str' => '1'))
      item.should_not be_publishable
    end

  end

  describe "json attributes" do

    it "should delegate hash calls to its json" do
      item = Weeter::TweetItem.new({'text' => "Hey"})
      item['text'].should == "Hey"
    end

    it "should retrieve nested attributes" do
      item = Weeter::TweetItem.new({'text' => "Hey", 'id_str' => "123", 'user' => {'id_str' => '1'}})
      item['user']['id_str'].should == "1"
    end

  end



end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
weeter-0.11.0 spec/weeter/twitter/tweet_item_spec.rb
weeter-0.10.0 spec/weeter/twitter/tweet_item_spec.rb
weeter-0.9.2 spec/weeter/twitter/tweet_item_spec.rb
weeter-0.9.1 spec/weeter/twitter/tweet_item_spec.rb
weeter-0.9.0 spec/weeter/twitter/tweet_item_spec.rb