Sha256: 6a4c0cffc4fc0d1da066769745bec8eda807a49be1a41780b4dbaf306fc6083c

Contents?: true

Size: 957 Bytes

Versions: 10

Compression:

Stored size: 957 Bytes

Contents

require 'spec_helper'

describe LinkThumbnailer::Graders::Position do

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

  describe '#call' do

    let(:action) { instance.call }

    context 'when position is 0' do

      before do
        description.stub(:position).and_return(0)
        description.stub(:candidates_number).and_return(1)
      end

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

    end

    context 'when position is 1 over 1 candidates' do

      before do
        description.stub(:position).and_return(1)
        description.stub(:candidates_number).and_return(1)
      end

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

    end

    context 'when position is 1 over more than 1 candidates' do

      before do
        description.stub(:position).and_return(1)
        description.stub(:candidates_number).and_return(2)
      end

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

    end

  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

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