Sha256: 7f0aeeaf005be2e85fcba3cc57e21a8d5096e3975af61752574c19fd5b57a9b8
Contents?: true
Size: 1.5 KB
Versions: 9
Compression:
Stored size: 1.5 KB
Contents
require 'spec_helper' describe LinkThumbnailer::Graders::Length do let(:config) { double('config') } let(:description) { double('description') } let(:instance) { described_class.new(description) } before do instance.stub(:config).and_return(config) end describe '#call' do let(:action) { instance.call } context 'when text is too short' do before do instance.stub(:too_short?).and_return(true) end it { expect(action).to eq(0.0) } end context 'when text is not too short' do before do instance.stub(:too_short?).and_return(false) instance.stub(: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?) } before do instance.stub_chain(:config, :description_min_length).and_return(10) instance.stub(: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
9 entries across 9 versions & 1 rubygems