Module: FriendlyId::Test::Generic

Defined in:
lib/friendly_id/test.rb

Overview

Tests for any model that implements FriendlyId. Any test that tests model features should include this module.

Instance Method Summary (collapse)

Instance Method Details

- (Object) assert_validation_error



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/friendly_id/test.rb', line 52

def assert_validation_error
  if validation_exceptions
    assert_raise(*[validation_exceptions].flatten) do
      yield
    end
  else  # DataMapper does not raise Validation Errors
    i = yield
    if i.kind_of?(TrueClass) || i.kind_of?(FalseClass)
      assert !i
    else
      instance = i
      assert !instance.errors.empty?
    end
  end
end

- (Object) create_method

Raises:

  • (NotImplementedError)


40
41
42
# File 'lib/friendly_id/test.rb', line 40

def create_method
  raise NotImplementedError
end

- (Object) find_method

Raises:

  • (NotImplementedError)


36
37
38
# File 'lib/friendly_id/test.rb', line 36

def find_method
  raise NotImplementedError
end

- (Object) instance

Raises:

  • (NotImplementedError)


24
25
26
# File 'lib/friendly_id/test.rb', line 24

def instance
  raise NotImplementedError
end

- (Object) klass

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/friendly_id/test.rb', line 28

def klass
  raise NotImplementedError
end

- (Object) other_class

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/friendly_id/test.rb', line 32

def other_class
  raise NotImplementedError
end

- (Object) setup



16
17
18
# File 'lib/friendly_id/test.rb', line 16

def setup
  klass.send delete_all_method
end

- (Object) teardown



20
21
22
# File 'lib/friendly_id/test.rb', line 20

def teardown
  klass.send delete_all_method
end

- (Object) update_method

Raises:

  • (NotImplementedError)


44
45
46
# File 'lib/friendly_id/test.rb', line 44

def update_method
  raise NotImplementedError
end

- (Object) validation_exceptions



48
49
50
# File 'lib/friendly_id/test.rb', line 48

def validation_exceptions
  return RuntimeError
end