Sha256: c52e36427e66e56d9d9c16153e6b79d3cab053c9bb0a3a9fc607e037375e3429

Contents?: true

Size: 940 Bytes

Versions: 1

Compression:

Stored size: 940 Bytes

Contents

require 'spec_helper'

describe LinkThumbnailer::Models::Website do

  let(:instance) { described_class.new }

  it { expect(instance.images).to be_empty }

  describe '#image=' do

    let(:image)   { double }
    let(:action)  { instance.image = image }

    before do
      allow(image).to receive(:valid?).and_return(true)
    end

    it { expect { action }.to change { instance.images.size }.by(1) }

  end

  describe '#images=' do

    let(:image)   { double }
    let(:action)  { instance.images = image }

    context 'when image is valid' do

      before do
        allow(image).to receive(:valid?).and_return(true)
      end

      it { expect { action }.to change { instance.images.size }.by(1) }

    end

    context 'when image is not valid' do

      before do
        allow(image).to receive(:valid?).and_return(false)
      end

      it { expect { action }.to_not change { instance.images.size } }

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
link_thumbnailer-3.3.1 spec/models/website_spec.rb