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
- #assert_validation_error ⇒ Object
- #create_method ⇒ Object
- #find_method ⇒ Object
- #instance ⇒ Object
- #klass ⇒ Object
- #other_class ⇒ Object
- #setup ⇒ Object
- #teardown ⇒ Object
- #update_method ⇒ Object
- #validation_exceptions ⇒ Object
Instance Method Details
#assert_validation_error ⇒ Object
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_method ⇒ Object
40 41 42 |
# File 'lib/friendly_id/test.rb', line 40 def create_method raise NotImplementedError end |
#find_method ⇒ Object
36 37 38 |
# File 'lib/friendly_id/test.rb', line 36 def find_method raise NotImplementedError end |
#instance ⇒ Object
24 25 26 |
# File 'lib/friendly_id/test.rb', line 24 def instance raise NotImplementedError end |
#klass ⇒ Object
28 29 30 |
# File 'lib/friendly_id/test.rb', line 28 def klass raise NotImplementedError end |
#other_class ⇒ Object
32 33 34 |
# File 'lib/friendly_id/test.rb', line 32 def other_class raise NotImplementedError end |
#setup ⇒ Object
16 17 18 |
# File 'lib/friendly_id/test.rb', line 16 def setup klass.send delete_all_method end |
#teardown ⇒ Object
20 21 22 |
# File 'lib/friendly_id/test.rb', line 20 def teardown klass.send delete_all_method end |
#update_method ⇒ Object
44 45 46 |
# File 'lib/friendly_id/test.rb', line 44 def update_method raise NotImplementedError end |
#validation_exceptions ⇒ Object
48 49 50 |
# File 'lib/friendly_id/test.rb', line 48 def validation_exceptions return RuntimeError end |