Sha256: dda16a3fe0f279b02e8a1a4fede028643880df3c3d52daa2e2cf83dafe970104

Contents?: true

Size: 1.74 KB

Versions: 16

Compression:

Stored size: 1.74 KB

Contents

require File.join(File.dirname(__FILE__), %w[.. spec_helper])

describe Endeca::Refinement do
  before do
    @dimension_value = {
      "DimValueID" => "4294965335",
      "SelectionLink" => "N=4294965335&Ne=3",
      "DimValueName" => "Winter Park",
      "NumberofRecords" => "44"
    }

    dimensions = { "Dimensions" => [ 
      { 
        "DimensionID" => "3",
        "DimensionName" => "state", 
        "ContractionLink" => "N=",
        "DimensionValues" => [@dimension_value] 
      }
     ]
    }
    @refinement = Endeca::Refinement.new( dimensions )
  end

  describe '#==' do
    it "should compare refinements by id" do
      doc_1, doc_2 = Endeca::Refinement.new, Endeca::Refinement.new
      doc_1.stub!(:id).and_return(1)
      doc_2.stub!(:id).and_return(1)
      (doc_1 == doc_2).should be_true

      doc_2.stub!(:id).and_return(2)
      (doc_1 == doc_2).should be_false
    end
  end

  describe '#inspect' do
    it "includes the class name" do
      @refinement.inspect.should include(Endeca::Refinement.name)
    end

    it "includes the hex string of the object id" do
      @refinement.inspect.should include("0x#{@refinement.object_id.to_s(16)}")
    end

    it "includes the id" do
      @refinement.stub!(:id).and_return(1)
      @refinement.inspect.should include('id=1')
    end

    it "includes the inspected name" do
      @refinement.stub!(:name).and_return('A Name')
      @refinement.inspect.should include('name="A Name"')
    end
  end

  it "should return to_params on the contraction link " do
    @refinement.to_params.should == "N="
  end

  it "should return an array of dimensions for dimension_values" do
    my_dimension = Endeca::Dimension.new(@dimension_value)
    @refinement.dimension_values.should == [my_dimension]
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
primedia-endeca-0.9.10 spec/endeca/refinement_spec.rb
primedia-endeca-0.9.11 spec/endeca/refinement_spec.rb
primedia-endeca-0.9.12 spec/endeca/refinement_spec.rb
primedia-endeca-0.9.13 spec/endeca/refinement_spec.rb
primedia-endeca-0.9.14 spec/endeca/refinement_spec.rb
primedia-endeca-0.9.15 spec/endeca/refinement_spec.rb
primedia-endeca-0.9.16 spec/endeca/refinement_spec.rb
primedia-endeca-0.9.17 spec/endeca/refinement_spec.rb
primedia-endeca-0.9.18 spec/endeca/refinement_spec.rb
primedia-endeca-0.9.19 spec/endeca/refinement_spec.rb
primedia-endeca-0.9.20 spec/endeca/refinement_spec.rb
primedia-endeca-0.9.21 spec/endeca/refinement_spec.rb
primedia-endeca-0.9.22 spec/endeca/refinement_spec.rb
primedia-endeca-0.9.7 spec/endeca/refinement_spec.rb
primedia-endeca-0.9.8 spec/endeca/refinement_spec.rb
primedia-endeca-0.9.9 spec/endeca/refinement_spec.rb