premailer-rails 1.9.7 → 1.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +4 -0
  3. data/.travis.yml +3 -2
  4. data/CHANGELOG.md +26 -0
  5. data/Gemfile +8 -4
  6. data/README.md +21 -29
  7. data/VERSION +1 -1
  8. data/lib/premailer/rails/css_helper.rb +30 -11
  9. data/lib/premailer/rails/css_loaders/asset_pipeline_loader.rb +12 -11
  10. data/lib/premailer/rails/css_loaders/network_loader.rb +1 -1
  11. data/lib/premailer/rails/css_loaders.rb +0 -1
  12. data/lib/premailer/rails/customized_premailer.rb +4 -4
  13. data/lib/premailer/rails/hook.rb +2 -6
  14. data/lib/premailer/rails.rb +2 -1
  15. data/premailer-rails.gemspec +1 -2
  16. data/spec/integration/css_helper_spec.rb +170 -139
  17. data/spec/integration/delivery_spec.rb +13 -0
  18. data/spec/integration/hook_spec.rb +36 -11
  19. data/spec/rails_app/app/assets/config/manifest.js +3 -0
  20. data/spec/rails_app/app/assets/stylesheets/application.css +3 -0
  21. data/spec/rails_app/app/mailers/application_mailer.rb +4 -0
  22. data/spec/rails_app/app/mailers/welcome_mailer.rb +6 -0
  23. data/spec/rails_app/app/views/layouts/mailer.html.erb +11 -0
  24. data/spec/rails_app/app/views/welcome_mailer/welcome_email.html.erb +1 -0
  25. data/spec/rails_app/config/application.rb +13 -0
  26. data/spec/rails_app/config/boot.rb +5 -0
  27. data/spec/rails_app/config/environment.rb +2 -0
  28. data/spec/rails_app/config/environments/test.rb +10 -0
  29. data/spec/rails_app/config/initializers/assets.rb +1 -0
  30. data/spec/rails_app/config/routes.rb +3 -0
  31. data/spec/rails_app/config.ru +5 -0
  32. data/spec/rails_app/log/.keep +0 -0
  33. data/spec/rails_app/tmp/.keep +0 -0
  34. data/spec/spec_helper.rb +3 -8
  35. data/spec/support/fixtures/message.rb +40 -0
  36. data/spec/unit/css_loaders/network_loader_spec.rb +1 -1
  37. data/spec/unit/customized_premailer_spec.rb +32 -40
  38. metadata +35 -31
  39. data/lib/premailer/rails/css_loaders/cache_loader.rb +0 -29
  40. data/spec/integration/hook_registration_spec.rb +0 -11
  41. data/spec/support/stubs/action_mailer.rb +0 -5
  42. data/spec/support/stubs/rails.rb +0 -51
@@ -1,51 +1,43 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Premailer::Rails::CustomizedPremailer do
4
- [ :nokogiri, :hpricot ].each do |adapter|
5
- next if adapter == :hpricot and RUBY_PLATFORM == 'java'
4
+ describe '#to_plain_text' do
5
+ it 'includes the text from the HTML part' do
6
+ premailer =
7
+ Premailer::Rails::CustomizedPremailer
8
+ .new(Fixtures::Message::HTML_PART)
9
+ expect(premailer.to_plain_text.gsub(/\s/, ' ').strip).to \
10
+ eq(Fixtures::Message::TEXT_PART.gsub(/\s/, ' ').strip)
11
+ end
12
+ end
6
13
 
7
- context "when adapter is #{adapter}" do
8
- before { allow(Premailer::Adapter).to receive(:use).and_return(adapter) }
14
+ describe '#to_inline_css' do
15
+ let(:regex) { %r{<p style=("|')color: ?red;?\1>} }
9
16
 
10
- describe '#to_plain_text' do
11
- it 'includes the text from the HTML part' do
12
- premailer =
13
- Premailer::Rails::CustomizedPremailer
14
- .new(Fixtures::Message::HTML_PART)
15
- expect(premailer.to_plain_text.gsub(/\s/, ' ').strip).to \
16
- eq(Fixtures::Message::TEXT_PART.gsub(/\s/, ' ').strip)
17
- end
17
+ context 'when inline CSS block present' do
18
+ it 'returns the HTML with the CSS inlined' do
19
+ allow(Premailer::Rails::CSSHelper).to \
20
+ receive(:css_for_doc).and_return('p { color: red; }')
21
+ html = Fixtures::Message::HTML_PART
22
+ premailer = Premailer::Rails::CustomizedPremailer.new(html)
23
+ expect(premailer.to_inline_css).to match(regex)
18
24
  end
25
+ end
19
26
 
20
- describe '#to_inline_css' do
21
- let(:regex) { %r{<p style=("|')color: ?red;?\1>} }
22
-
23
- context 'when inline CSS block present' do
24
- it 'returns the HTML with the CSS inlined' do
25
- allow(Premailer::Rails::CSSHelper).to \
26
- receive(:css_for_doc).and_return('p { color: red; }')
27
- html = Fixtures::Message::HTML_PART
28
- premailer = Premailer::Rails::CustomizedPremailer.new(html)
29
- expect(premailer.to_inline_css).to match(regex)
30
- end
31
- end
32
-
33
- context 'when CSS is loaded externally' do
34
- it 'returns the HTML with the CSS inlined' do
35
- html = Fixtures::Message::HTML_PART_WITH_CSS
36
- premailer = Premailer::Rails::CustomizedPremailer.new(html)
37
- expect(premailer.to_inline_css).to match(regex)
38
- end
39
- end
27
+ context 'when CSS is loaded externally' do
28
+ it 'returns the HTML with the CSS inlined' do
29
+ html = Fixtures::Message::HTML_PART_WITH_CSS
30
+ premailer = Premailer::Rails::CustomizedPremailer.new(html)
31
+ expect(premailer.to_inline_css).to match(regex)
32
+ end
33
+ end
40
34
 
41
- context 'when HTML contains unicode' do
42
- it 'does not mess those up' do
43
- html = Fixtures::Message::HTML_PART_WITH_UNICODE
44
- premailer = Premailer::Rails::CustomizedPremailer.new(html)
45
- expect(premailer.to_inline_css).to \
46
- include(Fixtures::Message::UNICODE_STRING)
47
- end
48
- end
35
+ context 'when HTML contains unicode' do
36
+ it 'does not mess those up' do
37
+ html = Fixtures::Message::HTML_PART_WITH_UNICODE
38
+ premailer = Premailer::Rails::CustomizedPremailer.new(html)
39
+ expect(premailer.to_inline_css).to \
40
+ include(Fixtures::Message::UNICODE_STRING)
49
41
  end
50
42
  end
51
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: premailer-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.7
4
+ version: 1.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philipe Fatio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-26 00:00:00.000000000 Z
11
+ date: 2020-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: premailer
@@ -37,9 +37,6 @@ dependencies:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: '3'
40
- - - "<"
41
- - !ruby/object:Gem::Version
42
- version: '6'
43
40
  type: :runtime
44
41
  prerelease: false
45
42
  version_requirements: !ruby/object:Gem::Requirement
@@ -47,9 +44,6 @@ dependencies:
47
44
  - - ">="
48
45
  - !ruby/object:Gem::Version
49
46
  version: '3'
50
- - - "<"
51
- - !ruby/object:Gem::Version
52
- version: '6'
53
47
  - !ruby/object:Gem::Dependency
54
48
  name: rspec
55
49
  requirement: !ruby/object:Gem::Requirement
@@ -78,20 +72,6 @@ dependencies:
78
72
  - - ">="
79
73
  - !ruby/object:Gem::Version
80
74
  version: '0'
81
- - !ruby/object:Gem::Dependency
82
- name: hpricot
83
- requirement: !ruby/object:Gem::Requirement
84
- requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- version: '0'
88
- type: :development
89
- prerelease: false
90
- version_requirements: !ruby/object:Gem::Requirement
91
- requirements:
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- version: '0'
95
75
  - !ruby/object:Gem::Dependency
96
76
  name: coveralls
97
77
  requirement: !ruby/object:Gem::Requirement
@@ -149,7 +129,6 @@ files:
149
129
  - lib/premailer/rails/css_helper.rb
150
130
  - lib/premailer/rails/css_loaders.rb
151
131
  - lib/premailer/rails/css_loaders/asset_pipeline_loader.rb
152
- - lib/premailer/rails/css_loaders/cache_loader.rb
153
132
  - lib/premailer/rails/css_loaders/file_system_loader.rb
154
133
  - lib/premailer/rails/css_loaders/network_loader.rb
155
134
  - lib/premailer/rails/customized_premailer.rb
@@ -158,13 +137,26 @@ files:
158
137
  - lib/premailer/rails/version.rb
159
138
  - premailer-rails.gemspec
160
139
  - spec/integration/css_helper_spec.rb
161
- - spec/integration/hook_registration_spec.rb
140
+ - spec/integration/delivery_spec.rb
162
141
  - spec/integration/hook_spec.rb
142
+ - spec/rails_app/app/assets/config/manifest.js
143
+ - spec/rails_app/app/assets/stylesheets/application.css
144
+ - spec/rails_app/app/mailers/application_mailer.rb
145
+ - spec/rails_app/app/mailers/welcome_mailer.rb
146
+ - spec/rails_app/app/views/layouts/mailer.html.erb
147
+ - spec/rails_app/app/views/welcome_mailer/welcome_email.html.erb
148
+ - spec/rails_app/config.ru
149
+ - spec/rails_app/config/application.rb
150
+ - spec/rails_app/config/boot.rb
151
+ - spec/rails_app/config/environment.rb
152
+ - spec/rails_app/config/environments/test.rb
153
+ - spec/rails_app/config/initializers/assets.rb
154
+ - spec/rails_app/config/routes.rb
155
+ - spec/rails_app/log/.keep
156
+ - spec/rails_app/tmp/.keep
163
157
  - spec/spec_helper.rb
164
158
  - spec/support/fixtures/html.rb
165
159
  - spec/support/fixtures/message.rb
166
- - spec/support/stubs/action_mailer.rb
167
- - spec/support/stubs/rails.rb
168
160
  - spec/unit/css_loaders/asset_pipeline_loader_spec.rb
169
161
  - spec/unit/css_loaders/file_system_loader_spec.rb
170
162
  - spec/unit/css_loaders/network_loader_spec.rb
@@ -189,8 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
181
  - !ruby/object:Gem::Version
190
182
  version: '0'
191
183
  requirements: []
192
- rubyforge_project:
193
- rubygems_version: 2.6.11
184
+ rubygems_version: 3.1.2
194
185
  signing_key:
195
186
  specification_version: 4
196
187
  summary: Easily create styled HTML emails in Rails.
@@ -213,13 +204,26 @@ test_files:
213
204
  - example/config/secrets.yml
214
205
  - example/test/mailers/previews/example_mailer_preview.rb
215
206
  - spec/integration/css_helper_spec.rb
216
- - spec/integration/hook_registration_spec.rb
207
+ - spec/integration/delivery_spec.rb
217
208
  - spec/integration/hook_spec.rb
209
+ - spec/rails_app/app/assets/config/manifest.js
210
+ - spec/rails_app/app/assets/stylesheets/application.css
211
+ - spec/rails_app/app/mailers/application_mailer.rb
212
+ - spec/rails_app/app/mailers/welcome_mailer.rb
213
+ - spec/rails_app/app/views/layouts/mailer.html.erb
214
+ - spec/rails_app/app/views/welcome_mailer/welcome_email.html.erb
215
+ - spec/rails_app/config.ru
216
+ - spec/rails_app/config/application.rb
217
+ - spec/rails_app/config/boot.rb
218
+ - spec/rails_app/config/environment.rb
219
+ - spec/rails_app/config/environments/test.rb
220
+ - spec/rails_app/config/initializers/assets.rb
221
+ - spec/rails_app/config/routes.rb
222
+ - spec/rails_app/log/.keep
223
+ - spec/rails_app/tmp/.keep
218
224
  - spec/spec_helper.rb
219
225
  - spec/support/fixtures/html.rb
220
226
  - spec/support/fixtures/message.rb
221
- - spec/support/stubs/action_mailer.rb
222
- - spec/support/stubs/rails.rb
223
227
  - spec/unit/css_loaders/asset_pipeline_loader_spec.rb
224
228
  - spec/unit/css_loaders/file_system_loader_spec.rb
225
229
  - spec/unit/css_loaders/network_loader_spec.rb
@@ -1,29 +0,0 @@
1
- class Premailer
2
- module Rails
3
- module CSSLoaders
4
- module CacheLoader
5
- extend self
6
-
7
- @cache = {}
8
-
9
- def load(url)
10
- @cache[url] unless development_env?
11
- end
12
-
13
- def store(url, content)
14
- @cache[url] ||= content unless development_env?
15
- end
16
-
17
- def clear!
18
- @cache = {}
19
- end
20
-
21
- def development_env?
22
- defined?(::Rails) &&
23
- ::Rails.respond_to?(:env) &&
24
- ::Rails.env.development?
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,11 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'ActionMailer::Base.register_interceptor' do
4
- it 'registers interceptors' do
5
- expect(ActionMailer::Base).to \
6
- receive(:register_interceptor).with(Premailer::Rails::Hook)
7
- expect(ActionMailer::Base).to \
8
- receive(:register_preview_interceptor).with(Premailer::Rails::Hook)
9
- load 'premailer/rails.rb'
10
- end
11
- end
@@ -1,5 +0,0 @@
1
- module ActionMailer
2
- class Base
3
- def self.register_interceptor(x); end
4
- end
5
- end
@@ -1,51 +0,0 @@
1
- module Rails
2
- extend self
3
-
4
- module Configuration
5
- extend self
6
- end
7
-
8
- module Env
9
- extend self
10
-
11
- def development?
12
- false
13
- end
14
- end
15
-
16
- module Application
17
- extend self
18
-
19
- module Assets
20
- extend self
21
- end
22
-
23
- def assets
24
- Assets
25
- end
26
- end
27
-
28
- class Railtie
29
- class Configuration
30
- def after_initialize
31
- yield
32
- end
33
- end
34
-
35
- def self.config
36
- Configuration.new
37
- end
38
- end
39
-
40
- def env
41
- Env
42
- end
43
-
44
- def configuration
45
- Configuration
46
- end
47
-
48
- def application
49
- Application
50
- end
51
- end