From a453b9a7d3144b35bbac87a56c5c2ae41ec48592 Mon Sep 17 00:00:00 2001
From: David Liu
Date: Wed, 27 Apr 2022 14:30:00 +0800
Subject: [PATCH 1/2] support rails "~> 6.0.4.8"
---
Gemfile.lock | 235 +++++++++++-------
lib/truncate_html.rb | 5 +-
spec/helpers/truncate_html_helper_spec.rb | 14 +-
spec/rails_root/Gemfile | 4 +-
spec/rails_root/Gemfile.lock | 235 +++++++++++-------
spec/rails_root/config/application.rb | 2 +
.../config/environments/development.rb | 17 --
.../config/environments/production.rb | 28 ---
spec/rails_root/config/environments/test.rb | 29 ---
spec/truncate_html/configuration_spec.rb | 6 +-
spec/truncate_html/html_string_spec.rb | 34 +--
spec/truncate_html/html_truncator_spec.rb | 73 +++---
spec/truncate_html/truncate_html_spec.rb | 2 +-
truncate_html.gemspec | 6 +-
14 files changed, 364 insertions(+), 326 deletions(-)
delete mode 100644 spec/rails_root/config/environments/development.rb
delete mode 100644 spec/rails_root/config/environments/production.rb
delete mode 100644 spec/rails_root/config/environments/test.rb
diff --git a/Gemfile.lock b/Gemfile.lock
index d46fc8c..78c69d2 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -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
diff --git a/lib/truncate_html.rb b/lib/truncate_html.rb
index 95b7923..59baf37 100644
--- a/lib/truncate_html.rb
+++ b/lib/truncate_html.rb
@@ -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
diff --git a/spec/helpers/truncate_html_helper_spec.rb b/spec/helpers/truncate_html_helper_spec.rb
index 79ea56d..a438122 100644
--- a/spec/helpers/truncate_html_helper_spec.rb
+++ b/spec/helpers/truncate_html_helper_spec.rb
@@ -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 = 'foo
'
- @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
diff --git a/spec/rails_root/Gemfile b/spec/rails_root/Gemfile
index 3a5e0c0..c6cdd01 100644
--- a/spec/rails_root/Gemfile
+++ b/spec/rails_root/Gemfile
@@ -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
diff --git a/spec/rails_root/Gemfile.lock b/spec/rails_root/Gemfile.lock
index dbb7086..3a1f9b2 100644
--- a/spec/rails_root/Gemfile.lock
+++ b/spec/rails_root/Gemfile.lock
@@ -1,99 +1,154 @@
GEM
remote: http://gemcutter.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)
+ mini_portile2 (2.8.0)
+ minitest (5.15.0)
+ nio4r (2.5.8)
+ nokogiri (1.13.4)
+ mini_portile2 (~> 2.8.0)
+ 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
DEPENDENCIES
- rails (~> 3.2.13)
- rspec-rails (~> 2.13)
+ rails (~> 6.0.4.8)
+ rspec-rails (~> 4.0.2)
+
+BUNDLED WITH
+ 2.3.10
diff --git a/spec/rails_root/config/application.rb b/spec/rails_root/config/application.rb
index 291d960..d2f67ef 100644
--- a/spec/rails_root/config/application.rb
+++ b/spec/rails_root/config/application.rb
@@ -10,5 +10,7 @@ class Application < Rails::Application
config.active_support.deprecation = :stderr
config.session_store :cookie_store, :key => "_myapp_session"
config.secret_token = "truncate_html_super_secret_dont_tell_anyone"
+ config.cache_classes = false
+ config.eager_load = false
end
end
diff --git a/spec/rails_root/config/environments/development.rb b/spec/rails_root/config/environments/development.rb
deleted file mode 100644
index 85c9a60..0000000
--- a/spec/rails_root/config/environments/development.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# Settings specified here will take precedence over those in config/environment.rb
-
-# In the development environment your application's code is reloaded on
-# every request. This slows down response time but is perfect for development
-# since you don't have to restart the webserver when you make code changes.
-config.cache_classes = false
-
-# Log error messages when you accidentally call methods on nil.
-config.whiny_nils = true
-
-# Show full error reports and disable caching
-config.action_controller.consider_all_requests_local = true
-config.action_view.debug_rjs = true
-config.action_controller.perform_caching = false
-
-# Don't care if the mailer can't send
-config.action_mailer.raise_delivery_errors = false
\ No newline at end of file
diff --git a/spec/rails_root/config/environments/production.rb b/spec/rails_root/config/environments/production.rb
deleted file mode 100644
index 27119d2..0000000
--- a/spec/rails_root/config/environments/production.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-# Settings specified here will take precedence over those in config/environment.rb
-
-# The production environment is meant for finished, "live" apps.
-# Code is not reloaded between requests
-config.cache_classes = true
-
-# Full error reports are disabled and caching is turned on
-config.action_controller.consider_all_requests_local = false
-config.action_controller.perform_caching = true
-config.action_view.cache_template_loading = true
-
-# See everything in the log (default is :info)
-# config.log_level = :debug
-
-# Use a different logger for distributed setups
-# config.logger = SyslogLogger.new
-
-# Use a different cache store in production
-# config.cache_store = :mem_cache_store
-
-# Enable serving of images, stylesheets, and javascripts from an asset server
-# config.action_controller.asset_host = "http://assets.example.com"
-
-# Disable delivery errors, bad email addresses will be ignored
-# config.action_mailer.raise_delivery_errors = false
-
-# Enable threaded mode
-# config.threadsafe!
\ No newline at end of file
diff --git a/spec/rails_root/config/environments/test.rb b/spec/rails_root/config/environments/test.rb
deleted file mode 100644
index 5cbfd65..0000000
--- a/spec/rails_root/config/environments/test.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-# Settings specified here will take precedence over those in config/environment.rb
-
-# The test environment is used exclusively to run your application's
-# test suite. You never need to work with it otherwise. Remember that
-# your test database is "scratch space" for the test suite and is wiped
-# and recreated between test runs. Don't rely on the data there!
-config.cache_classes = true
-
-# Log error messages when you accidentally call methods on nil.
-config.whiny_nils = true
-
-# Show full error reports and disable caching
-config.action_controller.consider_all_requests_local = true
-config.action_controller.perform_caching = false
-config.action_view.cache_template_loading = true
-
-# Disable request forgery protection in test environment
-config.action_controller.allow_forgery_protection = false
-
-# Tell Action Mailer not to deliver emails to the real world.
-# The :test delivery method accumulates sent emails in the
-# ActionMailer::Base.deliveries array.
-config.action_mailer.delivery_method = :test
-
-# Use SQL instead of Active Record's schema dumper when creating the test database.
-# This is necessary if your schema can't be completely dumped by the schema dumper,
-# like if you have constraints or database-specific column types
-# config.active_record.schema_format = :sql
-config.gem 'rspec-rails', :version => '>= 1.3.2', :lib => false unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec-rails'))
diff --git a/spec/truncate_html/configuration_spec.rb b/spec/truncate_html/configuration_spec.rb
index 7c503bb..1b82377 100644
--- a/spec/truncate_html/configuration_spec.rb
+++ b/spec/truncate_html/configuration_spec.rb
@@ -5,12 +5,12 @@
describe 'self.configure' do
it 'yields the configuration object' do
- lambda do
+ expect{
TruncateHtml.configure do |config|
- config.should be_kind_of(TruncateHtml::Configuration)
+ expect(config).to be_kind_of(TruncateHtml::Configuration)
throw :yay_it_yielded
end
- end.should throw_symbol(:yay_it_yielded)
+ }.to throw_symbol(:yay_it_yielded)
end
end
diff --git a/spec/truncate_html/html_string_spec.rb b/spec/truncate_html/html_string_spec.rb
index 064f87b..f174286 100644
--- a/spec/truncate_html/html_string_spec.rb
+++ b/spec/truncate_html/html_string_spec.rb
@@ -10,51 +10,51 @@ def html_string(original_string)
describe '#html_tokens' do
it 'returns each token in the string as an array element removing any consecutive whitespace from the string' do
html = 'Hi there
This is sweet!
squaremeter m²
'
- html_string(html).html_tokens.should == ['', 'Hi', ' ', 'there', '
', ' ', '', 'This', ' ', 'is', ' ', 'sweet!', '
',
- ' ', '', ' ', 'squaremeter', ' ', 'm²', ' ', '
']
+ expect(html_string(html).html_tokens).to eq(['', 'Hi', ' ', 'there', '
', ' ', '', 'This', ' ', 'is', ' ', 'sweet!', '
',
+ ' ', '', ' ', 'squaremeter', ' ', 'm²', ' ', '
'])
end
end
describe '#html_tag?' do
it 'returns false when the string parameter is not an html tag' do
- html_string('no tags').should_not be_html_tag
+ expect(html_string('no tags')).not_to be_html_tag
end
it 'returns true when the string parameter is an html tag' do
- html_string('
').should be_html_tag
- html_string('').should be_html_tag
+ expect(html_string('
')).to be_html_tag
+ expect(html_string('')).to be_html_tag
end
it 'is false for html comments' do
- html_string('').should_not be_html_tag
+ expect(html_string('')).not_to be_html_tag
end
end
describe '#open_tag?' do
it 'returns true if the tag is an open tag' do
- html_string('').should be_open_tag
+ expect(html_string('')).to be_open_tag
end
context 'the tag is an open tag, and has whitespace and html properties' do
it 'returns true if it has single quotes' do
- html_string(" ").should be_open_tag
+ expect(html_string(" ")).to be_open_tag
end
it 'returns true if it has double quotes' do
- html_string(' ').should be_open_tag
+ expect(html_string(' ')).to be_open_tag
end
end
it 'returns false if the tag is a close tag' do
- html_string('').should_not be_open_tag
+ expect(html_string('')).not_to be_open_tag
end
it 'returns false if the string is not an html tag' do
- html_string('foo bar').should_not be_open_tag
+ expect(html_string('foo bar')).not_to be_open_tag
end
it 'returns false if it is a and more text
"
expected_out = "I have a script and...
"
- truncate(input_html, :length => 23).should == expected_out
+ expect(truncate(input_html, :length => 23)).to eq(expected_out)
end
it 'in the middle of a link, truncates and closes the , and closes any remaining open tags' do
html = ''
expected = ''
- truncate(html, :length => 15).should == expected
+ expect(truncate(html, :length => 15)).to eq(expected)
end
%w(! @ # $ % ^ & * \( \) - _ + = [ ] { } \ | , . / ?).each do |char|
@@ -83,7 +83,7 @@ def truncate(html, opts = {})
it 'places the punctuation after the tag without any whitespace' do
html = "Look at this#{char} More words here
"
expected = "Look at this#{char}...
"
- truncate(html, :length => 19).should == expected
+ expect(truncate(html, :length => 19)).to eq(expected)
end
end
end
@@ -92,13 +92,13 @@ def truncate(html, opts = {})
it 'leaves a whitespace between the closing tag and the following word character' do
html = 'Look at this link for randomness
'
expected = 'Look at this link...
'
- truncate(html, :length => 21).should == expected
+ expect(truncate(html, :length => 21)).to eq(expected)
end
end
it 'handles multibyte characters and leaves them in the result' do
html = 'Look at our multibyte characters ā ž this link for randomness ā ž
'
- truncate(html, :length => html.length).should == html
+ expect(truncate(html, :length => html.length)).to eq(html)
end
#unusual, but just covering my ass
@@ -109,7 +109,7 @@ def truncate(html, opts = {})
This is ugly html.
END_HTML
- truncate(html, :length => 12).should == ' This is...
'
+ expect(truncate(html, :length => 12)).to eq(' This is...
')
end
%w(br hr img).each do |unpaired_tag|
@@ -119,8 +119,8 @@ def truncate(html, opts = {})
it "does not close the #{unpaired_tag} tag" do
html = "Some before. <#{unpaired_tag}>and some after
"
html_caps = "Some before. <#{unpaired_tag.capitalize}>and some after
"
- truncate(html, :length => 19).should == "Some before. <#{unpaired_tag}>and...
"
- truncate(html_caps, :length => 19).should == "Some before. <#{unpaired_tag.capitalize}>and...
"
+ expect(truncate(html, :length => 19)).to eq("Some before. <#{unpaired_tag}>and...
")
+ expect(truncate(html_caps, :length => 19)).to eq("Some before. <#{unpaired_tag.capitalize}>and...
")
end
end
@@ -128,8 +128,8 @@ def truncate(html, opts = {})
it "does not close the #{unpaired_tag} tag" do
html = "Some before. <#{unpaired_tag} />and some after
"
html_caps = "Some before. <#{unpaired_tag.capitalize} />and some after
"
- truncate(html, :length => 19).should == "Some before. <#{unpaired_tag} />and...
"
- truncate(html_caps, :length => 19).should == "Some before. <#{unpaired_tag.capitalize} />and...
"
+ expect(truncate(html, :length => 19)).to eq("Some before. <#{unpaired_tag} />and...
")
+ expect(truncate(html_caps, :length => 19)).to eq("Some before. <#{unpaired_tag.capitalize} />and...
")
end
end
@@ -147,61 +147,62 @@ def truncate(html, opts = {})
测试一下具体的truncatehtml功能。"
result = truncate(html, :omission => "", :length => 50)
- result.should include "“我现在使用的是中文的拼音。”
"
+ expect(result).to include "
“我现在使用的是中文的拼音。”
"
end
context 'when the break_token option is set as ' do
it 'does not truncate abnormally if the break_token is not present' do
- truncate('This is line one. This is line two.', :length => 30, :break_token => '').should == 'This is line one. This is...'
+ expect(truncate('This is line one. This is line two.', :length => 30, :break_token => '')).to eq('This is line one. This is...')
end
it 'does not truncate abnormally if the break_token is present, but beyond the length param' do
- truncate('This is line one. This is line two.', :length => 30, :break_token => '').should == 'This is line one. This is...'
+ expect(truncate('This is line one. This is line two.', :length => 30, :break_token => '')).to eq('This is line one. This is...')
end
it 'truncates before the length param if the break_token is before the token at "length"' do
- truncate('This is line one. This is line two.', :length => 30, :break_token => '').should == 'This is line one.'
+ expect(truncate('This is line one. This is line two.', :length => 30, :break_token => '')).to eq('This is line one.')
end
end
context 'when the break_token option is customized as a comment' do
it 'does not truncate abnormally if the break_token is not present' do
- truncate('This is line one. This is line two.', :length => 30, :break_token => '').should == 'This is line one. This is...'
+ expect(truncate('This is line one. This is line two.', :length => 30, :break_token => '')).to eq('This is line one. This is...')
end
it 'does not truncate abnormally if the break_token is present, but beyond the length param' do
- truncate('This is line one. This is line two.', :length => 30, :break_token => '').should == 'This is line one. This is...'
+ expect(truncate('This is line one. This is line two.', :length => 30, :break_token => '')).to eq('This is line one. This is...')
end
it 'truncates before the length param if the break_token is before the token at "length"' do
- truncate('This is line one. This is line two.', :length => 30, :break_token => '').should == 'This is line one.'
+ expect(truncate('This is line one. This is line two.', :length => 30, :break_token => '')).to eq('This is line one.')
end
end
context 'when the break_token option is customized as an html tag' do
it 'does not truncate abnormally if the break_token is not present' do
- truncate('This is line one. This is line two.', :length => 30, :break_token => '').should == 'This is line one. This is...'
+ expect(truncate('This is line one. This is line two.', :length => 30, :break_token => '')).to eq('This is line one. This is...')
end
it 'does not truncate abnormally if the break_token is present, but beyond the length param' do
- truncate('This is line one. This is line two.', :length => 30, :break_token => '').should == 'This is line one. This is...'
+ expect(truncate('This is line one. This is line two.', :length => 30, :break_token => '')).to eq('This is line one. This is...')
end
it 'truncates before the length param if the break_token is before the token at "length"' do
- truncate('This is line one. This is line two.', :length => 30, :break_token => '').should == 'This is line one.'
+ expect(truncate('This is line one. This is line two.', :length => 30, :break_token => '')).to eq('This is line one.')
end
end
context 'when the break_token option is customized as a word' do
it 'does not truncate abnormally if the break_token is not present' do
- truncate('This is line one. This is line two.', :length => 30, :break_token => 'foobar').should == 'This is line one. This is...'
+ expect(truncate('This is line one. This is line two.', :length => 30, :break_token => 'foobar')).to eq('This is line one. This is...')
end
it 'does not truncate abnormally if the break_token is present, but beyond the length param' do
- truncate('This is line one. This is line foobar two.', :length => 30, :break_token => 'foobar').should == 'This is line one. This is...'
+ expect(truncate('This is line one. This is line foobar two.', :length => 30, :break_token => 'foobar')).to eq('This is line one. This is...')
end
it 'truncates before the length param if the break_token is before the token at "length"' do
- truncate('This is line one. foobar This is line two.', :length => 30, :break_token => 'foobar').should == 'This is line one.'
+ expect(truncate('This is line one. foobar This is line two.', :length => 30, :break_token => 'foobar')).to eq('This is line one.')
end
end
context 'a string with comments' do
it 'does not duplicate comments (issue #32)' do
- truncate('
hello and goodbye
', length: 15).should ==
+ expect(truncate('hello and goodbye
', length: 15)).to eq(
'hello and ...
'
+ )
end
end
end
diff --git a/spec/truncate_html/truncate_html_spec.rb b/spec/truncate_html/truncate_html_spec.rb
index 7d19cec..4c0df1a 100644
--- a/spec/truncate_html/truncate_html_spec.rb
+++ b/spec/truncate_html/truncate_html_spec.rb
@@ -2,7 +2,7 @@
describe TruncateHtml do
it "includes itself in ActionController::Base" do
- ActionController::Base.should_receive(:helper).with(TruncateHtmlHelper)
+ expect(ActionController::Base).to receive(:helper).with(TruncateHtmlHelper)
load File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'truncate_html.rb'))
end
diff --git a/truncate_html.gemspec b/truncate_html.gemspec
index caf42f3..bd72d32 100644
--- a/truncate_html.gemspec
+++ b/truncate_html.gemspec
@@ -15,8 +15,8 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
- s.required_ruby_version = '>= 1.9'
+ s.required_ruby_version = '>= 2.7'
- s.add_development_dependency "rspec-rails", "~> 2.13"
- s.add_development_dependency "rails", "~> 3.2.13"
+ s.add_development_dependency "rspec-rails", "~> 4.0.2"
+ s.add_development_dependency "rails", "~> 6.0.4.8"
end
From e0a0565d6951ccb353c6a02ec81879bbdc364dbd Mon Sep 17 00:00:00 2001
From: David Liu
Date: Thu, 28 Apr 2022 10:45:49 +0800
Subject: [PATCH 2/2] accept more rails versions
---
Gemfile.lock | 4 ++--
truncate_html.gemspec | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Gemfile.lock b/Gemfile.lock
index 78c69d2..cfa6d8a 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -150,8 +150,8 @@ PLATFORMS
arm64-darwin-21
DEPENDENCIES
- rails (~> 6.0.4.8)
- rspec-rails (~> 4.0.2)
+ rails (>= 6.0.4.8)
+ rspec-rails (>= 4.0.2)
truncate_html!
BUNDLED WITH
diff --git a/truncate_html.gemspec b/truncate_html.gemspec
index bd72d32..b3d0e44 100644
--- a/truncate_html.gemspec
+++ b/truncate_html.gemspec
@@ -17,6 +17,6 @@ Gem::Specification.new do |s|
s.required_ruby_version = '>= 2.7'
- s.add_development_dependency "rspec-rails", "~> 4.0.2"
- s.add_development_dependency "rails", "~> 6.0.4.8"
+ s.add_development_dependency "rspec-rails", ">= 4.0.2"
+ s.add_development_dependency "rails", ">= 6.0.4.8"
end