Sha256: 9ae14a7c240b835f9102f953a0cc548dcbbe391ec511b06fa9f24a5cdb463f5c

Contents?: true

Size: 822 Bytes

Versions: 221

Compression:

Stored size: 822 Bytes

Contents

require File.join(File.dirname(__FILE__), '../test_helper.rb')
#require 'test/model_stub'

class ActiveRecordTest < Test::Unit::TestCase
  def setup
    @record = ModelStub.new
  end

  def test_to_label
    # without anything defined, it'll use the to_s method (e.g. #<ModelStub:0xb7379300>)
    assert_match /^#<[a-z]+:0x[0-9a-f]+>$/i, @record.to_label

    class << @record
      def to_s
        'to_s'
      end
    end

    assert_equal 'to_s', @record.to_label

    class << @record
      def title
        'title'
      end
    end

    assert_equal 'title', @record.to_label

    class << @record
      def label
        'label'
      end
    end

    assert_equal 'label', @record.to_label

    class << @record
      def name
        'name'
      end
    end

    assert_equal 'name', @record.to_label
  end
end

Version data entries

221 entries across 221 versions & 8 rubygems

Version Path
active_scaffold_vho-4.0.0 test/extensions/active_record_test.rb
active_scaffold_vho-3.2.14 test/extensions/active_record_test.rb
active_scaffold_vho-3.2.13 test/extensions/active_record_test.rb
active_scaffold-sequel-0.8.0 test/extensions/active_record_test.rb
active_scaffold-sequel-0.7.1 test/extensions/active_record_test.rb
active_scaffold_vho-3.2.12 test/extensions/active_record_test.rb
active_scaffold_vho-3.2.11 test/extensions/active_record_test.rb
active_scaffold_vho-3.2.10 test/extensions/active_record_test.rb
active_scaffold_vho-3.2.9 test/extensions/active_record_test.rb
active_scaffold_vho-3.2.8 test/extensions/active_record_test.rb
active_scaffold_vho-3.2.7 test/extensions/active_record_test.rb
active_scaffold_vho-3.2.6 test/extensions/active_record_test.rb
active_scaffold_vho-3.2.5 test/extensions/active_record_test.rb
active_scaffold_vho-3.2.4 test/extensions/active_record_test.rb
active_scaffold_vho-3.2.3 test/extensions/active_record_test.rb
active_scaffold_vho-3.2.2 test/extensions/active_record_test.rb
active_scaffold_vho-3.2.1 test/extensions/active_record_test.rb
active_scaffold-sequel-0.7.0 test/extensions/active_record_test.rb
active_scaffold_vho-3.2.0 test/extensions/active_record_test.rb
active_scaffold_vho-3.0.31 test/extensions/active_record_test.rb