Sha256: cd755083a22ba481c2a95b95b0a644eb0ec78242e2e599795cee650ce70fdbd8

Contents?: true

Size: 1.36 KB

Versions: 65

Compression:

Stored size: 1.36 KB

Contents

require 'abstract_unit'
require "fixtures/person"
require "fixtures/street_address"

class BaseEqualityTest < Test::Unit::TestCase
  def setup
    @new = Person.new
    @one = Person.new(:id => 1)
    @two = Person.new(:id => 2)
    @street = StreetAddress.new(:id => 2)
  end

  def test_should_equal_self
    assert @new == @new, '@new == @new'
    assert @one == @one, '@one == @one'
  end

  def test_shouldnt_equal_new_resource
    assert @new != @one, '@new != @one'
    assert @one != @new, '@one != @new'
  end

  def test_shouldnt_equal_different_class
    assert @two != @street, 'person != street_address with same id'
    assert @street != @two, 'street_address != person with same id'
  end

  def test_eql_should_alias_equals_operator
    assert_equal @new == @new, @new.eql?(@new)
    assert_equal @new == @one, @new.eql?(@one)

    assert_equal @one == @one, @one.eql?(@one)
    assert_equal @one == @new, @one.eql?(@new)

    assert_equal @one == @street, @one.eql?(@street)
  end

  def test_hash_should_be_id_hash
    [@new, @one, @two, @street].each do |resource|
      assert_equal resource.id.hash, resource.hash
    end
  end

	def test_with_prefix_options
    assert_equal @one == @one, @one.eql?(@one)
    assert_equal @one == @one.dup, @one.eql?(@one.dup)
    new_one = @one.dup
    new_one.prefix_options = {:foo => 'bar'}
    assert_not_equal @one, new_one
	end

end

Version data entries

65 entries across 64 versions & 11 rubygems

Version Path
activeresource-2.3.18 test/base/equality_test.rb
activeresource_csi-2.3.5.p8 test/base/equality_test.rb
activeresource-2.3.17 test/base/equality_test.rb
activeresource_csi-2.3.5.p7 test/base/equality_test.rb
activeresource_csi-2.3.5.20130130071128 test/base/equality_test.rb
activeresource_csi-2.3.5.p6 test/base/equality_test.rb
activeresource-2.3.16 test/base/equality_test.rb
activeresource-2.3.15 test/base/equality_test.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/activeresource-2.3.14/test/base/equality_test.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/activeresource-2.3.12/test/base/equality_test.rb
activeresource-2.3.14 test/base/equality_test.rb
kajam-1.0.3.rc2 vendor/rails/activeresource/test/base/equality_test.rb
activeresource-2.3.12 test/base/equality_test.rb
radiant-1.0.0.rc2 vendor/rails/activeresource/test/base/equality_test.rb
radiant-1.0.0.rc1 vendor/rails/activeresource/test/base/equality_test.rb
webroar-0.5.0 src/admin_panel/vendor/rails/activeresource/test/base/equality_test.rb
activeresource-2.3.11 test/base/equality_test.rb
radiantcms-couchrest_model-0.2.4 vendor/rails/activeresource/test/base/equality_test.rb
radiantcms-couchrest_model-0.2.2 vendor/rails/activeresource/test/base/equality_test.rb
radiantcms-couchrest_model-0.2.1 vendor/rails/activeresource/test/base/equality_test.rb