Sha256: 98a1d5262055480bd493257fc10884ab2ee4e64a269a9deb878f296efc7fc4a2
Contents?: true
Size: 1.68 KB
Versions: 2
Compression:
Stored size: 1.68 KB
Contents
# frozen_string_literal: true require 'spec_helper' describe LinkThumbnailer::Graders::Length do let(:config) { double('config') } let(:description) { double('description') } let(:instance) { described_class.new(description) } before do allow(instance).to receive(:config).and_return(config) end describe '#call' do let(:action) { instance.call } context 'when text is too short' do before do allow(instance).to receive(:too_short?).and_return(true) end it { expect(action).to eq(0.0) } end context 'when text is not too short' do before do allow(instance).to receive(:too_short?).and_return(false) allow(instance).to receive(:text).and_return(text) end context 'when text length is 120' do let(:text) { 'f' * 120 } it { expect(action).to eq(1.0) } end context 'when text length is 100' do let(:text) { 'f' * 100 } it { expect(action).to be < 1.0 } end context 'when text length is 60' do let(:text) { 'f' * 60 } it { expect(action).to be < 1.0 } end end end describe '#too_short?' do let(:action) { instance.send(:too_short?) } let(:config) { double } before do allow(instance).to receive(:config).and_return(config) allow(config).to receive(:description_min_length).and_return(10) allow(instance).to receive(:text).and_return(text) end context 'when true' do let(:text) { 'f' * 9 } it { expect(action).to be_truthy } end context 'when false' do let(:text) { 'f' * 10 } it { expect(action).to be_falsey } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
link_thumbnailer-3.4.0 | spec/graders/length_spec.rb |
link_thumbnailer-3.3.2 | spec/graders/length_spec.rb |