Sha256: e9d7c9cb1d788bcc7f0b2fc44bf65c6952109e3d463d5ebd978b7d3a5d2659fa

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

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

describe OEmbed::Formatter do
  include OEmbedSpecHelper

  it "should support JSON" do
    proc { OEmbed::Formatter.supported?(:json) }.
    should_not raise_error
  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.supported?(:xml) }.
    should_not raise_error
  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

3 entries across 3 versions & 1 rubygems

Version Path
ruby-oembed-0.8.11 spec/formatter_spec.rb
ruby-oembed-0.8.10 spec/formatter_spec.rb
ruby-oembed-0.8.9 spec/formatter_spec.rb