Sha256: b027c7a441c8b64aec9fe93d0db13cbc11ba73e36f300dc75162a10d32c2f9fa

Contents?: true

Size: 750 Bytes

Versions: 7

Compression:

Stored size: 750 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

7 entries across 7 versions & 1 rubygems

Version Path
active_scaffold-3.5.5 test/extensions/active_record_test.rb
active_scaffold-3.6.0.pre test/extensions/active_record_test.rb
active_scaffold-3.5.4 test/extensions/active_record_test.rb
active_scaffold-3.5.3 test/extensions/active_record_test.rb
active_scaffold-3.5.2 test/extensions/active_record_test.rb
active_scaffold-3.5.1 test/extensions/active_record_test.rb
active_scaffold-3.5.0 test/extensions/active_record_test.rb