cyx-scraper 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,55 @@
1
+ require 'test_helper'
2
+
3
+ class Scraper::FlickrTest < Test::Unit::TestCase
4
+ context "given a photostream url" do
5
+ setup do
6
+ @url = "http://www.flickr.com/photos/80186783@N00/"
7
+ @flickr = Scraper::Flickr.new(:url => @url)
8
+ Scraper::Modules::Web.stubs(:open).returns(
9
+ File.open(@@fixture_path + '/photostream.html', 'r')
10
+ )
11
+ end
12
+
13
+ should "return the photo stream's title" do
14
+ assert_equal "David Lazar's photostream", @flickr.title
15
+ end
16
+
17
+ should "say that it's a photostream" do
18
+ assert @flickr.photostream?
19
+ end
20
+
21
+ should "return the first photo as the thumbnail" do
22
+ @t = 'http://farm1.static.flickr.com/38/124484929_ed8c345cb9_m.jpg'
23
+ assert_equal @t, @flickr.thumbnail
24
+ end
25
+
26
+ should "have no description" do
27
+ assert_equal '', @flickr.description
28
+ end
29
+ end
30
+
31
+ context "given a photo url" do
32
+ setup do
33
+ @url = "http://www.flickr.com/photos/80186783@N00/124484929/"
34
+ Scraper::Modules::Web.stubs(:open).returns(
35
+ File.open(@@fixture_path + '/show_photo.html', 'r')
36
+ )
37
+ @flickr = Scraper::Flickr.new(:url => @url)
38
+ end
39
+
40
+ should "return the photo's title" do
41
+ assert_equal 'Debian Box', @flickr.title
42
+ end
43
+
44
+ should "return the photo's description" do
45
+ assert_equal 'An empty desktop.', @flickr.description
46
+ end
47
+
48
+ should "return the photo's thumbnail" do
49
+ @t = "http://farm1.static.flickr.com/38/124484929_ed8c345cb9_m.jpg"
50
+ assert_equal @t, @flickr.thumbnail
51
+ end
52
+ end
53
+
54
+ #
55
+ end
data/test/scraper_test.rb CHANGED
@@ -35,6 +35,29 @@ class ScraperTest < Test::Unit::TestCase
35
35
  end
36
36
  end
37
37
 
38
+ context "Scraper( <flickr url> )" do
39
+ setup do
40
+ @url = "http://www.flickr.com/photos/80186783@N00/124484929/"
41
+ @scraper = Scraper(:url => @url)
42
+ end
43
+
44
+ should "return a Scraper::Flickr object" do
45
+ assert_instance_of Scraper::Flickr, @scraper
46
+ end
47
+
48
+ context "when the url doesn't have the photo part at the end" do
49
+ setup do
50
+ @url = "http://www.flickr.com/photos/80186783@N00"
51
+ @scraper = Scraper(:url => @url)
52
+ end
53
+
54
+ should "return a Scraper::Flickr object still" do
55
+ assert_instance_of Scraper::Flickr, @scraper
56
+ end
57
+ end
58
+ end
59
+
60
+
38
61
  context "given an article from A-List-Apart" do
39
62
  setup do
40
63
  @article = fixture_file('unwebbable.html')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cyx-scraper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril David
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-31 00:00:00 -07:00
12
+ date: 2009-08-01 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -31,6 +31,7 @@ files:
31
31
  - VERSION
32
32
  - lib/scraper.rb
33
33
  - lib/scraper/article.rb
34
+ - lib/scraper/flickr.rb
34
35
  - lib/scraper/modules.rb
35
36
  - lib/scraper/modules/video.rb
36
37
  - lib/scraper/modules/web.rb
@@ -41,8 +42,11 @@ files:
41
42
  - test/fixtures/5826468.html
42
43
  - test/fixtures/dLO2s7SDHJo.html
43
44
  - test/fixtures/non-article.html
45
+ - test/fixtures/photostream.html
44
46
  - test/fixtures/scraped.html
47
+ - test/fixtures/show_photo.html
45
48
  - test/fixtures/unwebbable.html
49
+ - test/flickr_test.rb
46
50
  - test/scraper_test.rb
47
51
  - test/test_helper.rb
48
52
  - test/vimeo_test.rb
@@ -77,6 +81,7 @@ specification_version: 3
77
81
  summary: TODO
78
82
  test_files:
79
83
  - test/article_test.rb
84
+ - test/flickr_test.rb
80
85
  - test/scraper_test.rb
81
86
  - test/test_helper.rb
82
87
  - test/vimeo_test.rb