Sha256: ebce8f03823bb6d852deb57129dab1459d4f8f29607a008cacab531b8e04ee4a

Contents?: true

Size: 1.23 KB

Versions: 5

Compression:

Stored size: 1.23 KB

Contents

require File.dirname(__FILE__) + '/spec_helper'

describe OEmbed::Formatter do
  include OEmbedSpecHelper

  it "should support JSON" do
    proc { OEmbed::Formatter.support?(:json) }.
    should_not raise_error(OEmbed::FormatNotSupported)
  end
  
  it "should default to JSON" do
    OEmbed::Formatter.default.should == 'json'
  end
  
  it "should decode a JSON String" do
    decoded = OEmbed::Formatter.decode(:json, valid_response(:json))
    # We need to compare keys & values separately because we don't expect all
    # non-string values to be recognized correctly.
    decoded.keys.should == valid_response(:object).keys
    decoded.values.map{|v|v.to_s}.should == valid_response(:object).values.map{|v|v.to_s}
  end
  
  it "should support XML" do
    proc { OEmbed::Formatter.support?(:xml) }.
    should_not raise_error(OEmbed::FormatNotSupported)
  end
  
  it "should decode an XML String" do
    decoded = OEmbed::Formatter.decode(:xml, valid_response(:xml))
    # We need to compare keys & values separately because we don't expect all
    # non-string values to be recognized correctly.
    decoded.keys.should == valid_response(:object).keys
    decoded.values.map{|v|v.to_s}.should == valid_response(:object).values.map{|v|v.to_s}
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ruby-oembed-0.8.8 spec/formatter_spec.rb
ruby-oembed-0.8.7 spec/formatter_spec.rb
ruby-oembed-0.8.5 spec/formatter_spec.rb
ruby-oembed-0.8.3 spec/formatter_spec.rb
ruby-oembed-0.8.1 spec/formatter_spec.rb