ruby-oembed 0.8.11 → 0.8.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -136,7 +136,7 @@ module OEmbed
136
136
  # OEmbed::Providers::Youtube.endpoint += "?iframe=0"
137
137
  # * To require https embed code
138
138
  # OEmbed::Providers::Youtube.endpoint += "?scheme=https"
139
- Youtube = OEmbed::Provider.new("http://www.youtube.com/oembed")
139
+ Youtube = OEmbed::Provider.new("http://www.youtube.com/oembed?scheme=https")
140
140
  Youtube << "http://*.youtube.com/*"
141
141
  Youtube << "https://*.youtube.com/*"
142
142
  Youtube << "http://*.youtu.be/*"
@@ -179,6 +179,19 @@ module OEmbed
179
179
  Vimeo << "https://*.vimeo.com/*"
180
180
  add_official_provider(Vimeo)
181
181
 
182
+ # Provider for twitter.com
183
+ # https://dev.twitter.com/rest/reference/get/statuses/oembed
184
+ Twitter = OEmbed::Provider.new("https://api.twitter.com/1/statuses/oembed.{format}")
185
+ Twitter << "https://*.twitter.com/*/status/*"
186
+ add_official_provider(Twitter)
187
+
188
+ # Provider for vine.co
189
+ # https://dev.twitter.com/web/vine/oembed
190
+ Vine = OEmbed::Provider.new("https://vine.co/oembed.{format}")
191
+ Vine << "http://*.vine.co/v/*"
192
+ Vine << "https://*.vine.co/v/*"
193
+ add_official_provider(Vine)
194
+
182
195
  # Provider for instagram.com
183
196
  # http://instagr.am/developer/embedding/
184
197
  Instagram = OEmbed::Provider.new("http://api.instagram.com/oembed", :json)
@@ -199,6 +212,12 @@ module OEmbed
199
212
  Yfrog << "http://yfrog.com/*"
200
213
  add_official_provider(Yfrog)
201
214
 
215
+ # Provider for imgur.com
216
+ Imgur = OEmbed::Provider.new("https://api.imgur.com/oembed.{format}")
217
+ Imgur << "https://*.imgur.com/gallery/*"
218
+ Imgur << "http://*.imgur.com/gallery/*"
219
+ add_official_provider(Imgur)
220
+
202
221
  # provider for mlg-tv
203
222
  # http://tv.majorleaguegaming.com/oembed
204
223
  MlgTv = OEmbed::Provider.new("http://tv.majorleaguegaming.com/oembed")
@@ -2,7 +2,7 @@ module OEmbed
2
2
  class Version
3
3
  MAJOR = 0
4
4
  MINOR = 8
5
- PATCH = 11
5
+ PATCH = 12
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
 
8
8
  class << self
@@ -9,7 +9,7 @@ class WorkingDuck
9
9
  end
10
10
  def parse_error; RuntimeError; end
11
11
  end
12
-
12
+
13
13
  # A WorkingDuck instance should work as a Backend
14
14
  def decode(value)
15
15
  self.class.decode(value)
@@ -29,33 +29,33 @@ describe "OEmbed::Formatter::JSON::Backends::DuckType" do
29
29
  include OEmbedSpecHelper
30
30
 
31
31
  it "should work with WorkingDuck Class" do
32
- lambda {
32
+ expect {
33
33
  OEmbed::Formatter::JSON.backend = WorkingDuck
34
- }.should_not raise_error
35
- OEmbed::Formatter::JSON.backend.should equal(WorkingDuck)
34
+ }.not_to raise_error
35
+ expect(OEmbed::Formatter::JSON.backend).to be WorkingDuck
36
36
  end
37
-
37
+
38
38
  it "should work with a WorkingDuck instance" do
39
39
  instance = WorkingDuck.new
40
- lambda {
40
+ expect {
41
41
  OEmbed::Formatter::JSON.backend = instance
42
- }.should_not raise_error
43
- OEmbed::Formatter::JSON.backend.should equal(instance)
42
+ }.to_not raise_error
43
+ expect(OEmbed::Formatter::JSON.backend).to be instance
44
44
  end
45
-
45
+
46
46
  it "should fail with FailingDuckDecode Class" do
47
- lambda {
47
+ expect {
48
48
  OEmbed::Formatter::JSON.backend = FailingDuckDecode
49
- }.should raise_error(LoadError)
50
- OEmbed::Formatter::JSON.backend.should_not equal(FailingDuckDecode)
49
+ }.to raise_error(LoadError)
50
+ expect(OEmbed::Formatter::JSON.backend).to_not be(FailingDuckDecode)
51
51
  end
52
-
52
+
53
53
  it "should fail with a FailingDuckDecode instance" do
54
54
  instance = FailingDuckDecode.new
55
- lambda {
55
+ expect {
56
56
  OEmbed::Formatter::JSON.backend = instance
57
- }.should raise_error(LoadError)
58
- OEmbed::Formatter::JSON.backend.should_not equal(instance)
57
+ }.to raise_error(LoadError)
58
+ expect(OEmbed::Formatter::JSON.backend).to_not be(instance)
59
59
  end
60
60
  end
61
61
 
@@ -63,32 +63,32 @@ describe "OEmbed::Formatter::XML::Backends::DuckType" do
63
63
  include OEmbedSpecHelper
64
64
 
65
65
  it "should work with WorkingDuck Class" do
66
- lambda {
66
+ expect {
67
67
  OEmbed::Formatter::XML.backend = WorkingDuck
68
- }.should_not raise_error
69
- OEmbed::Formatter::XML.backend.should equal(WorkingDuck)
68
+ }.to_not raise_error
69
+ expect(OEmbed::Formatter::XML.backend).to be(WorkingDuck)
70
70
  end
71
-
71
+
72
72
  it "should work with a WorkingDuck instance" do
73
73
  instance = WorkingDuck.new
74
- lambda {
74
+ expect {
75
75
  OEmbed::Formatter::XML.backend = instance
76
- }.should_not raise_error
77
- OEmbed::Formatter::XML.backend.should equal(instance)
76
+ }.to_not raise_error
77
+ expect(OEmbed::Formatter::XML.backend).to be(instance)
78
78
  end
79
-
79
+
80
80
  it "should fail with FailingDuckDecode Class" do
81
- lambda {
81
+ expect {
82
82
  OEmbed::Formatter::XML.backend = FailingDuckDecode
83
- }.should raise_error(LoadError)
84
- OEmbed::Formatter::XML.backend.should_not equal(FailingDuckDecode)
83
+ }.to raise_error(LoadError)
84
+ expect(OEmbed::Formatter::XML.backend).to_not be(FailingDuckDecode)
85
85
  end
86
-
86
+
87
87
  it "should fail with a FailingDuckDecode instance" do
88
88
  instance = FailingDuckDecode.new
89
- lambda {
89
+ expect {
90
90
  OEmbed::Formatter::XML.backend = instance
91
- }.should raise_error(LoadError)
92
- OEmbed::Formatter::XML.backend.should_not equal(instance)
91
+ }.to raise_error(LoadError)
92
+ expect(OEmbed::Formatter::XML.backend).to_not be(instance)
93
93
  end
94
94
  end
@@ -4,55 +4,56 @@ describe "OEmbed::Formatter::JSON::Backends::JSONGem" do
4
4
  include OEmbedSpecHelper
5
5
 
6
6
  before(:all) do
7
- lambda {
7
+ expect {
8
8
  OEmbed::Formatter::JSON.backend = 'JSONGem'
9
- }.should raise_error(LoadError)
10
-
9
+ }.to raise_error(LoadError)
10
+
11
11
  require 'json'
12
-
13
- lambda {
12
+
13
+ expect {
14
14
  OEmbed::Formatter::JSON.backend = 'JSONGem'
15
- }.should_not raise_error
15
+ }.to_not raise_error
16
16
  end
17
17
 
18
18
  it "should support JSON" do
19
- proc { OEmbed::Formatter.supported?(:json) }.
20
- should_not raise_error
19
+ expect {
20
+ OEmbed::Formatter.supported?(:json)
21
+ }.to_not raise_error
21
22
  end
22
-
23
+
23
24
  it "should be using the JSONGem backend" do
24
- OEmbed::Formatter::JSON.backend.should == OEmbed::Formatter::JSON::Backends::JSONGem
25
+ expect(OEmbed::Formatter::JSON.backend).to eq(OEmbed::Formatter::JSON::Backends::JSONGem)
25
26
  end
26
-
27
+
27
28
  it "should decode a JSON String" do
28
29
  decoded = OEmbed::Formatter.decode(:json, valid_response(:json))
29
30
  # We need to compare keys & values separately because we don't expect all
30
31
  # non-string values to be recognized correctly.
31
- decoded.keys.should == valid_response(:object).keys
32
- decoded.values.map{|v|v.to_s}.should == valid_response(:object).values.map{|v|v.to_s}
32
+ expect(decoded.keys).to eq(valid_response(:object).keys)
33
+ expect(decoded.values.map{|v|v.to_s}).to eq(valid_response(:object).values.map{|v|v.to_s})
33
34
  end
34
-
35
+
35
36
  it "should raise an OEmbed::ParseError when decoding an invalid JSON String" do
36
- lambda {
37
+ expect {
37
38
  decode = OEmbed::Formatter.decode(:json, invalid_response('unclosed_container', :json))
38
- }.should raise_error(OEmbed::ParseError)
39
- lambda {
39
+ }.to raise_error(OEmbed::ParseError)
40
+ expect {
40
41
  decode = OEmbed::Formatter.decode(:json, invalid_response('unclosed_tag', :json))
41
- }.should raise_error(OEmbed::ParseError)
42
- lambda {
42
+ }.to raise_error(OEmbed::ParseError)
43
+ expect {
43
44
  decode = OEmbed::Formatter.decode(:json, invalid_response('invalid_syntax', :json))
44
- }.should raise_error(OEmbed::ParseError)
45
+ }.to raise_error(OEmbed::ParseError)
45
46
  end
46
-
47
+
47
48
  it "should raise an OEmbed::ParseError when decoding fails with an unexpected error" do
48
49
  error_to_raise = ArgumentError
49
- OEmbed::Formatter::JSON.backend.parse_error.should_not be_kind_of(error_to_raise)
50
-
51
- ::JSON.should_receive(:parse).
52
- and_raise(error_to_raise.new("unknown error"))
53
-
54
- lambda {
50
+ expect(OEmbed::Formatter::JSON.backend.parse_error).to_not be_kind_of(error_to_raise)
51
+
52
+ expect(::JSON).to receive(:parse).
53
+ and_throw(error_to_raise.new("unknown error"))
54
+
55
+ expect {
55
56
  decode = OEmbed::Formatter.decode(:json, valid_response(:json))
56
- }.should raise_error(OEmbed::ParseError)
57
+ }.to raise_error(OEmbed::ParseError)
57
58
  end
58
59
  end
@@ -4,51 +4,52 @@ describe "OEmbed::Formatter::JSON::Backends::Yaml" do
4
4
  include OEmbedSpecHelper
5
5
 
6
6
  before(:all) do
7
- lambda {
7
+ expect {
8
8
  OEmbed::Formatter::JSON.backend = 'Yaml'
9
- }.should_not raise_error
10
-
11
- (!!defined?(YAML)).should == true
9
+ }.to_not raise_error
10
+
11
+ expect(!!defined?(YAML)).to eq(true)
12
12
  end
13
13
 
14
14
  it "should support JSON" do
15
- proc { OEmbed::Formatter.supported?(:json) }.
16
- should_not raise_error
15
+ expect {
16
+ OEmbed::Formatter.supported?(:json)
17
+ }.to_not raise_error
17
18
  end
18
-
19
+
19
20
  it "should be using the Yaml backend" do
20
- OEmbed::Formatter::JSON.backend.should == OEmbed::Formatter::JSON::Backends::Yaml
21
+ expect(OEmbed::Formatter::JSON.backend).to eq(OEmbed::Formatter::JSON::Backends::Yaml)
21
22
  end
22
-
23
+
23
24
  it "should decode a JSON String" do
24
25
  decoded = OEmbed::Formatter.decode(:json, valid_response(:json))
25
26
  # We need to compare keys & values separately because we don't expect all
26
27
  # non-string values to be recognized correctly.
27
- decoded.keys.should == valid_response(:object).keys
28
- decoded.values.map{|v|v.to_s}.should == valid_response(:object).values.map{|v|v.to_s}
28
+ expect(decoded.keys).to eq(valid_response(:object).keys)
29
+ expect(decoded.values.map{|v|v.to_s}).to eq(valid_response(:object).values.map{|v|v.to_s})
29
30
  end
30
-
31
+
31
32
  it "should raise an OEmbed::ParseError when decoding an invalid JSON String" do
32
- lambda {
33
+ expect {
33
34
  decode = OEmbed::Formatter.decode(:json, invalid_response('unclosed_container', :json))
34
- }.should raise_error(OEmbed::ParseError)
35
- lambda {
35
+ }.to raise_error(OEmbed::ParseError)
36
+ expect {
36
37
  decode = OEmbed::Formatter.decode(:json, invalid_response('unclosed_tag', :json))
37
- }.should raise_error(OEmbed::ParseError)
38
- lambda {
38
+ }.to raise_error(OEmbed::ParseError)
39
+ expect {
39
40
  decode = OEmbed::Formatter.decode(:json, invalid_response('invalid_syntax', :json))
40
- }.should raise_error(OEmbed::ParseError)
41
+ }.to raise_error(OEmbed::ParseError)
41
42
  end
42
-
43
+
43
44
  it "should raise an OEmbed::ParseError when decoding fails with an unexpected error" do
44
45
  error_to_raise = ArgumentError
45
- OEmbed::Formatter::JSON.backend.parse_error.should_not be_kind_of(error_to_raise)
46
-
47
- OEmbed::Formatter::JSON.backend.should_receive(:convert_json_to_yaml).
48
- and_raise(error_to_raise.new("unknown error"))
49
-
50
- lambda {
46
+ expect(OEmbed::Formatter::JSON.backend.parse_error).to_not be_kind_of(error_to_raise)
47
+
48
+ expect(OEmbed::Formatter::JSON.backend).to receive(:convert_json_to_yaml).
49
+ and_throw(error_to_raise.new("unknown error"))
50
+
51
+ expect {
51
52
  decode = OEmbed::Formatter.decode(:json, valid_response(:json))
52
- }.should raise_error(OEmbed::ParseError)
53
+ }.to raise_error(OEmbed::ParseError)
53
54
  end
54
55
  end
@@ -4,55 +4,56 @@ describe "OEmbed::Formatter::XML::Backends::Nokogiri" do
4
4
  include OEmbedSpecHelper
5
5
 
6
6
  before(:all) do
7
- lambda {
7
+ expect {
8
8
  OEmbed::Formatter::XML.backend = 'Nokogiri'
9
- }.should raise_error(LoadError)
10
-
9
+ }.to raise_error(LoadError)
10
+
11
11
  require 'nokogiri'
12
-
13
- lambda {
12
+
13
+ expect {
14
14
  OEmbed::Formatter::XML.backend = 'Nokogiri'
15
- }.should_not raise_error
15
+ }.to_not raise_error
16
16
  end
17
17
 
18
18
  it "should support XML" do
19
- proc { OEmbed::Formatter.supported?(:xml) }.
20
- should_not raise_error
19
+ expect {
20
+ OEmbed::Formatter.supported?(:xml)
21
+ }.to_not raise_error
21
22
  end
22
-
23
+
23
24
  it "should be using the Nokogiri backend" do
24
- OEmbed::Formatter::XML.backend.should == OEmbed::Formatter::XML::Backends::Nokogiri
25
+ expect(OEmbed::Formatter::XML.backend).to eq(OEmbed::Formatter::XML::Backends::Nokogiri)
25
26
  end
26
-
27
+
27
28
  it "should decode an XML String" do
28
29
  decoded = OEmbed::Formatter.decode(:xml, valid_response(:xml))
29
30
  # We need to compare keys & values separately because we don't expect all
30
31
  # non-string values to be recognized correctly.
31
- decoded.keys.should == valid_response(:object).keys
32
- decoded.values.map{|v|v.to_s}.should == valid_response(:object).values.map{|v|v.to_s}
32
+ expect(decoded.keys).to eq(valid_response(:object).keys)
33
+ expect(decoded.values.map{|v|v.to_s}).to eq(valid_response(:object).values.map{|v|v.to_s})
33
34
  end
34
-
35
+
35
36
  it "should raise an OEmbed::ParseError when decoding an invalid XML String" do
36
- lambda {
37
+ expect {
37
38
  decode = OEmbed::Formatter.decode(:xml, invalid_response('unclosed_container', :xml))
38
- }.should raise_error(OEmbed::ParseError)
39
- lambda {
39
+ }.to raise_error(OEmbed::ParseError)
40
+ expect {
40
41
  decode = OEmbed::Formatter.decode(:xml, invalid_response('unclosed_tag', :xml))
41
- }.should raise_error(OEmbed::ParseError)
42
- lambda {
42
+ }.to raise_error(OEmbed::ParseError)
43
+ expect {
43
44
  decode = OEmbed::Formatter.decode(:xml, invalid_response('invalid_syntax', :xml))
44
- }.should raise_error(OEmbed::ParseError)
45
+ }.to raise_error(OEmbed::ParseError)
45
46
  end
46
-
47
+
47
48
  it "should raise an OEmbed::ParseError when decoding fails with an unexpected error" do
48
49
  error_to_raise = ArgumentError
49
- OEmbed::Formatter::XML.backend.parse_error.should_not be_kind_of(error_to_raise)
50
-
51
- ::Nokogiri::XML::Document.should_receive(:parse).
50
+ expect(OEmbed::Formatter::XML.backend.parse_error).to_not be_kind_of(error_to_raise)
51
+
52
+ expect(::Nokogiri::XML::Document).to receive(:parse).
52
53
  and_raise(error_to_raise.new("unknown error"))
53
-
54
- lambda {
54
+
55
+ expect {
55
56
  decode = OEmbed::Formatter.decode(:xml, valid_response(:xml))
56
- }.should raise_error(OEmbed::ParseError)
57
+ }.to raise_error(OEmbed::ParseError)
57
58
  end
58
59
  end
@@ -4,51 +4,52 @@ describe "OEmbed::Formatter::XML::Backends::REXML" do
4
4
  include OEmbedSpecHelper
5
5
 
6
6
  before(:all) do
7
- lambda {
7
+ expect {
8
8
  OEmbed::Formatter::XML.backend = 'REXML'
9
- }.should_not raise_error
10
-
11
- (!!defined?(REXML)).should == true
9
+ }.to_not raise_error
10
+
11
+ expect((!!defined?(REXML))).to eq(true)
12
12
  end
13
13
 
14
14
  it "should support XML" do
15
- proc { OEmbed::Formatter.supported?(:xml) }.
16
- should_not raise_error
15
+ expect {
16
+ OEmbed::Formatter.supported?(:xml)
17
+ }.to_not raise_error
17
18
  end
18
-
19
+
19
20
  it "should be using the XmlSimple backend" do
20
- OEmbed::Formatter::XML.backend.should == OEmbed::Formatter::XML::Backends::REXML
21
+ expect(OEmbed::Formatter::XML.backend).to eq(OEmbed::Formatter::XML::Backends::REXML)
21
22
  end
22
-
23
+
23
24
  it "should decode an XML String" do
24
25
  decoded = OEmbed::Formatter.decode(:xml, valid_response(:xml))
25
26
  # We need to compare keys & values separately because we don't expect all
26
27
  # non-string values to be recognized correctly.
27
- decoded.keys.should == valid_response(:object).keys
28
- decoded.values.map{|v|v.to_s}.should == valid_response(:object).values.map{|v|v.to_s}
28
+ expect(decoded.keys).to eq(valid_response(:object).keys)
29
+ expect(decoded.values.map{|v|v.to_s}).to eq(valid_response(:object).values.map{|v|v.to_s})
29
30
  end
30
-
31
+
31
32
  it "should raise an OEmbed::ParseError when decoding an invalid XML String" do
32
- lambda {
33
+ expect {
33
34
  decode = OEmbed::Formatter.decode(:xml, invalid_response('unclosed_container', :xml))
34
- }.should raise_error(OEmbed::ParseError)
35
- lambda {
35
+ }.to raise_error(OEmbed::ParseError)
36
+ expect {
36
37
  decode = OEmbed::Formatter.decode(:xml, invalid_response('unclosed_tag', :xml))
37
- }.should raise_error(OEmbed::ParseError)
38
- lambda {
38
+ }.to raise_error(OEmbed::ParseError)
39
+ expect {
39
40
  decode = OEmbed::Formatter.decode(:xml, invalid_response('invalid_syntax', :xml))
40
- }.should raise_error(OEmbed::ParseError)
41
+ }.to raise_error(OEmbed::ParseError)
41
42
  end
42
-
43
+
43
44
  it "should raise an OEmbed::ParseError when decoding fails with an unexpected error" do
44
45
  error_to_raise = ArgumentError
45
- OEmbed::Formatter::XML.backend.parse_error.should_not be_kind_of(error_to_raise)
46
-
47
- ::REXML::Document.should_receive(:new).
46
+ expect(OEmbed::Formatter::XML.backend.parse_error).to_not be_kind_of(error_to_raise)
47
+
48
+ expect(::REXML::Document).to receive(:new).
48
49
  and_raise(error_to_raise.new("unknown error"))
49
-
50
- lambda {
50
+
51
+ expect {
51
52
  decode = OEmbed::Formatter.decode(:xml, valid_response(:xml))
52
- }.should raise_error(OEmbed::ParseError)
53
+ }.to raise_error(OEmbed::ParseError)
53
54
  end
54
55
  end
@@ -4,55 +4,56 @@ describe "OEmbed::Formatter::XML::Backends::XmlSimple" do
4
4
  include OEmbedSpecHelper
5
5
 
6
6
  before(:all) do
7
- lambda {
7
+ expect {
8
8
  OEmbed::Formatter::XML.backend = 'XmlSimple'
9
- }.should raise_error(LoadError)
10
-
9
+ }.to raise_error(LoadError)
10
+
11
11
  require 'xmlsimple'
12
-
13
- lambda {
12
+
13
+ expect {
14
14
  OEmbed::Formatter::XML.backend = 'XmlSimple'
15
- }.should_not raise_error
15
+ }.to_not raise_error
16
16
  end
17
17
 
18
18
  it "should support XML" do
19
- proc { OEmbed::Formatter.supported?(:xml) }.
20
- should_not raise_error
19
+ expect {
20
+ OEmbed::Formatter.supported?(:xml)
21
+ }.to_not raise_error
21
22
  end
22
-
23
+
23
24
  it "should be using the XmlSimple backend" do
24
- OEmbed::Formatter::XML.backend.should == OEmbed::Formatter::XML::Backends::XmlSimple
25
+ expect(OEmbed::Formatter::XML.backend).to eq(OEmbed::Formatter::XML::Backends::XmlSimple)
25
26
  end
26
-
27
+
27
28
  it "should decode an XML String" do
28
29
  decoded = OEmbed::Formatter.decode(:xml, valid_response(:xml))
29
30
  # We need to compare keys & values separately because we don't expect all
30
31
  # non-string values to be recognized correctly.
31
- decoded.keys.should == valid_response(:object).keys
32
- decoded.values.map{|v|v.to_s}.should == valid_response(:object).values.map{|v|v.to_s}
32
+ expect(decoded.keys).to eq(valid_response(:object).keys)
33
+ expect(decoded.values.map{|v|v.to_s}).to eq(valid_response(:object).values.map{|v|v.to_s})
33
34
  end
34
-
35
+
35
36
  it "should raise an OEmbed::ParseError when decoding an invalid XML String" do
36
- lambda {
37
+ expect {
37
38
  decode = OEmbed::Formatter.decode(:xml, invalid_response('unclosed_container', :xml))
38
- }.should raise_error(OEmbed::ParseError)
39
- lambda {
39
+ }.to raise_error(OEmbed::ParseError)
40
+ expect {
40
41
  decode = OEmbed::Formatter.decode(:xml, invalid_response('unclosed_tag', :xml))
41
- }.should raise_error(OEmbed::ParseError)
42
- lambda {
42
+ }.to raise_error(OEmbed::ParseError)
43
+ expect {
43
44
  decode = OEmbed::Formatter.decode(:xml, invalid_response('invalid_syntax', :xml))
44
- }.should raise_error(OEmbed::ParseError)
45
+ }.to raise_error(OEmbed::ParseError)
45
46
  end
46
-
47
+
47
48
  it "should raise an OEmbed::ParseError when decoding fails with an unexpected error" do
48
49
  error_to_raise = ArgumentError
49
- OEmbed::Formatter::XML.backend.parse_error.should_not be_kind_of(error_to_raise)
50
-
51
- ::XmlSimple.should_receive(:xml_in).
50
+ expect(OEmbed::Formatter::XML.backend.parse_error).to_not be_kind_of(error_to_raise)
51
+
52
+ expect(::XmlSimple).to receive(:xml_in).
52
53
  and_raise(error_to_raise.new("unknown error"))
53
-
54
- lambda {
54
+
55
+ expect {
55
56
  decode = OEmbed::Formatter.decode(:xml, valid_response(:xml))
56
- }.should raise_error(OEmbed::ParseError)
57
+ }.to raise_error(OEmbed::ParseError)
57
58
  end
58
59
  end
@@ -4,32 +4,34 @@ describe OEmbed::Formatter do
4
4
  include OEmbedSpecHelper
5
5
 
6
6
  it "should support JSON" do
7
- proc { OEmbed::Formatter.supported?(:json) }.
8
- should_not raise_error
7
+ expect {
8
+ OEmbed::Formatter.supported?(:json)
9
+ }.to_not raise_error
9
10
  end
10
11
 
11
12
  it "should default to JSON" do
12
- OEmbed::Formatter.default.should == 'json'
13
+ expect(OEmbed::Formatter.default).to eq('json')
13
14
  end
14
15
 
15
16
  it "should decode a JSON String" do
16
17
  decoded = OEmbed::Formatter.decode(:json, valid_response(:json))
17
18
  # We need to compare keys & values separately because we don't expect all
18
19
  # non-string values to be recognized correctly.
19
- decoded.keys.should == valid_response(:object).keys
20
- decoded.values.map{|v|v.to_s}.should == valid_response(:object).values.map{|v|v.to_s}
20
+ expect(decoded.keys).to eq(valid_response(:object).keys)
21
+ expect(decoded.values.map{|v|v.to_s}).to eq(valid_response(:object).values.map{|v|v.to_s})
21
22
  end
22
23
 
23
24
  it "should support XML" do
24
- proc { OEmbed::Formatter.supported?(:xml) }.
25
- should_not raise_error
25
+ expect {
26
+ OEmbed::Formatter.supported?(:xml)
27
+ }.to_not raise_error
26
28
  end
27
29
 
28
30
  it "should decode an XML String" do
29
31
  decoded = OEmbed::Formatter.decode(:xml, valid_response(:xml))
30
32
  # We need to compare keys & values separately because we don't expect all
31
33
  # non-string values to be recognized correctly.
32
- decoded.keys.should == valid_response(:object).keys
33
- decoded.values.map{|v|v.to_s}.should == valid_response(:object).values.map{|v|v.to_s}
34
+ expect(decoded.keys).to eq(valid_response(:object).keys)
35
+ expect(decoded.values.map{|v|v.to_s}).to eq(valid_response(:object).values.map{|v|v.to_s})
34
36
  end
35
37
  end