ikm-opengraph 0.0.6

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,79 @@
1
+ # coding: utf-8
2
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
+
4
+ describe OpenGraph do
5
+ let(:rotten){ File.open(File.dirname(__FILE__) + '/examples/rottentomatoes.html').read }
6
+ let(:partial){ File.open(File.dirname(__FILE__) + '/examples/partial.html').read }
7
+
8
+ describe '.parse' do
9
+ it 'should return false if there isnt valid Open Graph info' do
10
+ OpenGraph.parse("").should be_false
11
+ OpenGraph.parse(partial).should be_false
12
+ end
13
+
14
+ it 'should otherwise return an OpenGraph::Object' do
15
+ OpenGraph.parse(rotten).should be_kind_of(OpenGraph::Object)
16
+ end
17
+
18
+ context ' without strict mode' do
19
+ subject{ OpenGraph.parse(partial, false) }
20
+
21
+ it { should_not be_false }
22
+ it { subject.title.should == 'Partialized' }
23
+ end
24
+ end
25
+
26
+ describe '.fetch' do
27
+ it 'should fetch from the specified URL' do
28
+ stub_request(:get, 'http://www.rottentomatoes.com/m/1217700-kick_ass/').to_return(:body => rotten)
29
+ OpenGraph.fetch('http://www.rottentomatoes.com/m/1217700-kick_ass/').title.should == 'Kick-Ass'
30
+ WebMock.should have_requested(:get, 'http://www.rottentomatoes.com/m/1217700-kick_ass/')
31
+ end
32
+
33
+ it 'should catch errors' do
34
+ stub_request(:get, 'http://example.com').to_return(:status => 404)
35
+ OpenGraph.fetch('http://example.com').should be_false
36
+ Faraday.should_receive(:get).with('http://example.com').and_raise(SocketError)
37
+ OpenGraph.fetch('http://example.com').should be_false
38
+ end
39
+ end
40
+ end
41
+
42
+ describe OpenGraph::Object do
43
+ let(:rotten){ File.open(File.dirname(__FILE__) + '/examples/rottentomatoes.html')}
44
+ let(:euc_jp){ File.open(File.dirname(__FILE__) + '/examples/euc_jp.html')}
45
+
46
+ context ' a Rotten Tomatoes Movie' do
47
+ subject{ OpenGraph.parse(rotten) }
48
+
49
+ it 'should have the title' do
50
+ subject.title.should == "Kick-Ass"
51
+ end
52
+
53
+ it 'should be a product' do
54
+ subject.schema.should == 'product'
55
+ subject.should be_product
56
+ subject.should_not be_person
57
+ end
58
+
59
+ it 'should be a movie' do
60
+ subject.type.should == 'movie'
61
+ subject.should be_movie
62
+ subject.should_not be_tv_show
63
+ end
64
+
65
+ it 'should be valid' do
66
+ subject.should be_valid
67
+ subject['type'] = nil
68
+ subject.should_not be_valid
69
+ end
70
+ end
71
+
72
+ context 'EUC-JP encoded website' do
73
+ subject { OpenGraph.parse(euc_jp, false) }
74
+
75
+ it 'should have the title, converted into UTF-8' do
76
+ subject.title.should == "このページはEUC-JPで記述されています"
77
+ end
78
+ end
79
+ 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,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ikm-opengraph
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.6
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Michael Bleigh
9
+ - Matt Wilson
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-06-13 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hashie
17
+ requirement: !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: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: nokogiri
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: 1.4.0
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: 1.4.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: faraday
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.8.0
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: 0.8.0
63
+ - !ruby/object:Gem::Dependency
64
+ name: rspec
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: 2.0.0
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: 2.0.0
79
+ - !ruby/object:Gem::Dependency
80
+ name: webmock
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ type: :development
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ description: A very simple Ruby library for parsing Open Graph prototocol information
96
+ from websites. See http://opengraphprotocol.org for more information.
97
+ email: social-stream@dit.upm.es
98
+ executables: []
99
+ extensions: []
100
+ extra_rdoc_files:
101
+ - LICENSE
102
+ - README.rdoc
103
+ files:
104
+ - .document
105
+ - .rspec
106
+ - LICENSE
107
+ - README.rdoc
108
+ - Rakefile
109
+ - VERSION
110
+ - ikm-opengraph.gemspec
111
+ - lib/opengraph.rb
112
+ - opengraph.gemspec
113
+ - spec/examples/partial.html
114
+ - spec/examples/rottentomatoes.html
115
+ - spec/examples/euc_jp.html
116
+ - spec/opengraph_spec.rb
117
+ - spec/spec.opts
118
+ - spec/spec_helper.rb
119
+ homepage: http://github.com/ikm/opengraph
120
+ licenses: []
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ none: false
127
+ requirements:
128
+ - - ! '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ none: false
133
+ requirements:
134
+ - - ! '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 1.8.24
140
+ signing_key:
141
+ specification_version: 3
142
+ summary: A very simple Ruby library for parsing Open Graph prototocol information
143
+ from websites.
144
+ test_files: []
145
+ has_rdoc: