require 'spec_helper'
describe LinkOracle::Extractor::Meta do
let(:parsed_body) { ::Nokogiri::HTML.parse(body) }
let(:link_data) { LinkOracle::Extractor::Meta.new(parsed_body).perform }
let(:body) {
"
TITLE!
"
}
describe 'perform' do
context 'there is no suitable meta data' do
let(:body) {
"
"
}
it 'should fail quietly' do
expect { link_data }.to_not raise_error
end
end
context "the meta data is there but blank" do
let(:body) {
"
"
}
it 'should set link_data title to nil' do
link_data.title.should == nil
end
it 'should set link_data image_url to nil' do
link_data.image_url.should == nil
end
it 'should set link_data description to nil' do
link_data.description.should == nil
end
end
context 'there is meta data' do
it 'should populate link_data title' do
link_data.title.should == 'TITLE!'
end
it 'should populate link_data image_url' do
link_data.image_url.should == "http://imageurlfrommeta.com"
end
it 'should populate link_data description' do
link_data.description.should == 'Here is a description not for facebook'
end
end
end
end