Sha256: a0fbfa4c71fd786a9a4d83cb317811aec09c2a7248e0d2833cf4878ba43c7c1b

Contents?: true

Size: 890 Bytes

Versions: 2

Compression:

Stored size: 890 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

describe LinkThumbnailer::Graders::LinkDensity do

  let(:description) { double('description') }
  let(:instance)    { described_class.new(description) }

  describe '#call' do

    let(:action) { instance.call }

    before do
      allow(instance).to receive(:text).and_return(text)
      allow(instance).to receive(:links).and_return(links)
    end

    context 'when text length is 0' do

      let(:text) { '' }
      let(:links) { [] }

      it { expect(action).to eq(0.0) }

    end

    context 'when text length is > 0' do

      let(:text) { 'foo' }

      context 'and links is 0' do

        let(:links) { [] }

        it { expect(action).to eq(1.0) }

      end

      context 'and links is > 0' do

        let(:links) { [1] }

        it { expect(action).to be_within(0.001).of(0.666) }

      end

    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
link_thumbnailer-3.4.0 spec/graders/link_density_spec.rb
link_thumbnailer-3.3.2 spec/graders/link_density_spec.rb