Sha256: 8c708fd13abc44e960d722853f614b5c3969f891a1bf0e5dc9e2d6abff55af82

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

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

describe "OEmbed::Formatter::JSON::Backends::JSONGem" do
  include OEmbedSpecHelper

  before(:all) do
    lambda {
      OEmbed::Formatter::JSON.backend = 'JSONGem'
    }.should raise_error(LoadError)
    
    require 'json'
    
    lambda {
      OEmbed::Formatter::JSON.backend = 'JSONGem'
    }.should_not raise_error
  end

  it "should support JSON" do
    proc { OEmbed::Formatter.supported?(:json) }.
    should_not raise_error(OEmbed::FormatNotSupported)
  end
  
  it "should be using the JSONGem backend" do
    OEmbed::Formatter::JSON.backend.should == OEmbed::Formatter::JSON::Backends::JSONGem
  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-oembed-0.8.1 spec/formatter/json/jsongem_backend_spec.rb