Sha256: 9a98551a1384d6165168d4f0f2efd91addd5b0880035c4727edfd2f8e0c4f78a

Contents?: true

Size: 1.1 KB

Versions: 10

Compression:

Stored size: 1.1 KB

Contents

require './spec/spec_helper'

class PrimaryModel
  include FlexmlsApi::Primary
  attr_accessor :Primary, :id, :attributes
  def initialize(id, prime = false)
    @id = id
    @Primary = prime
    @attributes = {"Primary" => prime }
  end
end

describe FlexmlsApi::PrimaryArray do
  it "should give me the primary element" do
    a = PrimaryModel.new(1)
    b = PrimaryModel.new(2)
    c = PrimaryModel.new(3)
    d = PrimaryModel.new(4, true)
    e = PrimaryModel.new(5)
    tester = subject.class.new([d,e])
    tester.primary.should eq(d)
    tester = subject.class.new([a,b,c,d,e])
    tester.primary.should eq(d)
    # Note, it doesn't care if there is more than one primary, just returns first in the list.
    b.Primary = true
    tester.primary.should eq(b)
  end
  it "should return nil when there is no primary element" do
    a = PrimaryModel.new(1)
    b = PrimaryModel.new(2)
    c = PrimaryModel.new(3)
    d = PrimaryModel.new(4)
    e = PrimaryModel.new(5)
    tester = subject.class.new([])
    tester.primary.should be(nil)
    tester = subject.class.new([a,b,c,d,e])
    tester.primary.should be(nil)
  end
end


Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
spark_api-1.0.2 spec/unit/spark_api/primary_array_spec.rb~
spark_api-1.0.1 spec/unit/spark_api/primary_array_spec.rb~
spark_api-1.0.0 spec/unit/spark_api/primary_array_spec.rb~
flexmls_api-0.7.3 spec/unit/flexmls_api/primary_array_spec.rb
flexmls_api-0.7.5 spec/unit/flexmls_api/primary_array_spec.rb
flexmls_api-0.7.0 spec/unit/flexmls_api/primary_array_spec.rb
flexmls_api-0.6.5 spec/unit/flexmls_api/primary_array_spec.rb
flexmls_api-0.6.4 spec/unit/flexmls_api/primary_array_spec.rb
flexmls_api-0.4.5 spec/unit/flexmls_api/primary_array_spec.rb
flexmls_api-0.3.6 spec/unit/flexmls_api/primary_array_spec.rb