Sha256: 3fd800c84798a128a754be2619a7a31e42371c52405cd160f256c929dae49464

Contents?: true

Size: 1.07 KB

Versions: 7

Compression:

Stored size: 1.07 KB

Contents

require "spec_helper"
require "microformats2"

describe Microformats2::Parser do
  let(:parser) { Microformats2::Parser.new }

  describe "#http_headers" do
    it "starts as a blank hash" do
      parser.http_headers.should eq({})
    end

    describe "open file" do
      before do
        parser.parse("spec/support/lib/microformats2/simple.html")
      end

      it "doesn't save #http_headers" do
        parser.http_headers.should eq({})
      end
      it "saves #http_body" do
        parser.http_body.should include "<!DOCTYPE html>"
      end
    end

    describe "http response" do
      before do
        stub_request(:get, "http://www.example.com/").
           with(:headers => {"Accept"=>"*/*", "User-Agent"=>"Ruby"}).
           to_return(:status => 200, :body => "abc", :headers => {"Content-Length" => 3})
        parser.parse("http://www.example.com")
      end

      it "saves #http_headers" do
        parser.http_headers.should eq({"content-length" => "3"})
      end
      it "saves #http_body" do
        parser.http_body.should eq("abc")
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
microformats2-2.9.0 spec/lib/microformats2/parser_spec.rb
microformats2-2.1.0 spec/lib/microformats2/parser_spec.rb
microformats2-2.0.3 spec/lib/microformats2/parser_spec.rb
microformats2-2.0.2 spec/lib/microformats2/parser_spec.rb
microformats2-2.0.1 spec/lib/microformats2/parser_spec.rb
microformats2-2.0.0 spec/lib/microformats2/parser_spec.rb
microformats2-2.0.0.pre5 spec/lib/microformats2/parser_spec.rb