Sha256: df0c1dda14a1bb84faa8f8e6ba9367836cf062b4ea4c2fcecf473707fc37d1af

Contents?: true

Size: 713 Bytes

Versions: 1

Compression:

Stored size: 713 Bytes

Contents

# Allow declarative test definitions inside modules.
class Module
  def test(name, &block)
    define_method("test_#{name.gsub(/[^a-z0-9]/i, "_")}".to_sym, &block)
  end
end

# Use this to create models in your tests, rather than define
# a bunch of static models. This allows for much more
# flexbile and granular tests.
#
# @name The table name - make sure it is unique.
# @args The args that will be passed to +has_friendly_id+.
# @block The block that will be passed to +create_table+.
def make_model(name, *args, &block)
  ActiveRecord::Migration.create_table(name, &block)
  Class.new(ActiveRecord::Base) do
    self.table_name = name
    has_friendly_id(*args)
  end
end

require "friendly_id/test/generic"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
friendly_id4-4.0.0.pre lib/friendly_id/test.rb