Sha256: 163af899551392e839addac63a147f081b1f4e9a2392453d356ed2358cc6aa33

Contents?: true

Size: 749 Bytes

Versions: 46

Compression:

Stored size: 749 Bytes

Contents

require 'test_helper'

class ActiveRecordTest < MiniTest::Test
  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

46 entries across 46 versions & 1 rubygems

Version Path
active_scaffold-3.4.43 test/extensions/active_record_test.rb
active_scaffold-3.4.42 test/extensions/active_record_test.rb
active_scaffold-3.4.41.1 test/extensions/active_record_test.rb
active_scaffold-3.4.41 test/extensions/active_record_test.rb
active_scaffold-3.4.40 test/extensions/active_record_test.rb
active_scaffold-3.4.39 test/extensions/active_record_test.rb
active_scaffold-3.4.38 test/extensions/active_record_test.rb
active_scaffold-3.4.37 test/extensions/active_record_test.rb
active_scaffold-3.4.36 test/extensions/active_record_test.rb
active_scaffold-3.4.35 test/extensions/active_record_test.rb
active_scaffold-3.4.34 test/extensions/active_record_test.rb
active_scaffold-3.4.33 test/extensions/active_record_test.rb
active_scaffold-3.4.32 test/extensions/active_record_test.rb
active_scaffold-3.4.31 test/extensions/active_record_test.rb
active_scaffold-3.4.30 test/extensions/active_record_test.rb
active_scaffold-3.4.29 test/extensions/active_record_test.rb
active_scaffold-3.4.28 test/extensions/active_record_test.rb
active_scaffold-3.4.27 test/extensions/active_record_test.rb
active_scaffold-3.4.26 test/extensions/active_record_test.rb
active_scaffold-3.4.25 test/extensions/active_record_test.rb