ging-opengraph 0.0.4

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,69 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe OpenGraph do
4
+ let(:rotten){ File.open(File.dirname(__FILE__) + '/examples/rottentomatoes.html').read }
5
+ let(:partial){ File.open(File.dirname(__FILE__) + '/examples/partial.html').read }
6
+
7
+ describe '.parse' do
8
+ it 'should return false if there isnt valid Open Graph info' do
9
+ OpenGraph.parse("").should be_false
10
+ OpenGraph.parse(partial).should be_false
11
+ end
12
+
13
+ it 'should otherwise return an OpenGraph::Object' do
14
+ OpenGraph.parse(rotten).should be_kind_of(OpenGraph::Object)
15
+ end
16
+
17
+ context ' without strict mode' do
18
+ subject{ OpenGraph.parse(partial, false) }
19
+
20
+ it { should_not be_false }
21
+ it { subject.title.should == 'Partialized' }
22
+ end
23
+ end
24
+
25
+ describe '.fetch' do
26
+ it 'should fetch from the specified URL' do
27
+ stub_request(:get, 'http://www.rottentomatoes.com/m/1217700-kick_ass/').to_return(:body => rotten)
28
+ OpenGraph.fetch('http://www.rottentomatoes.com/m/1217700-kick_ass/').title.should == 'Kick-Ass'
29
+ WebMock.should have_requested(:get, 'http://www.rottentomatoes.com/m/1217700-kick_ass/')
30
+ end
31
+
32
+ it 'should catch errors' do
33
+ stub_request(:get, 'http://example.com').to_return(:status => 404)
34
+ OpenGraph.fetch('http://example.com').should be_false
35
+ RestClient.should_receive(:get).with('http://example.com').and_raise(SocketError)
36
+ OpenGraph.fetch('http://example.com').should be_false
37
+ end
38
+ end
39
+ end
40
+
41
+ describe OpenGraph::Object do
42
+ let(:rotten){ File.open(File.dirname(__FILE__) + '/examples/rottentomatoes.html')}
43
+
44
+ context ' a Rotten Tomatoes Movie' do
45
+ subject{ OpenGraph.parse(rotten) }
46
+
47
+ it 'should have the title' do
48
+ subject.title.should == "Kick-Ass"
49
+ end
50
+
51
+ it 'should be a product' do
52
+ subject.schema.should == 'product'
53
+ subject.should be_product
54
+ subject.should_not be_person
55
+ end
56
+
57
+ it 'should be a movie' do
58
+ subject.type.should == 'movie'
59
+ subject.should be_movie
60
+ subject.should_not be_tv_show
61
+ end
62
+
63
+ it 'should be valid' do
64
+ subject.should be_valid
65
+ subject['type'] = nil
66
+ subject.should_not be_valid
67
+ end
68
+ end
69
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,14 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
4
+ require 'rubygems'
5
+ require 'opengraph'
6
+ require 'rspec'
7
+ require 'rspec/autorun'
8
+ require 'webmock/rspec'
9
+
10
+ include WebMock::API
11
+
12
+ RSpec.configure do |config|
13
+
14
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ging-opengraph
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Michael Bleigh
9
+ - Matt Wilson
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-04-23 00:00:00.000000000Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hashie
17
+ requirement: &83949190 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *83949190
26
+ - !ruby/object:Gem::Dependency
27
+ name: nokogiri
28
+ requirement: &83948930 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.5.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *83948930
37
+ - !ruby/object:Gem::Dependency
38
+ name: rest-client
39
+ requirement: &83948630 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: 1.6.0
45
+ type: :runtime
46
+ prerelease: false
47
+ version_requirements: *83948630
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec
50
+ requirement: &83948330 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: 2.0.0
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: *83948330
59
+ - !ruby/object:Gem::Dependency
60
+ name: webmock
61
+ requirement: &83948030 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: *83948030
70
+ description: A very simple Ruby library for parsing Open Graph prototocol information
71
+ from websites. See http://opengraphprotocol.org for more information.
72
+ email: social-stream@dit.upm.es
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files:
76
+ - LICENSE
77
+ - README.rdoc
78
+ files:
79
+ - .document
80
+ - .rspec
81
+ - LICENSE
82
+ - README.rdoc
83
+ - Rakefile
84
+ - VERSION
85
+ - lib/opengraph.rb
86
+ - opengraph.gemspec
87
+ - spec/examples/partial.html
88
+ - spec/examples/rottentomatoes.html
89
+ - spec/opengraph_spec.rb
90
+ - spec/spec.opts
91
+ - spec/spec_helper.rb
92
+ homepage: http://github.com/ging/opengraph
93
+ licenses: []
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 1.8.12
113
+ signing_key:
114
+ specification_version: 3
115
+ summary: A very simple Ruby library for parsing Open Graph prototocol information
116
+ from websites.
117
+ test_files: []