1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
|
require 'helper'
describe Twitter::OEmbed do
describe '#author_uri' do
it 'returns a URI when the author_url is set' do
oembed = Twitter::OEmbed.new(author_url: 'https://twitter.com/sferik')
expect(oembed.author_uri).to be_an Addressable::URI
expect(oembed.author_uri.to_s).to eq('https://twitter.com/sferik')
end
it 'returns nil when the author_uri is not set' do
oembed = Twitter::OEmbed.new
expect(oembed.author_uri).to be_nil
end
end
describe '#author_uri?' do
it 'returns true when the author_url is set' do
oembed = Twitter::OEmbed.new(author_url: 'https://twitter.com/sferik')
expect(oembed.author_uri?).to be true
end
it 'returns false when the author_uri is not set' do
oembed = Twitter::OEmbed.new
expect(oembed.author_uri?).to be false
end
end
describe '#author_name' do
it 'returns the author name' do
oembed = Twitter::OEmbed.new(author_name: 'Erik Berlin')
expect(oembed.author_name).to eq('Erik Berlin')
end
it 'returns nil when not set' do
author_name = Twitter::OEmbed.new.author_name
expect(author_name).to be_nil
end
end
describe '#cache_age' do
it 'returns the cache_age' do
oembed = Twitter::OEmbed.new(cache_age: '31536000000')
expect(oembed.cache_age).to eq('31536000000')
end
it 'returns nil when not set' do
cache_age = Twitter::OEmbed.new.cache_age
expect(cache_age).to be_nil
end
end
describe '#height' do
it 'returns the height' do
oembed = Twitter::OEmbed.new(height: 200)
expect(oembed.height).to eq(200)
end
it 'returns it as an Integer' do
oembed = Twitter::OEmbed.new(height: 200)
expect(oembed.height).to be_an Integer
end
it 'returns nil when not set' do
height = Twitter::OEmbed.new.height
expect(height).to be_nil
end
end
describe '#html' do
it 'returns the html' do
oembed = Twitter::OEmbed.new(html: '<blockquote>all my <b>witty tweet</b> stuff here</blockquote>')
expect(oembed.html).to eq('<blockquote>all my <b>witty tweet</b> stuff here</blockquote>')
end
it 'returns nil when not set' do
html = Twitter::OEmbed.new.html
expect(html).to be_nil
end
end
describe '#provider_name' do
it 'returns the provider_name' do
oembed = Twitter::OEmbed.new(provider_name: 'Twitter')
expect(oembed.provider_name).to eq('Twitter')
end
it 'returns nil when not set' do
provider_name = Twitter::OEmbed.new.provider_name
expect(provider_name).to be_nil
end
end
describe '#provider_uri' do
it 'returns a URI when the provider_url is set' do
oembed = Twitter::OEmbed.new(provider_url: 'http://twitter.com')
expect(oembed.provider_uri).to be_an Addressable::URI
expect(oembed.provider_uri.to_s).to eq('http://twitter.com')
end
it 'returns nil when the provider_uri is not set' do
oembed = Twitter::OEmbed.new
expect(oembed.provider_uri).to be_nil
end
end
describe '#provider_uri?' do
it 'returns true when the provider_url is set' do
oembed = Twitter::OEmbed.new(provider_url: 'https://twitter.com/sferik')
expect(oembed.provider_uri?).to be true
end
it 'returns false when the provider_uri is not set' do
oembed = Twitter::OEmbed.new
expect(oembed.provider_uri?).to be false
end
end
describe '#type' do
it 'returns the type' do
oembed = Twitter::OEmbed.new(type: 'rich')
expect(oembed.type).to eq('rich')
end
it 'returns nil when not set' do
type = Twitter::OEmbed.new.type
expect(type).to be_nil
end
end
describe '#width' do
it 'returns the width' do
oembed = Twitter::OEmbed.new(width: 550)
expect(oembed.width).to eq(550)
end
it 'returns it as an Integer' do
oembed = Twitter::OEmbed.new(width: 550)
expect(oembed.width).to be_an Integer
end
it 'returns nil when not set' do
width = Twitter::OEmbed.new.width
expect(width).to be_nil
end
end
describe '#uri' do
it 'returns a URI when the url is set' do
oembed = Twitter::OEmbed.new(url: 'https://twitter.com/twitterapi/status/133640144317198338')
expect(oembed.uri).to be_an Addressable::URI
expect(oembed.uri.to_s).to eq('https://twitter.com/twitterapi/status/133640144317198338')
end
it 'returns nil when the url is not set' do
oembed = Twitter::OEmbed.new
expect(oembed.uri).to be_nil
end
end
describe '#uri?' do
it 'returns true when the url is set' do
oembed = Twitter::OEmbed.new(url: 'https://twitter.com/twitterapi/status/133640144317198338')
expect(oembed.uri?).to be true
end
it 'returns false when the url is not set' do
oembed = Twitter::OEmbed.new
expect(oembed.uri?).to be false
end
end
describe '#version' do
it 'returns the version' do
oembed = Twitter::OEmbed.new(version: '1.0')
expect(oembed.version).to eq('1.0')
end
it 'returns nil when not set' do
version = Twitter::OEmbed.new.version
expect(version).to be_nil
end
end
end
|