Sha256: a3d0fd11bcdfe6a8f3a493ce123a7b29e1be0fec2eb77c8842b9fbbc769ac2e2

Contents?: true

Size: 1.09 KB

Versions: 11

Compression:

Stored size: 1.09 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

# Test vs the latest changes in the lib file, not the installed gem version
require File.expand_path(File.dirname(__FILE__) + '/../lib/editorial_logic')

describe "EditorialLogic" do

  before :all do
    class Foo
      include Mongoid::Document
      include EditorialLogic::Base
      has_slug :desired_slug
      attr_accessor :desired_slug
      attr_accessor :slug
    end
  end

  it 'adds the has_slug method to a class' do
    Foo.respond_to?(:has_slug).should be_true
  end

  describe 'slug' do

    it 'converts non-alpha-numeric characters' do
      Foo.new(:desired_slug => 'dollars$and$cents').make_slug.should == 'dollars-and-cents'
    end

    it 'converts runs of hyphens' do
      Foo.new(:desired_slug => 'dollars$$and$$cents').make_slug.should == 'dollars-and-cents'
    end

    it 'removes trailing hyphens' do
      Foo.new(:desired_slug => 'dollars$').make_slug.should == 'dollars'
    end

    it 'removes leading hyphens' do
      Foo.new(:desired_slug => '$dollars').make_slug.should == 'dollars'
    end

  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
editorial_logic-1.3.3 spec/editorial_logic_spec.rb
editorial_logic-1.3.2 spec/editorial_logic_spec.rb
editorial_logic-1.3.1 spec/editorial_logic_spec.rb
editorial_logic-1.3.0 spec/editorial_logic_spec.rb
editorial_logic-1.1.6 spec/editorial_logic_spec.rb
editorial_logic-1.1.5 spec/editorial_logic_spec.rb
editorial_logic-1.1.4 spec/editorial_logic_spec.rb
editorial_logic-1.1.3 spec/editorial_logic_spec.rb
editorial_logic-1.1.2 spec/editorial_logic_spec.rb
editorial_logic-1.1.1 spec/editorial_logic_spec.rb
editorial_logic-1.1.0 spec/editorial_logic_spec.rb