Sha256: 2f9065b4878389b161607e7a18e63966ec8e4648d8e96ac8cf744415c884fec3

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'

class MockOembedResponse
  def body
    { 'html' => '<iframe/>' }
  end
end

describe Earl do
  let(:instance) { Earl.new(url,options) }
  let(:url) { 'http:://example.com' }
  let(:options) { {} }

  describe "#oembed_options" do
    subject { instance.oembed_options }
    context "with default options" do
      let(:expected) { { :maxwidth => "560", :maxheight => "315" } }
      it { should eql(expected) }
    end
    context "with custom options" do
      let(:options) { { :oembed => { :maxwidth => "260" } } }
      let(:expected) { { :maxwidth => "260", :maxheight => "315" } }
      it { should eql(expected) }
    end
    context "with custom options passed to oembed" do
      let(:expected) { { :maxwidth => "360", :maxheight => "315" } }
      before do
        Oembedr.stub(:fetch).and_return(nil)
        instance.oembed({ :maxwidth => "360" })
      end
      it { should eql(expected) }
    end
  end

  describe "#oembed" do
    let(:dummy_response) { MockOembedResponse.new }
    before do
      instance.stub(:base_url).and_return('')
      Oembedr.stub(:fetch).and_return(dummy_response)
    end
    subject { instance.oembed }
    it { should eql({ :html => '<iframe/>' }) }
    describe "#oembed_html" do
      subject { instance.oembed_html }
      it { should eql('<iframe/>') }
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
earl-1.0.0 spec/unit/earl/oembed_spec.rb