Sha256: 790df9e5d493e7460c070e0c8ed5482603d925d89e1e2e2a43d13f2d6fb2f053

Contents?: true

Size: 704 Bytes

Versions: 2

Compression:

Stored size: 704 Bytes

Contents

require 'spec_helper'

class DummyClass
  include ActiveModel::Model
  include ActiveModel::Validations
  include ActiveRecord::Callbacks
  include Redde::Sluggable

  attr_accessor :id, :title, :slug

  def id
    3
  end

  def title
    'hey ho'
  end
end


class DummyClassWithTitle < DummyClass
  include Redde::Sluggable
  TITLE_SYMBOL = :name

  def name
    'super name'
  end
end

describe Redde::Sluggable do
  let(:title) { DummyClass.new }
  let(:name) { DummyClassWithTitle.new }

  it 'sets slug for model with title' do
    title.valid?
    expect(title.slug).to eq 'hey-ho'
  end

  it 'sets slug for model with name' do
    name.valid?
    expect(name.slug).to eq 'super-name'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
redde-0.1.10 spec/models/sluggable_spec.rb
redde-0.1.9 spec/models/sluggable_spec.rb