Skip to content

Commit

Permalink
Make Twitter::User#profile_background_image_uri methods return a URI
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Jun 24, 2014
1 parent 31c306b commit d96194c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/twitter/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class User < Twitter::BasicUser
:profile_use_background_image, :suspended, :verified
define_predicate_method :translator, :is_translator
define_predicate_method :translation_enabled, :is_translation_enabled
uri_attr_reader :profile_background_image_uri, :profile_background_image_uri_https

class << self
private
Expand Down
24 changes: 24 additions & 0 deletions spec/twitter/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,30 @@
end
end

describe '#profile_background_image_uri' do
it 'returns the URI to the user' do
user = Twitter::User.new(:id => 7_505_382, :profile_background_image_url => 'http://pbs.twimg.com/profile_background_images/677717672/bb0b3653dcf0644e344823e0a2eb3382.png')
expect(user.profile_background_image_uri).to be_an Addressable::URI
expect(user.profile_background_image_uri.to_s).to eq('http://pbs.twimg.com/profile_background_images/677717672/bb0b3653dcf0644e344823e0a2eb3382.png')
end
it 'returns nil when the screen name is not set' do
user = Twitter::User.new(:id => 7_505_382)
expect(user.profile_background_image_uri).to be_nil
end
end

describe '#profile_background_image_uri_https' do
it 'returns the URI to the user' do
user = Twitter::User.new(:id => 7_505_382, :profile_background_image_url_https => 'https://pbs.twimg.com/profile_background_images/677717672/bb0b3653dcf0644e344823e0a2eb3382.png')
expect(user.profile_background_image_uri_https).to be_an Addressable::URI
expect(user.profile_background_image_uri_https.to_s).to eq('https://pbs.twimg.com/profile_background_images/677717672/bb0b3653dcf0644e344823e0a2eb3382.png')
end
it 'returns nil when the screen name is not set' do
user = Twitter::User.new(:id => 7_505_382)
expect(user.profile_background_image_uri_https).to be_nil
end
end

describe '#profile_banner_uri' do
it 'accepts utf8 urls' do
user = Twitter::User.new(:id => 7_505_382, :profile_banner_url => 'https://si0.twimg.com/profile_banners/7_505_382/1348266581©_normal.png')
Expand Down

0 comments on commit d96194c

Please sign in to comment.