Sha256: 49e3c46f8be9daff14b740448230af11065a2fedd252dfe6ce0c79fd07b084b0

Contents?: true

Size: 1.52 KB

Versions: 8

Compression:

Stored size: 1.52 KB

Contents

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) {
    "<html>
      <head>
        <meta property=\"og:title\" content=\"This is a title\">
        <meta property=\"og:description\" content=\"A description for your face\">
        <meta property=\"og:image\" content=\"http://imageurl.com\">
        <meta name=\"Description\" content=\" \tHere is a description not for facebook\t\">
        <meta name=\"KEYWORDS\"    content=\" \tKeywords, Keywords everywhere  \t\">
        <title>TITLE!</title>
      </head>
    </html>"
  }

  describe 'perform' do
    context 'there is no og_data' do
      let(:body) {
        "<html>
        <head>
          <meta name=\"Description\" content=\" \tHere is a description not for facebook\t\">
        <meta name=\"KEYWORDS\"    content=\" \tKeywords, Keywords everywhere  \t\">
        <title>TITLE!</title>
        </head>
      </html>"
      }

      it 'should fail quietly' do
        expect { link_data }.to_not raise_error
      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
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
link_oracle-0.0.8 spec/link_oracle/extractor/og_spec.rb
link_oracle-0.0.7 spec/link_oracle/extractor/og_spec.rb
link_oracle-0.0.6 spec/link_oracle/extractor/og_spec.rb
link_oracle-0.0.5 spec/link_oracle/extractor/og_spec.rb
link_oracle-0.0.4 spec/link_oracle/extractor/og_spec.rb
link_oracle-0.0.3 spec/link_oracle/extractor/og_spec.rb
link_oracle-0.0.2 spec/link_oracle/extractor/og_spec.rb
link_oracle-0.0.1 spec/link_oracle/extractor/og_spec.rb