Sha256: 6062fc38ec4ac4675228db269edb8bbb89fae96e5dc809ed7dbb6c012b147c7f

Contents?: true

Size: 889 Bytes

Versions: 1

Compression:

Stored size: 889 Bytes

Contents

require 'spec_helper'

describe LinkThumbnailer::Graders::PunctuationDensity 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(:punctuations).and_return(punctuations)
    end

    context 'when text length is 0' do

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

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

    end

    context 'when text length is > 0' do

      let(:text) { 'foo' }

      context 'and punctuations is 0' do

        let(:punctuations) { [] }

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

      end

      context 'and punctuations is > 0' do

        let(:punctuations) { [1] }

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

      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
link_thumbnailer-3.0.0 spec/graders/punctuation_density_spec.rb