Sha256: 8fcfb786de6bcbcd29557da5cdf31bf82e8d23cacd72036d0f7b93faf32bc162

Contents?: true

Size: 1.54 KB

Versions: 12

Compression:

Stored size: 1.54 KB

Contents

# coding: utf-8
#
require 'spec_helper'

describe Picky::Query::Combinations do

  before(:each) do
    @combinations_ary = double :combinations_ary

    @combinations = described_class.new @combinations_ary
  end

  describe "to_result" do
    before(:each) do
      @combination1 = double :combination1, :to_result => :result1
      @combination2 = double :combination2, :to_result => :result2

      @combinations_ary = [@combination1, @combination2]

      @combinations = described_class.new @combinations_ary
    end
    it "resultifies the combinations" do
      @combinations.to_result.should == [:result1, :result2]
    end
  end

  describe "total_score" do
    before(:each) do
      @combination1 = double :combination1, :weight => 3.14
      @combination2 = double :combination2, :weight => 2.76

      @combinations_ary = [@combination1, @combination2]

      @combinations = described_class.new @combinations_ary
    end
    it "sums the scores" do
      @combinations.score.should == 5.90
    end
  end

  describe 'remove' do
    before(:each) do
      @combination1 = double :combination1, :category => double(:other, :name => :other)
      @combination2 = double :combination2, :category => double(:to_remove, :name => :to_remove)
      @combination3 = double :combination3, :category => double(:to_remove, :name => :to_remove)

      @combinations = described_class.new [@combination1, @combination2, @combination3]
    end
    it 'should remove the combinations' do
      @combinations.remove([:to_remove]).should == [@combination1]
    end
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
picky-4.23.1 spec/lib/query/combinations_spec.rb
picky-4.23.0 spec/lib/query/combinations_spec.rb
picky-4.22.0 spec/lib/query/combinations_spec.rb
picky-4.21.2 spec/lib/query/combinations_spec.rb
picky-4.21.1 spec/lib/query/combinations_spec.rb
picky-4.21.0 spec/lib/query/combinations_spec.rb
picky-4.20.2 spec/lib/query/combinations_spec.rb
picky-4.20.1 spec/lib/query/combinations_spec.rb
picky-4.20.0 spec/lib/query/combinations_spec.rb
picky-4.19.7 spec/lib/query/combinations_spec.rb
picky-4.19.6 spec/lib/query/combinations_spec.rb
picky-4.19.5 spec/lib/query/combinations_spec.rb