Module: FriendlyId::ShouldaMacros
- Defined in:
- lib/friendly_id/shoulda_macros.rb
Overview
A Shoulda macros for testing models using FriendlyId.
Class Method Summary collapse
-
.should_have_friendly_id(column, options = {}) ⇒ Object
Ensure that a model is using FriendlyId.
Class Method Details
.should_have_friendly_id(column, options = {}) ⇒ Object
Ensure that a model is using FriendlyId.
8 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 |
# File 'lib/friendly_id/shoulda_macros.rb', line 8 def self.should_have_friendly_id(column, = {}) .assert_valid_keys(:use_slug) klass = self.model_class should "have friendly id for #{method}" do assert_respond_to klass, :friendly_id_options, "#{klass} does not respond to friendly_id_options" assert_equal column, klass.[:method] end if [:use_slug] should "include/extend friendly_id's sluggable modules" do assert klass.extended_by.include?(FriendlyId::SluggableClassMethods), "#{klass} does not extend FriendlyId::SluggableClassMethods" assert klass.include?(FriendlyId::SluggableInstanceMethods), "#{klass} not include FriendlyId::SluggableInstanceMethods" end else should "include/extend friendly_id's non-sluggable modules" do assert klass.extended_by.include?(FriendlyId::NonSluggableClassMethods), "#{klass} does not extend FriendlyId::NonSluggableClassMethods" assert klass.include?(FriendlyId::NonSluggableInstanceMethods), "#{klass} not include FriendlyId::NonSluggableInstanceMethods" end end end |