Sha256: cb0e57792cff8024cc1ded12dcfce024bda43d232ba700fd929b8b859f50a8b5

Contents?: true

Size: 989 Bytes

Versions: 5

Compression:

Stored size: 989 Bytes

Contents

# typed: false
# frozen_string_literal: true

require './spec/spec_setup'
require 'lib/frontman/helpers/link_helper'

describe LinkHelper do
  subject do
    Class.new do
      include LinkHelper
    end.new
  end

  before(:each) do
    subject.reset_ids_generation
  end

  it 'should properly slugify a string' do
    expect(subject.slugify('Hello world')).to eq 'hello-world'
  end

  it 'should generate an id' do
    expect(subject.generate_id('Hello world')).to eq 'hello-world'
  end

  it 'should append numbers if an id is created multiple times' do
    expect(subject.generate_id('Hello world')).to eq 'hello-world'
    expect(subject.generate_id('Hello world')).to eq 'hello-world-2'
  end

  it 'should reset appended numbers' do
    expect(subject.generate_id('Hello world')).to eq 'hello-world'
    expect(subject.generate_id('Hello world')).to eq 'hello-world-2'
    subject.reset_ids_generation
    expect(subject.generate_id('Hello world')).to eq 'hello-world'
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
frontman-ssg-0.1.1 spec/frontman/helpers/link_helper_spec.rb
frontman-ssg-0.1.0 spec/frontman/helpers/link_helper_spec.rb
frontman-ssg-0.0.4 spec/frontman/helpers/link_helper_spec.rb
frontman-ssg-0.0.3 spec/frontman/helpers/link_helper_spec.rb
frontman-ssg-0.0.2 spec/frontman/helpers/link_helper_spec.rb