spec/twitter/tweet_spec.rb in twitter-5.8.0 vs spec/twitter/tweet_spec.rb in twitter-5.9.0

- old
+ new

@@ -51,31 +51,30 @@ expect(tweet.created?).to be false end end describe '#entities?' do - it 'returns false if there are no entities set' do - tweet = Twitter::Tweet.new(:id => 28_669_546_014) - expect(tweet.entities?).to be false - end - - it 'returns false if there are blank lists of entities set' do - tweet = Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:urls => []}) - expect(tweet.entities?).to be false - end it 'returns true if there are entities set' do urls_array = [ { - :url => 'http://example.com/t.co', + :url => 'https://t.co/L2xIBazMPf', :expanded_url => 'http://example.com/expanded', - :display_url => 'example.com/expandedâ¦', + :display_url => 'example.com/expanded…', :indices => [10, 33], } ] tweet = Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:urls => urls_array}) expect(tweet.entities?).to be true end + it 'returns false if there are blank lists of entities set' do + tweet = Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:urls => []}) + expect(tweet.entities?).to be false + end + it 'returns false if there are no entities set' do + tweet = Twitter::Tweet.new(:id => 28_669_546_014) + expect(tweet.entities?).to be false + end end describe '#filter_level' do it 'returns the filter level when filter_level is set' do tweet = Twitter::Tweet.new(:id => 28_669_546_014, :filter_level => 'high') @@ -138,44 +137,36 @@ [{ :text => 'twitter', :indices => [10, 33], }] end - let(:subject) do Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:hashtags => hashtags_array}) end - it 'returns an array of Entity::Hashtag' do hashtags = subject.hashtags expect(hashtags).to be_an Array expect(hashtags.first).to be_a Twitter::Entity::Hashtag expect(hashtags.first.indices).to eq([10, 33]) expect(hashtags.first.text).to eq('twitter') end end - context 'when entities are set, but empty' do subject { Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:hashtags => []}) } - it 'is empty' do expect(subject.hashtags).to be_empty end - it 'does not warn' do subject.hashtags expect($stderr.string).to be_empty end end - context 'when entities are not set' do subject { Twitter::Tweet.new(:id => 28_669_546_014) } - it 'is empty' do expect(subject.hashtags).to be_empty end - it 'warns' do subject.hashtags expect($stderr.string).to match(/To get hashtags, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./) end end @@ -353,11 +344,11 @@ describe '#uris' do it 'returns an array of Entity::URIs when entities are set' do urls_array = [ { - :url => 'http://example.com/t.co', + :url => 'https://t.co/L2xIBazMPf', :expanded_url => 'http://example.com/expanded', :display_url => 'example.com/expanded…', :indices => [10, 33], } ] @@ -377,11 +368,11 @@ expect($stderr.string).to match(/To get urls, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./) end it 'can handle strange urls' do urls_array = [ { - :url => 'http://with_underscore.example.com/t.co', + :url => 'https://t.co/L2xIBazMPf', :expanded_url => 'http://with_underscore.example.com/expanded', :display_url => 'with_underscore.example.com/expanded…', :indices => [10, 33], } ] @@ -394,18 +385,18 @@ end describe '#uri' do it 'returns the URI to the tweet' do tweet = Twitter::Tweet.new(:id => 28_669_546_014, :user => {:id => 7_505_382, :screen_name => 'sferik'}) - expect(tweet.uri).to be_a Addressable::URI + expect(tweet.uri).to be_an Addressable::URI expect(tweet.uri.to_s).to eq('https://twitter.com/sferik/status/28669546014') end end describe '#uris?' do it 'returns true when the tweet includes urls entities' do entities = { - :urls => [{:url => 'http://with_underscore.example.com/t.co'}] + :urls => [{:url => 'https://t.co/L2xIBazMPf'}] } tweet = Twitter::Tweet.new(:id => 28_669_546_014, :entities => entities) expect(tweet.uris?).to be true end it 'returns false when no entities are present' do