Sha256: 9e44752ea0d00be27a7ff40e3fb9e97555684e0eea8977ca845dec32e3ef7d48
Contents?: true
Size: 1.4 KB
Versions: 1
Compression:
Stored size: 1.4 KB
Contents
require 'spec_helper' describe LinkThumbnailer::Scrapers::Base do let(:document) { double('document') } let(:website) { LinkThumbnailer::Models::Website.new } let(:instance) { described_class.new(document, website) } describe '#call' do let(:attr) { :title } let(:value) { 'foo' } let(:action) { instance.call(attr) } before do allow(instance).to receive(:value).and_return(value) end it { expect { action }.to change { website.title }.from(nil).to(value) } end describe '#model_class' do let(:action) { instance.send(:model_class) } before do allow(instance).to receive(:attribute_name).and_return(attr) end context 'when internal class exists' do let(:attr) { :title } it { expect(action).to eq(::LinkThumbnailer::Models::Title) } end context 'when internal class does not exists' do let(:attr) { :foo } it { expect { action }.to raise_error(NameError) } end end describe '#modelize' do let(:node) { double('node') } let(:text) { 'foo' } let(:model_class) { double('model_class') } let(:action) { instance.send(:modelize, node, text) } before do allow(instance).to receive(:model_class).and_return(model_class) end it 'instantiates a new model' do expect(model_class).to receive(:new).with(node, text) action end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
link_thumbnailer-3.3.1 | spec/scrapers/base_spec.rb |