require 'spec_helper' describe LinkOracle::Extractor::OG do let(:parsed_body) { ::Nokogiri::HTML.parse(body) } let(:link_data) { LinkOracle::Extractor::OG.new(parsed_body).perform } let(:body) { " TITLE! " } describe 'perform' do context 'there is no og_data' do let(:body) { " TITLE! " } it 'should fail quietly' do expect { link_data }.to_not raise_error end end context "the og data is blank" do let(:body) { " TITLE! " } it 'should set title to nil' do link_data.title.should == nil end it 'should set description to nil' do link_data.description.should == nil end it 'should set image to nil' do link_data.image_url.should == nil end end context 'there is og_data' do it 'should populate link_data title' do link_data.title.should == 'This is a title' end it 'should populate link_data image_url' do link_data.image_url.should == "http://imageurl.com" end it 'should populate link_data description' do link_data.description.should == 'A description for your face' end end context 'the og image content is a path' do let(:body) { " TITLE! " } it 'should set image to nil' do link_data.image_url.should == nil end end end end