cyx-scraper 0.3.0 → 0.3.1

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.
data/test/scraper_test.rb CHANGED
@@ -24,6 +24,17 @@ class ScraperTest < Test::Unit::TestCase
24
24
  end
25
25
  end
26
26
 
27
+ context "Scraper( <vimeo url> )" do
28
+ setup do
29
+ @url = "http://vimeo.com/5826468"
30
+ @scraper = Scraper(:url => @url)
31
+ end
32
+
33
+ should "return a Scraper::Vimeo object" do
34
+ assert_instance_of Scraper::Vimeo, @scraper
35
+ end
36
+ end
37
+
27
38
  context "given an article from A-List-Apart" do
28
39
  setup do
29
40
  @article = fixture_file('unwebbable.html')
@@ -76,4 +87,16 @@ class ScraperTest < Test::Unit::TestCase
76
87
  end
77
88
  end
78
89
 
90
+ context "given the non-article content" do
91
+ setup do
92
+ @content = fixture_file('non-article.html')
93
+ end
94
+
95
+ should "raise an ArgumentError (can't handle content from args)" do
96
+ assert_raise ArgumentError do
97
+ Scraper(:content => @content)
98
+ end
99
+ end
100
+ end
101
+
79
102
  end
data/test/vimeo_test.rb CHANGED
@@ -8,6 +8,25 @@ class Scraper::VimeoTest < Test::Unit::TestCase
8
8
  )
9
9
  end
10
10
 
11
+ context "given a url not from vimeo.com" do
12
+ should "raise an ArgumentError" do
13
+ assert_raise ArgumentError do
14
+ Scraper::Vimeo.new(:url => 'http://wikipedia.org/bla.html')
15
+ end
16
+ end
17
+ end
18
+
19
+ context "a vimeo url without an id in it" do
20
+ setup do
21
+ @url = "http://vimeo.com/user1269265/videos"
22
+ end
23
+
24
+ should "raise an ArgumentError" do
25
+ assert_raise ArgumentError do
26
+ Scraper::Vimeo.new(:url => @url)
27
+ end
28
+ end
29
+ end
11
30
 
12
31
  context "given the canonical URL http://vimeo.com/5826468" do
13
32
  setup do
data/test/web_test.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'test_helper'
2
+
3
+ class Scraper::WebTest < Test::Unit::TestCase
4
+ context "Web.open" do
5
+ should "just delegate to Kernel.open" do
6
+ Kernel.expects(:open).with(:timbuktu)
7
+
8
+ Scraper::Modules::Web.open(:timbuktu)
9
+ end
10
+ end
11
+
12
+ end
data/test/youtube_test.rb CHANGED
@@ -35,6 +35,10 @@ class Scraper::YoutubeTest < Test::Unit::TestCase
35
35
 
36
36
  assert_equal @desc, @youtube.description
37
37
  end
38
+
39
+ should "have a thumbnail with it's video id in it" do
40
+ assert_match(/dLO2s7SDHJo/, @youtube.thumbnail)
41
+ end
38
42
  end
39
43
 
40
44
  context "given http://www.youtube.com/watch?feature=rec-HM-r2&v=dLO2s7SDHJo" do
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.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril David
@@ -40,11 +40,13 @@ files:
40
40
  - test/article_test.rb
41
41
  - test/fixtures/5826468.html
42
42
  - test/fixtures/dLO2s7SDHJo.html
43
+ - test/fixtures/non-article.html
43
44
  - test/fixtures/scraped.html
44
45
  - test/fixtures/unwebbable.html
45
46
  - test/scraper_test.rb
46
47
  - test/test_helper.rb
47
48
  - test/vimeo_test.rb
49
+ - test/web_test.rb
48
50
  - test/youtube_test.rb
49
51
  has_rdoc: false
50
52
  homepage: http://github.com/cyx/scraper
@@ -78,4 +80,5 @@ test_files:
78
80
  - test/scraper_test.rb
79
81
  - test/test_helper.rb
80
82
  - test/vimeo_test.rb
83
+ - test/web_test.rb
81
84
  - test/youtube_test.rb