Sha256: d80a518a54192610e01e4bf9e6a70e24f1e74eef161151cbb7e50bba4f94c588
Contents?: true
Size: 1.1 KB
Versions: 39
Compression:
Stored size: 1.1 KB
Contents
require 'spec_helper' describe Picky::API::Search::Boost do let(:object) do Class.new do include Picky::API::Search::Boost end.new end context 'boost_for' do context 'with a Hash' do it 'returns a boosts object' do combinations = [ stub(:combination, :category_name => :bla) ] object.extract_boosts([:bla] => +7.77).boost_for(combinations).should == 7.77 end end context 'with a boosts object' do let(:booster) do Class.new do def boost_for whatever 7.0 end end.new end it 'returns a boosts object' do object.extract_boosts(booster).boost_for(:anything).should == 7.0 end end context 'invalid weight' do it 'raises with a nice error message' do expect { object.extract_boosts Object.new }.to raise_error(<<-ERROR) boost options for a Search should be either * for example a Hash { [:name, :surname] => +3 } or * an object that responds to #boost_for(combinations) and returns a boost float ERROR end end end end
Version data entries
39 entries across 39 versions & 1 rubygems