Sha256: 020c7085fa3939fa44ea4229b0c0141e7e42e97bd9eb5422fdc18c15e6d3714f

Contents?: true

Size: 971 Bytes

Versions: 2

Compression:

Stored size: 971 Bytes

Contents

# frozen_string_literal: true

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

2 entries across 2 versions & 1 rubygems

Version Path
link_thumbnailer-3.4.0 spec/models/website_spec.rb
link_thumbnailer-3.3.2 spec/models/website_spec.rb