socialcast-opengraph 0.0.5

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 'spec'
7
+ require 'spec/autorun'
8
+ require 'webmock/rspec'
9
+
10
+ include WebMock
11
+
12
+ Spec::Runner.configure do |config|
13
+
14
+ end
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: socialcast-opengraph
3
+ version: !ruby/object:Gem::Version
4
+ hash: 21
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 5
10
+ version: 0.0.5
11
+ platform: ruby
12
+ authors:
13
+ - Michael Bleigh
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-12-01 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: hashie
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: nokogiri
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 1
45
+ - 5
46
+ - 0
47
+ version: 1.5.0
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: rest-client
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ hash: 15
59
+ segments:
60
+ - 1
61
+ - 6
62
+ - 0
63
+ version: 1.6.0
64
+ type: :runtime
65
+ version_requirements: *id003
66
+ - !ruby/object:Gem::Dependency
67
+ name: rspec
68
+ prerelease: false
69
+ requirement: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 13
75
+ segments:
76
+ - 1
77
+ - 2
78
+ - 9
79
+ version: 1.2.9
80
+ type: :development
81
+ version_requirements: *id004
82
+ - !ruby/object:Gem::Dependency
83
+ name: webmock
84
+ prerelease: false
85
+ requirement: &id005 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ hash: 3
91
+ segments:
92
+ - 0
93
+ version: "0"
94
+ type: :development
95
+ version_requirements: *id005
96
+ description: A very simple Ruby library for parsing Open Graph prototocol information from websites. See http://opengraphprotocol.org for more information.
97
+ email: michael@intridea.com
98
+ executables: []
99
+
100
+ extensions: []
101
+
102
+ extra_rdoc_files:
103
+ - LICENSE
104
+ - README.rdoc
105
+ files:
106
+ - .document
107
+ - .gitignore
108
+ - .rspec
109
+ - LICENSE
110
+ - README.rdoc
111
+ - Rakefile
112
+ - VERSION
113
+ - lib/opengraph.rb
114
+ - opengraph.gemspec
115
+ - spec/examples/partial.html
116
+ - spec/examples/rottentomatoes.html
117
+ - spec/opengraph_spec.rb
118
+ - spec/spec.opts
119
+ - spec/spec_helper.rb
120
+ homepage: http://github.com/intridea/opengraph
121
+ licenses: []
122
+
123
+ post_install_message:
124
+ rdoc_options:
125
+ - --charset=UTF-8
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ hash: 3
134
+ segments:
135
+ - 0
136
+ version: "0"
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ hash: 3
143
+ segments:
144
+ - 0
145
+ version: "0"
146
+ requirements: []
147
+
148
+ rubyforge_project:
149
+ rubygems_version: 1.8.11
150
+ signing_key:
151
+ specification_version: 3
152
+ summary: A very simple Ruby library for parsing Open Graph prototocol information from websites.
153
+ test_files:
154
+ - spec/opengraph_spec.rb
155
+ - spec/spec_helper.rb