Sha256: acb5b54aa2cb9af7983e00aaaa7bce18a1a8b6f2de92ec2917b5b1b7b06586b9

Contents?: true

Size: 1.18 KB

Versions: 7

Compression:

Stored size: 1.18 KB

Contents

require File.join(File.dirname(__FILE__), '..', 'spec_helper')

include TruncateHtmlHelper

class Truncator
  include TruncateHtmlHelper
end

describe TruncateHtmlHelper do

  def truncator
    @truncator ||= Truncator.new
  end

  it 'is included in ActionView::Base' do
    ActionView::Base.included_modules.should include(TruncateHtmlHelper)
  end

  before(:each) do
    @original_html = '<p>foo</p>'
    @original_html.stub!(:html_safe).and_return(@original_html)
  end

  it 'creates an instance of HtmlTruncator and calls truncate on it' do
    truncator = double(truncate: @original_html)
    TruncateHtml::HtmlTruncator.should_receive(:new).and_return(truncator)
    truncator.truncate_html(@original_html)
  end

  it 'calls truncate on the HtmlTruncator object' do
    truncator = double(truncate: @original_html)
    TruncateHtml::HtmlTruncator.stub!(:new).and_return(truncator)
    truncator.should_receive(:truncate).and_return(@original_html)
    truncator.truncate_html('foo')
  end

  context 'the input html is nil' do
    it 'returns an empty string' do
      truncator.truncate_html(nil).should be_empty
      truncator.truncate_html(nil).should be_kind_of(String)
    end
  end

end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
solidus_backend-1.0.0.pre3 vendor/bundle/gems/truncate_html-0.9.2/spec/helpers/truncate_html_helper_spec.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/truncate_html-0.9.2/spec/helpers/truncate_html_helper_spec.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/truncate_html-0.9.2/spec/helpers/truncate_html_helper_spec.rb
truncate_html-0.9.3 spec/helpers/truncate_html_helper_spec.rb
truncate_html_chinese-0.1.0 spec/helpers/truncate_html_helper_spec.rb
truncate_html-0.9.2 spec/helpers/truncate_html_helper_spec.rb
truncate_html-0.9.1 spec/helpers/truncate_html_helper_spec.rb