Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
235 changes: 144 additions & 91 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,100 +6,153 @@ PATH
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.2.13)
actionpack (= 3.2.13)
mail (~> 2.5.3)
actionpack (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.5)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.2.1)
activemodel (3.2.13)
activesupport (= 3.2.13)
builder (~> 3.0.0)
activerecord (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
activesupport (3.2.13)
i18n (= 0.6.1)
multi_json (~> 1.0)
arel (3.0.2)
builder (3.0.4)
diff-lcs (1.2.2)
erubis (2.7.0)
hike (1.2.1)
i18n (0.6.1)
journey (1.0.4)
json (1.7.7)
mail (2.5.3)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.22)
multi_json (1.7.2)
polyglot (0.3.3)
rack (1.4.5)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.3)
rack
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.13)
actionmailer (= 3.2.13)
actionpack (= 3.2.13)
activerecord (= 3.2.13)
activeresource (= 3.2.13)
activesupport (= 3.2.13)
bundler (~> 1.0)
railties (= 3.2.13)
railties (3.2.13)
actionpack (= 3.2.13)
activesupport (= 3.2.13)
rack-ssl (~> 1.3.2)
actioncable (6.0.4.8)
actionpack (= 6.0.4.8)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.0.4.8)
actionpack (= 6.0.4.8)
activejob (= 6.0.4.8)
activerecord (= 6.0.4.8)
activestorage (= 6.0.4.8)
activesupport (= 6.0.4.8)
mail (>= 2.7.1)
actionmailer (6.0.4.8)
actionpack (= 6.0.4.8)
actionview (= 6.0.4.8)
activejob (= 6.0.4.8)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.0.4.8)
actionview (= 6.0.4.8)
activesupport (= 6.0.4.8)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.4.8)
actionpack (= 6.0.4.8)
activerecord (= 6.0.4.8)
activestorage (= 6.0.4.8)
activesupport (= 6.0.4.8)
nokogiri (>= 1.8.5)
actionview (6.0.4.8)
activesupport (= 6.0.4.8)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.0.4.8)
activesupport (= 6.0.4.8)
globalid (>= 0.3.6)
activemodel (6.0.4.8)
activesupport (= 6.0.4.8)
activerecord (6.0.4.8)
activemodel (= 6.0.4.8)
activesupport (= 6.0.4.8)
activestorage (6.0.4.8)
actionpack (= 6.0.4.8)
activejob (= 6.0.4.8)
activerecord (= 6.0.4.8)
marcel (~> 1.0.0)
activesupport (6.0.4.8)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
builder (3.2.4)
concurrent-ruby (1.1.10)
crass (1.0.6)
diff-lcs (1.5.0)
erubi (1.10.0)
globalid (1.0.0)
activesupport (>= 5.0)
i18n (1.10.0)
concurrent-ruby (~> 1.0)
loofah (2.16.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (1.0.2)
method_source (1.0.0)
mini_mime (1.1.2)
minitest (5.15.0)
nio4r (2.5.8)
nokogiri (1.13.4-arm64-darwin)
racc (~> 1.4)
racc (1.6.0)
rack (2.2.3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.0.4.8)
actioncable (= 6.0.4.8)
actionmailbox (= 6.0.4.8)
actionmailer (= 6.0.4.8)
actionpack (= 6.0.4.8)
actiontext (= 6.0.4.8)
actionview (= 6.0.4.8)
activejob (= 6.0.4.8)
activemodel (= 6.0.4.8)
activerecord (= 6.0.4.8)
activestorage (= 6.0.4.8)
activesupport (= 6.0.4.8)
bundler (>= 1.3.0)
railties (= 6.0.4.8)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.2)
loofah (~> 2.3)
railties (6.0.4.8)
actionpack (= 6.0.4.8)
activesupport (= 6.0.4.8)
method_source
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.0.4)
rdoc (3.12.2)
json (~> 1.4)
rspec-core (2.13.1)
rspec-expectations (2.13.0)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.13.0)
rspec-rails (2.13.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 2.13.0)
rspec-expectations (~> 2.13.0)
rspec-mocks (~> 2.13.0)
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
thor (0.18.1)
tilt (1.3.6)
treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.37)
thor (>= 0.20.3, < 2.0)
rake (13.0.6)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-expectations (3.11.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-mocks (3.11.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-rails (4.0.2)
actionpack (>= 4.2)
activesupport (>= 4.2)
railties (>= 4.2)
rspec-core (~> 3.10)
rspec-expectations (~> 3.10)
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.11.0)
sprockets (4.0.3)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.4.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
thor (1.2.1)
thread_safe (0.3.6)
tzinfo (1.2.9)
thread_safe (~> 0.1)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.5.4)

PLATFORMS
ruby
arm64-darwin-21

DEPENDENCIES
rails (~> 3.2.13)
rspec-rails (~> 2.13)
rails (>= 6.0.4.8)
rspec-rails (>= 4.0.2)
truncate_html!

BUNDLED WITH
2.3.10
5 changes: 3 additions & 2 deletions lib/truncate_html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
config.word_boundary = /\S/
end


ActionController::Base.helper(TruncateHtmlHelper) if defined?(ActionController)
ActiveSupport.on_load(:action_controller_base) do
helper(TruncateHtmlHelper)
end
14 changes: 7 additions & 7 deletions spec/helpers/truncate_html_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@ def truncator
end

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

before(:each) do
@original_html = '<p>foo</p>'
@original_html.stub!(:html_safe).and_return(@original_html)
allow(@original_html).to receive(: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)
expect(TruncateHtml::HtmlTruncator).to 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)
allow(TruncateHtml::HtmlTruncator).to receive(:new).and_return(truncator)
expect(truncator).to 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)
expect(truncator.truncate_html(nil)).to be_empty
expect(truncator.truncate_html(nil)).to be_kind_of(String)
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/rails_root/Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Edit this Gemfile to bundle your application's dependencies.
source 'http://gemcutter.org'
group :development, :test do
gem "rails", "~> 3.2.13"
gem 'rspec-rails', '~> 2.13'
gem "rails", '~> 6.0.4.8'
gem 'rspec-rails', '~> 4.0.2'
end
Loading