tomtaylor-geo-spider 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/geo-spider.rb CHANGED
@@ -5,6 +5,7 @@ require 'rubygems'
5
5
  require 'hpricot'
6
6
  require 'open-uri'
7
7
 
8
+ require 'geo-spider/exceptions'
8
9
  require 'geo-spider/page'
9
10
  require 'geo-spider/site'
10
11
 
@@ -5,6 +5,7 @@ module GeoSpider
5
5
  class Base
6
6
 
7
7
  def initialize(element)
8
+ raise InvalidElement if element.class != Hpricot::Elem || element.nil?
8
9
  @element = element
9
10
  end
10
11
 
@@ -28,7 +28,7 @@ module GeoSpider
28
28
  seen << url
29
29
  next_links = (page.internal_links - seen - queue) # only add internal links that we've not seen or already have queued.
30
30
  queue.concat(next_links)
31
- rescue Timeout::Error, OpenURI::HTTPError
31
+ rescue Timeout::Error, OpenURI::HTTPError, InvalidElement
32
32
  next
33
33
  end
34
34
  end
@@ -2,7 +2,7 @@ module GeoSpider
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -135,4 +135,17 @@ describe Page, "which is parsing a page with a string in a URL that happens to m
135
135
  @page.locations.should be_empty
136
136
  end
137
137
 
138
+ end
139
+
140
+ describe Page, "which is a parsing a page which doesn't contain the specific content_css_selector" do
141
+
142
+ before(:each) do
143
+ OpenURI.should_receive(:open_uri).and_return(page_as_string('page_with_links.html'))
144
+ @page = Page.new("http://www.example.com", :content_css_selector => "notreal")
145
+ end
146
+
147
+ it "should raise InvalidElement" do
148
+ lambda { @page.locations }.should raise_error(InvalidElement)
149
+ end
150
+
138
151
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tomtaylor-geo-spider
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Taylor