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

#assert_validation_errorObject



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

#create_methodObject

Raises:

  • (NotImplementedError)


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

def create_method
  raise NotImplementedError
end

#find_methodObject

Raises:

  • (NotImplementedError)


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

def find_method
  raise NotImplementedError
end

#instanceObject

Raises:

  • (NotImplementedError)


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

def instance
  raise NotImplementedError
end

#klassObject

Raises:

  • (NotImplementedError)


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

def klass
  raise NotImplementedError
end

#other_classObject

Raises:

  • (NotImplementedError)


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

def other_class
  raise NotImplementedError
end

#setupObject



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

def setup
  klass.send delete_all_method
end

#teardownObject



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

def teardown
  klass.send delete_all_method
end

#update_methodObject

Raises:

  • (NotImplementedError)


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

def update_method
  raise NotImplementedError
end

#validation_exceptionsObject



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

def validation_exceptions
  return RuntimeError
end