Sha256: 775d3944142b57d48899c7411c9264fea9a2b16da39288697572402ca0af107f

Contents?: true

Size: 1.67 KB

Versions: 41

Compression:

Stored size: 1.67 KB

Contents

require 'spec_helper'

describe Locomotive::Steam::Liquid::Filters::Text do

  include Locomotive::Steam::Liquid::Filters::Text

  let(:services)  { Locomotive::Steam::Services.build_instance }
  let(:context)   { instance_double('Context', registers: { services: services }) }

  before { @context = context }

  it 'transforms a textile input into HTML' do
    expect(textile('This is *my* text.')).to eq "<p>This is <strong>my</strong> text.</p>"
  end

  it 'transforms a markdown input into HTML' do
    expect(markdown('# My title')).to eq "<h1>My title</h1>\n"
  end

  it 'underscores an input' do
    expect(underscore('foo')).to eq 'foo'
    expect(underscore('home page')).to eq 'home_page'
    expect(underscore('My foo Bar')).to eq 'my_foo_bar'
    expect(underscore('foo/bar')).to eq 'foo_bar'
    expect(underscore('foo/bar/index')).to eq 'foo_bar_index'
  end

  it 'dasherizes an input' do
    expect(dasherize('foo')).to eq 'foo'
    expect(dasherize('foo_bar')).to eq 'foo-bar'
    expect(dasherize('foo/bar')).to eq 'foo-bar'
    expect(dasherize('foo/bar/index')).to eq 'foo-bar-index'
  end

  it 'concats strings' do
    expect(concat('foo', 'bar')).to eq 'foobar'
    expect(concat('hello', 'foo', 'bar')).to eq 'hellofoobar'
  end

  it 'encodes an input' do
    expect(encode('http:://www.example.com?key=hello world')).to eq 'http%3A%3A%2F%2Fwww.example.com%3Fkey%3Dhello+world'
  end

  it 'replaces \n by <br/>' do
    expect(multi_line("hello\nworld")).to eq 'hello<br/>world'
  end

  it 'right justifies and padds a string' do
    expect(rjust('42', 4, '.')).to eq '..42'
  end

  it 'left justifies and padds a string' do
    expect(ljust('42', 4, '.')).to eq '42..'
  end

end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
locomotivecms_steam-1.5.0.rc0 spec/unit/liquid/filters/text_spec.rb
locomotivecms_steam-1.5.0.beta3 spec/unit/liquid/filters/text_spec.rb
locomotivecms_steam-1.5.0.beta2 spec/unit/liquid/filters/text_spec.rb
locomotivecms_steam-1.5.0.beta1 spec/unit/liquid/filters/text_spec.rb
locomotivecms_steam-1.4.1 spec/unit/liquid/filters/text_spec.rb
locomotivecms_steam-1.4.0 spec/unit/liquid/filters/text_spec.rb
locomotivecms_steam-1.4.0.rc2 spec/unit/liquid/filters/text_spec.rb
locomotivecms_steam-1.4.0.rc1 spec/unit/liquid/filters/text_spec.rb
locomotivecms_steam-1.4.0.pre.rc.1 spec/unit/liquid/filters/text_spec.rb
locomotivecms_steam-1.3.0 spec/unit/liquid/filters/text_spec.rb
locomotivecms_steam-1.3.0.rc2 spec/unit/liquid/filters/text_spec.rb
locomotivecms_steam-1.1.2 spec/unit/liquid/filters/text_spec.rb
locomotivecms_steam-1.2.1 spec/unit/liquid/filters/text_spec.rb
locomotivecms_steam-1.3.0.rc1 spec/unit/liquid/filters/text_spec.rb
locomotivecms_steam-1.2.0 spec/unit/liquid/filters/text_spec.rb
locomotivecms_steam-1.2.0.rc3 spec/unit/liquid/filters/text_spec.rb
locomotivecms_steam-1.2.0.rc2 spec/unit/liquid/filters/text_spec.rb
locomotivecms_steam-1.2.0.rc1 spec/unit/liquid/filters/text_spec.rb
locomotivecms_steam-1.2.0.beta1 spec/unit/liquid/filters/text_spec.rb
locomotivecms_steam-1.1.1 spec/unit/liquid/filters/text_spec.rb