Sha256: 9239e599b0a4a3c801b1f3d7cd310c2ff2e8b36fb8720e26a41a4e2c85af6108

Contents?: true

Size: 1020 Bytes

Versions: 3

Compression:

Stored size: 1020 Bytes

Contents

require "spec_helper"
require "microformats2"

describe Microformats2 do
  before do
    @html = <<-HTML.strip
      <div class="h-card"><p class="p-name">Jessica Lynn Suttles</p></div>
    HTML
  end

  describe "::parse" do
    it "returns ParserResult" do
      expect(Microformats2.parse(@html)).to be_kind_of Microformats2::Collection
    end
  end

  describe "::read_html" do
    it "can be a string of html" do
      expect(Microformats2.read_html(@html)).to include @html
    end
    it "can be a file path to html" do
      html = "spec/support/lib/microformats2/simple.html"
      expect(Microformats2.read_html(html)).to include "<div class=\"h-card\">"
    end
    it "can be a url to html" do
      stub_request(:get, "http://google.com/").
               with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
               to_return(:status => 200, :body => "google", :headers => {})
      html = "http://google.com"
      expect(Microformats2.read_html(html)).to include "google"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
microformats2-3.1.0 spec/lib/microformats2_spec.rb
microformats2-3.0.1 spec/lib/microformats2_spec.rb
microformats2-3.0.0 spec/lib/microformats2_spec.rb