Sha256: dabea54f522925a492ff46b90c276579facbd2f12de8312f734379f50e3e19cf

Contents?: true

Size: 812 Bytes

Versions: 15

Compression:

Stored size: 812 Bytes

Contents

require 'spec_helper'

describe Notu::HtmlDocument, :vcr do

  describe '.get' do

    it 'returns document parsed' do
      document = Notu::HtmlDocument.get('http://alweb.org')
      expect((document/'title').text).to eq('Alexis Toulotte')
    end

    it 'follows redirects' do
      document = Notu::HtmlDocument.get('http://www.alweb.org')
      expect((document/'title').text).to eq('Alexis Toulotte')
    end

    it 'raise a NetworkError on 404' do
      expect {
        Notu::HtmlDocument.get('http://alweb.org/foo')
      }.to raise_error(Notu::NetworkError, '404 "Not Found"')
    end

    it 'raise a ParseError if not a valid document' do
      expect {
        Notu::HtmlDocument.get('http://alweb.org/avatar')
      }.to raise_error(Notu::ParseError, 'Invalid HTML document')
    end

  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
notu-1.0.2 spec/notu/html_document_spec.rb
notu-1.0.1 spec/notu/html_document_spec.rb
notu-1.0.0 spec/notu/html_document_spec.rb
notu-0.3.1 spec/notu/html_document_spec.rb
notu-0.3.0 spec/notu/html_document_spec.rb
notu-0.2.2 spec/notu/html_document_spec.rb
notu-0.2.1 spec/notu/html_document_spec.rb
notu-0.2.0 spec/notu/html_document_spec.rb
notu-0.1.6 spec/notu/html_document_spec.rb
notu-0.1.5 spec/notu/html_document_spec.rb
notu-0.1.4 spec/notu/html_document_spec.rb
notu-0.1.3 spec/notu/html_document_spec.rb
notu-0.1.2 spec/notu/html_document_spec.rb
notu-0.1.1 spec/notu/html_document_spec.rb
notu-0.1.0 spec/notu/html_document_spec.rb