Sha256: fac9f0ab00d6342fac938779057e46c237f40b870cd073ed0a56b9810a62cd5c

Contents?: true

Size: 833 Bytes

Versions: 10

Compression:

Stored size: 833 Bytes

Contents

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
      instance.stub(:text).and_return(text)
      instance.stub(: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

10 entries across 10 versions & 1 rubygems

Version Path
link_thumbnailer-3.3.0 spec/graders/link_density_spec.rb
link_thumbnailer-3.2.1 spec/graders/link_density_spec.rb
link_thumbnailer-3.2.0 spec/graders/link_density_spec.rb
link_thumbnailer-3.1.2 spec/graders/link_density_spec.rb
link_thumbnailer-3.1.1 spec/graders/link_density_spec.rb
link_thumbnailer-3.1.0 spec/graders/link_density_spec.rb
link_thumbnailer-3.0.3 spec/graders/link_density_spec.rb
link_thumbnailer-3.0.2 spec/graders/link_density_spec.rb
link_thumbnailer-3.0.1 spec/graders/link_density_spec.rb
link_thumbnailer-3.0.0 spec/graders/link_density_spec.rb