Sha256: cf352afe65e11c7d5128987f6bac8cedceba9e9bb89c5ef446d3261de6b5abdc

Contents?: true

Size: 991 Bytes

Versions: 3

Compression:

Stored size: 991 Bytes

Contents

require 'spec_helper'

describe LinkThumbnailer::WebImage do

  class Foo
  end

  let(:foo) { Foo.new }

  before do
    foo.extend LinkThumbnailer::WebImage
  end

  subject { foo }

  it { should respond_to :to_hash }
  it { should respond_to :source_url }
  it { should respond_to :doc }

  describe ".to_hash" do

    context "with default attributes" do

      let(:attributes) { [:source_url] }

      subject { foo.to_hash }

      it { subject.keys.should eq(attributes.map(&:to_sym)) }

    end

    context "with all attributes" do

      let(:attributes) { LinkThumbnailer.configuration.rmagick_attributes }

      before do
        attributes.each {|a| foo.class.send(:define_method, a.to_sym) { 'foo' } }
      end

      after do
        attributes.each {|a| foo.class.send(:undef_method, a.to_sym) }
      end

      subject { foo.to_hash }

      it { subject.keys.should eq(attributes.map(&:to_sym)) }
      it { subject.values.should include('foo') }

    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
link_thumbnailer-1.0.3 spec/web_image_spec.rb
link_thumbnailer-1.0.2 spec/web_image_spec.rb
link_thumbnailer-1.0.0 spec/web_image_spec.rb