Class: ActiveRecordTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/six-updater-web/vendor/plugins/active_scaffold/test/extensions/active_record_test.rb

Overview

require ‘test/model_stub’

Instance Method Summary collapse

Instance Method Details

#setupObject



5
6
7
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/extensions/active_record_test.rb', line 5

def setup
  @record = ModelStub.new
end

#test_to_labelObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/extensions/active_record_test.rb', line 9

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