Sha256: 98afb96240f2558d1cd6679a60d04c1f227668f3d52e120ad2e5ca4d0a21eb87

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

# encoding: UTF-8

require 'spec_helper'

describe "String to slug" do
  it 'string process 1' do
    'hello world!'.to_slug_param(delimiter: '_').should eq 'hello_world'
  end

  it 'string process 2' do
    :hello_world!.to_s.to_slug_param(delimiter: '_').should eq 'hello_world'
  end

  it 'string process 3' do
    "hello !      world".to_slug_param(delimiter: '_').should eq 'hello_world'
  end

  it 'string process 4' do
    "HELLO  $!= WorlD".to_slug_param(delimiter: '_').should eq 'hello_world'
  end

  it 'string process 5' do
    "HELLO---WorlD".to_slug_param(delimiter: '_').should eq 'hello_world'
  end

  it "should work with Controller Name" do
    ctrl = PagesController.new
    ctrl.controller_path
    ctrl.controller_path.to_slug_param(delimiter: '_').should eq 'pages'
  end

  it "should work with Nested Controller Name" do
    class Admin::PagesController < ApplicationController; end
    ctrl = Admin::PagesController.new
    ctrl.controller_path

    ctrl.controller_path.to_slug_param(delimiter: '_').should eq 'admin_pages'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
the_role-2.5.1 spec/dummy_app/spec/models/param_process_spec.rb
the_role-2.5 spec/dummy_app/spec/models/param_process_spec.rb