sanitize_email 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (c) 2008-16 Peter H. Boling of RailsBling.com
2
4
  # Released under the MIT license
3
5
 
4
6
  module SanitizeEmail
5
7
  # For Rails 3.0, which didn't yet support Engines
6
8
  class Railtie < ::Rails::Railtie
7
-
8
9
  config.after_initialize do
9
10
  ActionMailer::Base.register_interceptor(SanitizeEmail::Bleach)
10
11
  end
11
-
12
12
  end
13
13
  end
@@ -1,47 +1,49 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (c) 2008-16 Peter H. Boling of RailsBling.com
2
4
  # Released under the MIT license
3
5
  # Note: the RspecMatchers are composed matchers:
4
6
  # See: http://www.relishapp.com/rspec/rspec-expectations/v/3-5/docs/composing-matchers
5
7
 
6
- require "sanitize_email/mail_ext"
8
+ require 'sanitize_email/mail_ext'
7
9
 
8
10
  module SanitizeEmail
9
11
  # Provides matchers that can be used in
10
12
  # Rspec tests to assert the behavior of email
11
13
  module RspecMatchers
12
- [:from, :to, :cc, :bcc, :subject, :reply_to].each do |attribute|
14
+ %i[from to cc bcc subject reply_to].each do |attribute|
13
15
  RSpec::Matchers.define "have_#{attribute}" do |matcher|
14
16
  match do |actual|
15
17
  @actual = actual.send(attribute)
16
- @actual = @actual.join(", ") if @actual.respond_to?(:join)
18
+ @actual = @actual.join(', ') if @actual.respond_to?(:join)
17
19
  expect(@actual).to match(matcher)
18
20
  end
19
21
  end
20
22
  end
21
23
 
22
- [:from, :to, :cc, :bcc, :subject, :reply_to].each do |attribute|
24
+ %i[from to cc bcc subject reply_to].each do |attribute|
23
25
  RSpec::Matchers.define "match_#{attribute}" do |matcher|
24
26
  match do |actual|
25
27
  @actual = actual.send(attribute)
26
- @actual = @actual.join(", ") if @actual.respond_to?(:join)
28
+ @actual = @actual.join(', ') if @actual.respond_to?(:join)
27
29
  expect(@actual).to match(matcher)
28
30
  end
29
31
  end
30
32
  end
31
33
 
32
- [:from, :to, :cc, :bcc, :subject, :reply_to].each do |attribute|
34
+ %i[from to cc bcc subject reply_to].each do |attribute|
33
35
  RSpec::Matchers.define "be_#{attribute}" do |matcher|
34
36
  match do |actual|
35
37
  @actual = actual.send(attribute)
36
- @actual = @actual.join(", ") if @actual.respond_to?(:join)
38
+ @actual = @actual.join(', ') if @actual.respond_to?(:join)
37
39
  expect(@actual).to be(matcher)
38
40
  end
39
41
  end
40
42
  end
41
43
 
42
- RSpec::Matchers.define "have_to_username" do |matcher|
44
+ RSpec::Matchers.define 'have_to_username' do |matcher|
43
45
  def get_to_username(email_message)
44
- username_header = email_message.header["X-Sanitize-Email-To"]
46
+ username_header = email_message.header['X-Sanitize-Email-To']
45
47
  return username_header unless username_header.is_a?(Mail::Field)
46
48
  email_message.header.fields[3].value
47
49
  end
@@ -51,9 +53,9 @@ module SanitizeEmail
51
53
  end
52
54
  end
53
55
 
54
- RSpec::Matchers.define "have_cc_username" do |matcher|
56
+ RSpec::Matchers.define 'have_cc_username' do |matcher|
55
57
  def get_cc_username(email_message)
56
- username_header = email_message.header["X-Sanitize-Email-Cc"]
58
+ username_header = email_message.header['X-Sanitize-Email-Cc']
57
59
  return username_header unless username_header.is_a?(Mail::Field)
58
60
  email_message.header.fields[3].value
59
61
  end
@@ -64,13 +66,13 @@ module SanitizeEmail
64
66
  end
65
67
 
66
68
  # Cribbed from email_spec gem
67
- RSpec::Matchers.define "have_body_text" do |matcher|
69
+ RSpec::Matchers.define 'have_body_text' do |matcher|
68
70
  def get_fuzzy_body(email_message)
69
- email_message.default_part_body.to_s.gsub(/\s+/, " ")
71
+ email_message.default_part_body.to_s.gsub(/\s+/, ' ')
70
72
  end
71
73
 
72
74
  def get_fuzzy_matcher(to_fuzz)
73
- to_fuzz.gsub(/\s+/, " ")
75
+ to_fuzz.gsub(/\s+/, ' ')
74
76
  end
75
77
  match do |actual|
76
78
  @actual = get_fuzzy_body(actual)
@@ -80,13 +82,12 @@ module SanitizeEmail
80
82
  end
81
83
 
82
84
  # Cribbed from email_spec gem
83
- RSpec::Matchers.define "have_header" do |name, matcher|
85
+ RSpec::Matchers.define 'have_header' do |name, matcher|
84
86
  match do |actual|
85
87
  @actual = actual.header[name]
86
88
  @actual = @actual.value unless @actual.nil?
87
89
  expect(@actual).to match(matcher)
88
90
  end
89
91
  end
90
-
91
92
  end
92
93
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (c) 2008-16 Peter H. Boling of RailsBling.com
2
4
  # Released under the MIT license
3
5
  # Note: the RspecMatchers no longer use these methods. Instead they are composed matchers:
@@ -6,7 +8,6 @@
6
8
  module SanitizeEmail
7
9
  # Helpers for test-unit
8
10
  module TestHelpers
9
-
10
11
  # Error raised when unable to match an expected part of email in order to fail the test
11
12
  class UnexpectedMailType < StandardError; end
12
13
 
@@ -15,20 +16,18 @@ module SanitizeEmail
15
16
  end
16
17
 
17
18
  def string_matching(matcher, part, attribute)
18
- if attribute.respond_to?(:=~) # Can we match a regex against it?
19
- if matcher.is_a?(Regexp)
20
- attribute =~ matcher
21
- else
22
- attribute =~ Regexp.new(Regexp.escape(matcher))
23
- end
24
- else
25
- raise UnexpectedMailType, "Cannot match #{matcher} for #{part}"
26
- end
19
+ # Can we match a regex against it?
20
+ raise UnexpectedMailType, "Cannot match #{matcher} for #{part}" unless attribute.respond_to?(:=~)
21
+ attribute =~ if matcher.is_a?(Regexp)
22
+ matcher
23
+ else
24
+ Regexp.new(Regexp.escape(matcher))
25
+ end
27
26
  end
28
27
 
29
28
  # Normalize arrays to strings
30
29
  def array_matching(matcher, part, attribute)
31
- attribute = attribute.join(", ") if attribute.respond_to?(:join)
30
+ attribute = attribute.join(', ') if attribute.respond_to?(:join)
32
31
  string_matching(matcher, part, attribute)
33
32
  end
34
33
 
@@ -39,6 +38,5 @@ module SanitizeEmail
39
38
  def email_attribute_matching(matcher, part, attribute)
40
39
  array_matching(matcher, part, attribute)
41
40
  end
42
-
43
41
  end
44
42
  end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (c) 2008-16 Peter H. Boling of RailsBling.com
2
4
  # Released under the MIT license
3
5
 
4
6
  module SanitizeEmail
5
- VERSION = "2.0.0".freeze
7
+ VERSION = '2.0.1'
6
8
  end
@@ -1,47 +1,49 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/sanitize_email/version', __FILE__)
1
+
2
+ # frozen_string_literal: true
3
+
4
+ require File.expand_path('lib/sanitize_email/version', __dir__)
3
5
 
4
6
  Gem::Specification.new do |s|
5
- s.name = "sanitize_email"
7
+ s.name = 'sanitize_email'
6
8
  s.version = SanitizeEmail::VERSION
7
9
 
8
- s.authors = ["Peter Boling", "John Trupiano", "George Anderson"]
9
- s.summary = "Email Condom for your Ruby Server"
10
- s.description = <<EOS
11
- Email Condom for your Ruby Server.
12
- In Rails, Sinatra, et al, or simply the mail gem: Aids in development, testing, qa, and production troubleshooting of email issues without worrying that emails will get sent to actual live addresses.
13
- EOS
14
- s.email = ["peter.boling@gmail.com"]
10
+ s.authors = ['Peter Boling', 'John Trupiano', 'George Anderson']
11
+ s.summary = 'Email Condom for your Ruby Server'
12
+ s.description = <<~DESCRIPTION
13
+ Email Condom for your Ruby Server.
14
+ In Rails, Sinatra, et al, or simply the mail gem: Aids in development, testing, qa, and production troubleshooting of email issues without worrying that emails will get sent to actual live addresses.
15
+ DESCRIPTION
16
+ s.email = ['peter.boling@gmail.com']
15
17
  s.extra_rdoc_files = [
16
- "CHANGELOG.md",
17
- "LICENSE",
18
- "README.md"
18
+ 'CHANGELOG.md',
19
+ 'LICENSE',
20
+ 'README.md',
19
21
  ]
20
- s.files = `git ls-files`.split($\)
21
- s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
22
+ s.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
23
+ s.executables = s.files.grep(%r{^bin/}).map { |f| File.basename(f) }
22
24
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
23
- s.homepage = "http://github.com/pboling/sanitize_email"
24
- s.licenses = ["MIT"]
25
- s.email = 'peter.boling@gmail.com'
26
- s.require_paths = ["lib"]
25
+ s.homepage = 'http://github.com/pboling/sanitize_email'
26
+ s.licenses = ['MIT']
27
+ s.require_paths = ['lib']
27
28
  s.platform = Gem::Platform::RUBY
29
+ s.required_ruby_version = '>= 2.3.0'
28
30
 
29
31
  # Runtime Dependencies
30
32
  # A project wanting to use this gem's engine/railtie will be expected to have already loaded the rails/railtie gem.
31
- #s.add_dependency "railties", ">= 3.2"
33
+ # s.add_dependency "railties", ">= 3.2"
32
34
  # to replace the cattr_accessor method we lost when removing rails from run time dependencies
33
- #s.add_runtime_dependency("facets", ["> 0"])
35
+ # s.add_runtime_dependency("facets", ["> 0"])
34
36
 
35
37
  # Development Dependencies
36
- s.add_development_dependency "bundler"
37
- s.add_development_dependency("rails", [">= 3.0.20", "< 6"])
38
- s.add_development_dependency("actionmailer", [">= 3"])
39
- s.add_development_dependency("rspec", [">= 3"])
40
- s.add_development_dependency("mail", [">= 0"])
41
- s.add_development_dependency("rdoc", [">= 3.12"])
42
- s.add_development_dependency("rake", [">= 12"])
43
- s.add_development_dependency("pry", [">= 0"])
44
- s.add_development_dependency("appraisal")
45
- s.add_development_dependency("wwtd")
46
- s.add_development_dependency("coveralls")
38
+ s.add_development_dependency('actionmailer', ['>= 3'])
39
+ s.add_development_dependency('appraisal')
40
+ s.add_development_dependency 'bundler'
41
+ s.add_development_dependency('byebug', ['>= 0'])
42
+ s.add_development_dependency('coveralls')
43
+ s.add_development_dependency('mail', ['>= 0'])
44
+ s.add_development_dependency('rails', ['>= 3.2', '< 6'])
45
+ s.add_development_dependency('rake', ['>= 12'])
46
+ s.add_development_dependency('rdoc', ['>= 3.12'])
47
+ s.add_development_dependency('rspec', ['>= 3'])
48
+ s.add_development_dependency('wwtd')
47
49
  end
@@ -1,34 +1,32 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright (c) 2008-16 Peter H. Boling of RailsBling.com
2
4
  # Released under the MIT license
3
- require "spec_helper"
5
+ require 'spec_helper'
4
6
 
5
7
  describe SanitizeEmail do
6
8
  DEFAULT_TEST_CONFIG = {
7
- sanitized_cc: "cc@sanitize_email.org",
8
- sanitized_bcc: "bcc@sanitize_email.org",
9
- use_actual_email_prepended_to_subject: false,
10
- use_actual_environment_prepended_to_subject: false,
11
- use_actual_email_as_sanitized_user_name: false
9
+ :sanitized_cc => 'cc@sanitize_email.org',
10
+ :sanitized_bcc => 'bcc@sanitize_email.org',
11
+ :use_actual_email_prepended_to_subject => false,
12
+ :use_actual_environment_prepended_to_subject => false,
13
+ :use_actual_email_as_sanitized_user_name => false,
12
14
  }.freeze
13
15
 
14
- before(:all) do
15
- SanitizeEmail::Deprecation.deprecate_in_silence = true
16
- end
17
-
18
16
  # Cleanup, so tests don't bleed
19
- after(:each) do
17
+ after do
20
18
  SanitizeEmail::Config.config = SanitizeEmail::Config::DEFAULTS
21
- SanitizeEmail.force_sanitize = nil
19
+ described_class.force_sanitize = nil
22
20
  Mail.class_variable_get(:@@delivery_interceptors).pop
23
21
  end
24
22
 
25
- def sanitize_spec_dryer(rails_env = "test")
26
- logger = Logger.new($stdout).tap do |logger|
27
- logger.level = 5 # Unknown (make it silent!)
23
+ def sanitize_spec_dryer(rails_env = 'test')
24
+ logger = Logger.new($stdout).tap do |logsy|
25
+ logsy.level = 5 # Unknown (make it silent!)
28
26
  end
29
27
 
30
28
  Mail.defaults do
31
- delivery_method :logger, logger: logger, severity: :info
29
+ delivery_method :logger, :logger => logger, :severity => :info
32
30
  end
33
31
  SanitizeEmail::Config.instance_variable_set(
34
32
  :@config,
@@ -40,8 +38,13 @@ describe SanitizeEmail do
40
38
  def configure_sanitize_email(sanitize_hash = {})
41
39
  options = DEFAULT_TEST_CONFIG.merge(sanitize_hash).dup
42
40
  unless sanitize_hash.key?(:sanitized_recipients)
43
- options.reverse_merge!(sanitized_to: "to@sanitize_email.org")
41
+ options.reverse_merge!(:sanitized_to => 'to@sanitize_email.org')
44
42
  end
43
+ configure_from_options(options)
44
+ Mail.register_interceptor(SanitizeEmail::Bleach)
45
+ end
46
+
47
+ def configure_from_options(options)
45
48
  SanitizeEmail::Config.configure do |config|
46
49
  config[:engage] = options[:engage]
47
50
  config[:environment] = options[:environment]
@@ -49,39 +52,29 @@ describe SanitizeEmail do
49
52
  config[:sanitized_to] = options[:sanitized_to]
50
53
  config[:sanitized_cc] = options[:sanitized_cc]
51
54
  config[:sanitized_bcc] = options[:sanitized_bcc]
52
- config[:use_actual_email_prepended_to_subject] =
53
- options[:use_actual_email_prepended_to_subject]
54
- config[:use_actual_environment_prepended_to_subject] =
55
- options[:use_actual_environment_prepended_to_subject]
56
- config[:use_actual_email_as_sanitized_user_name] =
57
- options[:use_actual_email_as_sanitized_user_name]
55
+ config[:use_actual_email_prepended_to_subject] = options[:use_actual_email_prepended_to_subject]
56
+ config[:use_actual_environment_prepended_to_subject] = options[:use_actual_environment_prepended_to_subject]
57
+ config[:use_actual_email_as_sanitized_user_name] = options[:use_actual_email_as_sanitized_user_name]
58
58
 
59
59
  # For testing *deprecated* configuration options:
60
- if options[:local_environments]
61
- config[:local_environments] = options[:local_environments]
62
- end
63
- if options[:sanitized_recipients]
64
- config[:sanitized_recipients] = options[:sanitized_recipients]
65
- end
66
- unless options[:force_sanitize].nil?
67
- config[:force_sanitize] = options[:force_sanitize]
68
- end
60
+ config[:local_environments] = options[:local_environments] if options[:local_environments]
61
+ config[:sanitized_recipients] = options[:sanitized_recipients] if options[:sanitized_recipients]
62
+ config[:force_sanitize] = options[:force_sanitize] unless options[:force_sanitize].nil?
69
63
  end
70
- Mail.register_interceptor(SanitizeEmail::Bleach)
71
64
  end
72
65
 
73
66
  def funky_config
74
67
  SanitizeEmail::Config.configure do |config|
75
68
  config[:sanitized_to] =
76
- %w(
77
- funky@sanitize_email.org
78
- yummy@sanitize_email.org
79
- same@example.org
80
- )
69
+ %w[
70
+ funky@sanitize_email.org
71
+ yummy@sanitize_email.org
72
+ same@example.org
73
+ ]
81
74
  config[:sanitized_cc] = nil
82
75
  config[:sanitized_bcc] = nil
83
76
  # logic to turn sanitize_email on and off goes in this Proc:
84
- config[:activation_proc] = proc { Rails.env != "production" }
77
+ config[:activation_proc] = proc { Rails.env != 'production' }
85
78
  config[:use_actual_email_prepended_to_subject] = true
86
79
  config[:use_actual_environment_prepended_to_subject] = true
87
80
  config[:use_actual_email_as_sanitized_user_name] = false
@@ -115,502 +108,503 @@ describe SanitizeEmail do
115
108
 
116
109
  def mail_delivery_frozen_strings
117
110
  @email_message = Mail.deliver do
118
- from "from@example.org".freeze
119
- to "to@example.org".freeze
120
- subject "original subject".freeze
121
- body "funky fresh".freeze
111
+ from 'from@example.org'
112
+ to 'to@example.org'
113
+ subject 'original subject'
114
+ body 'funky fresh'
122
115
  end
123
116
  end
124
117
 
125
118
  def mail_delivery_hot_mess
126
119
  @email_message = Mail.deliver do
127
- from "same@example.org"
128
- to %w(
129
- same@example.org
130
- same@example.org
131
- same@example.org
132
- same@example.org
133
- same@example.org
134
- )
135
- cc "same@example.org"
136
- bcc "same@example.org"
137
- reply_to "same@example.org"
138
- subject "original subject"
139
- body "funky fresh"
120
+ from 'same@example.org'
121
+ to %w[
122
+ same@example.org
123
+ same@example.org
124
+ same@example.org
125
+ same@example.org
126
+ same@example.org
127
+ ]
128
+ cc 'same@example.org'
129
+ bcc 'same@example.org'
130
+ reply_to 'same@example.org'
131
+ subject 'original subject'
132
+ body 'funky fresh'
140
133
  end
141
134
  end
142
135
 
143
136
  def mail_delivery
144
137
  @email_message = Mail.deliver do
145
- from "from@example.org"
146
- to "to@example.org"
147
- cc "cc@example.org"
148
- bcc "bcc@example.org"
149
- reply_to "reply_to@example.org"
150
- subject "original subject"
151
- body "funky fresh"
138
+ from 'from@example.org'
139
+ to 'to@example.org'
140
+ cc 'cc@example.org'
141
+ bcc 'bcc@example.org'
142
+ reply_to 'reply_to@example.org'
143
+ subject 'original subject'
144
+ body 'funky fresh'
152
145
  end
153
146
  end
154
147
 
155
148
  def mail_delivery_multiple_recipients
156
149
  @email_message = Mail.deliver do
157
- from "from@example.org"
158
- to %w( to1@example.org to2@example.org to3@example.org )
159
- cc %w( cc1@example.org cc2@example.org cc3@example.org )
160
- bcc %w( bcc1@example.org bcc2@example.org bcc3@example.org )
161
- reply_to "reply_to@example.org"
162
- subject "original subject"
163
- body "funky fresh"
150
+ from 'from@example.org'
151
+ to %w[to1@example.org to2@example.org to3@example.org]
152
+ cc %w[cc1@example.org cc2@example.org cc3@example.org]
153
+ bcc %w[bcc1@example.org bcc2@example.org bcc3@example.org]
154
+ reply_to 'reply_to@example.org'
155
+ subject 'original subject'
156
+ body 'funky fresh'
164
157
  end
165
158
  end
166
159
 
167
- before(:each) do
160
+ before do
161
+ SanitizeEmail::Deprecation.deprecate_in_silence = true
168
162
  sanitize_spec_dryer
169
163
  end
170
164
 
171
- context "module methods" do
172
- context "unsanitary" do
173
- before(:each) do
165
+ context 'module methods' do
166
+ context 'unsanitary' do
167
+ before do
174
168
  configure_sanitize_email
175
169
  unsanitary_mail_delivery
176
170
  end
177
- it "should not alter non-sanitized attributes" do
178
- expect(@email_message).to have_from("from@example.org")
179
- expect(@email_message).to have_reply_to("reply_to@example.org")
180
- expect(@email_message).to have_body_text("funky fresh")
171
+ it 'does not alter non-sanitized attributes' do
172
+ expect(@email_message).to have_from('from@example.org')
173
+ expect(@email_message).to have_reply_to('reply_to@example.org')
174
+ expect(@email_message).to have_body_text('funky fresh')
181
175
  end
182
- it "should not prepend overrides" do
176
+ it 'does not prepend overrides' do
183
177
  expect(@email_message).not_to have_to_username(
184
- "to at sanitize_email.org"
178
+ 'to at sanitize_email.org'
185
179
  )
186
180
  expect(@email_message).not_to have_subject(
187
- "(to at sanitize_email.org)"
181
+ '(to at sanitize_email.org)'
188
182
  )
189
183
  end
190
- it "alters nothing" do
191
- expect(@email_message).to have_from("from@example.org")
192
- expect(@email_message).to have_reply_to("reply_to@example.org")
193
- expect(@email_message).to have_from("from@example.org")
194
- expect(@email_message).to have_to("to@example.org")
195
- expect(@email_message).not_to have_to_username("to at")
196
- expect(@email_message).to have_cc("cc@example.org")
197
- expect(@email_message).to have_bcc("bcc@example.org")
198
- expect(@email_message).to have_subject("original subject")
199
- expect(@email_message).to have_body_text("funky fresh")
184
+ it 'alters nothing' do
185
+ expect(@email_message).to have_from('from@example.org')
186
+ expect(@email_message).to have_reply_to('reply_to@example.org')
187
+ expect(@email_message).to have_from('from@example.org')
188
+ expect(@email_message).to have_to('to@example.org')
189
+ expect(@email_message).not_to have_to_username('to at')
190
+ expect(@email_message).to have_cc('cc@example.org')
191
+ expect(@email_message).to have_bcc('bcc@example.org')
192
+ expect(@email_message).to have_subject('original subject')
193
+ expect(@email_message).to have_body_text('funky fresh')
200
194
  end
201
195
  end
202
196
 
203
- context "sanitary" do
204
- before(:each) do
197
+ context 'sanitary' do
198
+ before do
205
199
  configure_sanitize_email
206
200
  sanitary_mail_delivery
207
201
  end
208
- it "should not alter non-sanitized attributes" do
209
- expect(@email_message).to have_from("from@example.org")
210
- expect(@email_message).to have_reply_to("reply_to@example.org")
211
- expect(@email_message).to have_body_text("funky fresh")
202
+ it 'does not alter non-sanitized attributes' do
203
+ expect(@email_message).to have_from('from@example.org')
204
+ expect(@email_message).to have_reply_to('reply_to@example.org')
205
+ expect(@email_message).to have_body_text('funky fresh')
212
206
  end
213
- it "should not prepend overrides" do
207
+ it 'does not prepend overrides' do
214
208
  expect(@email_message).not_to have_to_username(
215
- "to at sanitize_email.org"
209
+ 'to at sanitize_email.org'
216
210
  )
217
211
  expect(@email_message).not_to have_subject(
218
- "(to at sanitize_email.org)"
212
+ '(to at sanitize_email.org)'
219
213
  )
220
214
  end
221
- it "should override" do
222
- expect(@email_message).to have_to("to@sanitize_email.org")
223
- expect(@email_message).to have_cc("cc@sanitize_email.org")
224
- expect(@email_message).to have_bcc("bcc@sanitize_email.org")
215
+ it 'overrides' do
216
+ expect(@email_message).to have_to('to@sanitize_email.org')
217
+ expect(@email_message).to have_cc('cc@sanitize_email.org')
218
+ expect(@email_message).to have_bcc('bcc@sanitize_email.org')
225
219
  end
226
- it "should set headers" do
220
+ it 'sets headers' do
227
221
  expect(@email_message).to have_header(
228
- "X-Sanitize-Email-To",
229
- "to@example.org"
222
+ 'X-Sanitize-Email-To',
223
+ 'to@example.org'
230
224
  )
231
225
  expect(@email_message).to have_header(
232
- "X-Sanitize-Email-Cc",
233
- "cc@example.org"
226
+ 'X-Sanitize-Email-Cc',
227
+ 'cc@example.org'
234
228
  )
235
229
  expect(@email_message).not_to have_header(
236
- "X-Sanitize-Email-Bcc",
237
- "bcc@sanitize_email.org"
230
+ 'X-Sanitize-Email-Bcc',
231
+ 'bcc@sanitize_email.org'
238
232
  )
239
233
  end
240
- it "should not prepend originals by default" do
234
+ it 'does not prepend originals by default' do
241
235
  expect(@email_message).not_to have_to_username(
242
- "to at example.org <to@sanitize_email.org>"
236
+ 'to at example.org <to@sanitize_email.org>'
243
237
  )
244
238
  expect(@email_message).not_to have_subject(
245
- "(to at example.org) original subject"
239
+ '(to at example.org) original subject'
246
240
  )
247
241
  end
248
242
  end
249
243
 
250
- context "sanitary with multiple recipients" do
251
- before(:each) do
244
+ context 'sanitary with multiple recipients' do
245
+ before do
252
246
  configure_sanitize_email
253
247
  sanitary_mail_delivery_multiple_recipients
254
248
  end
255
- it "should not alter non-sanitized attributes" do
256
- expect(@email_message).to have_from("from@example.org")
257
- expect(@email_message).to have_reply_to("reply_to@example.org")
258
- expect(@email_message).to have_body_text("funky fresh")
249
+ it 'does not alter non-sanitized attributes' do
250
+ expect(@email_message).to have_from('from@example.org')
251
+ expect(@email_message).to have_reply_to('reply_to@example.org')
252
+ expect(@email_message).to have_body_text('funky fresh')
259
253
  end
260
- it "should not prepend overrides" do
254
+ it 'does not prepend overrides' do
261
255
  expect(@email_message).not_to have_to_username(
262
- "to at sanitize_email.org"
256
+ 'to at sanitize_email.org'
263
257
  )
264
- expect(@email_message).not_to have_subject("(to at sanitize_email.org)")
258
+ expect(@email_message).not_to have_subject('(to at sanitize_email.org)')
265
259
  end
266
- it "should override" do
267
- expect(@email_message).to have_to("to@sanitize_email.org")
268
- expect(@email_message).to have_cc("cc@sanitize_email.org")
269
- expect(@email_message).to have_bcc("bcc@sanitize_email.org")
260
+ it 'overrides' do
261
+ expect(@email_message).to have_to('to@sanitize_email.org')
262
+ expect(@email_message).to have_cc('cc@sanitize_email.org')
263
+ expect(@email_message).to have_bcc('bcc@sanitize_email.org')
270
264
  end
271
- it "should set headers for sanitized :to recipients" do
265
+ it 'sets headers for sanitized :to recipients' do
272
266
  expect(@email_message).to have_header(
273
- "X-Sanitize-Email-To",
274
- "to1@example.org"
267
+ 'X-Sanitize-Email-To',
268
+ 'to1@example.org'
275
269
  )
276
270
  expect(@email_message).not_to have_header(
277
- "X-Sanitize-Email-To-0",
278
- "to1@example.org"
271
+ 'X-Sanitize-Email-To-0',
272
+ 'to1@example.org'
279
273
  )
280
274
  expect(@email_message).not_to have_header(
281
- "X-Sanitize-Email-To-1",
282
- "to1@example.org"
275
+ 'X-Sanitize-Email-To-1',
276
+ 'to1@example.org'
283
277
  )
284
278
  expect(@email_message).to have_header(
285
- "X-Sanitize-Email-To-2",
286
- "to2@example.org"
279
+ 'X-Sanitize-Email-To-2',
280
+ 'to2@example.org'
287
281
  )
288
282
  expect(@email_message).to have_header(
289
- "X-Sanitize-Email-To-3",
290
- "to3@example.org"
283
+ 'X-Sanitize-Email-To-3',
284
+ 'to3@example.org'
291
285
  )
292
286
  end
293
- it "should set headers for sanitized :cc recipients" do
287
+ it 'sets headers for sanitized :cc recipients' do
294
288
  expect(@email_message).to have_header(
295
- "X-Sanitize-Email-Cc",
296
- "cc1@example.org"
289
+ 'X-Sanitize-Email-Cc',
290
+ 'cc1@example.org'
297
291
  )
298
292
  expect(@email_message).not_to have_header(
299
- "X-Sanitize-Email-Cc-0",
300
- "cc1@example.org"
293
+ 'X-Sanitize-Email-Cc-0',
294
+ 'cc1@example.org'
301
295
  )
302
296
  expect(@email_message).not_to have_header(
303
- "X-Sanitize-Email-Cc-1",
304
- "cc1@example.org"
297
+ 'X-Sanitize-Email-Cc-1',
298
+ 'cc1@example.org'
305
299
  )
306
300
  expect(@email_message).to have_header(
307
- "X-Sanitize-Email-Cc-2",
308
- "cc2@example.org"
301
+ 'X-Sanitize-Email-Cc-2',
302
+ 'cc2@example.org'
309
303
  )
310
304
  expect(@email_message).to have_header(
311
- "X-Sanitize-Email-Cc-3",
312
- "cc3@example.org"
305
+ 'X-Sanitize-Email-Cc-3',
306
+ 'cc3@example.org'
313
307
  )
314
308
  end
315
- it "should not set headers for sanitized :bcc recipients" do
309
+ it 'does not set headers for sanitized :bcc recipients' do
316
310
  expect(@email_message).not_to have_header(
317
- "X-Sanitize-Email-Bcc",
318
- "bcc1@sanitize_email.org"
311
+ 'X-Sanitize-Email-Bcc',
312
+ 'bcc1@sanitize_email.org'
319
313
  )
320
314
  expect(@email_message).not_to have_header(
321
- "X-Sanitize-Email-Bcc-0",
322
- "bcc1@sanitize_email.org"
315
+ 'X-Sanitize-Email-Bcc-0',
316
+ 'bcc1@sanitize_email.org'
323
317
  )
324
318
  expect(@email_message).not_to have_header(
325
- "X-Sanitize-Email-Bcc-1",
326
- "bcc1@sanitize_email.org"
319
+ 'X-Sanitize-Email-Bcc-1',
320
+ 'bcc1@sanitize_email.org'
327
321
  )
328
322
  expect(@email_message).not_to have_header(
329
- "X-Sanitize-Email-Bcc-2",
330
- "bcc2@sanitize_email.org"
323
+ 'X-Sanitize-Email-Bcc-2',
324
+ 'bcc2@sanitize_email.org'
331
325
  )
332
326
  expect(@email_message).not_to have_header(
333
- "X-Sanitize-Email-Bcc-3",
334
- "bcc3@sanitize_email.org"
327
+ 'X-Sanitize-Email-Bcc-3',
328
+ 'bcc3@sanitize_email.org'
335
329
  )
336
330
  end
337
- it "should not prepend originals by default" do
331
+ it 'does not prepend originals by default' do
338
332
  expect(@email_message).not_to have_to_username(
339
- "to at example.org <to@sanitize_email.org>"
333
+ 'to at example.org <to@sanitize_email.org>'
340
334
  )
341
335
  expect(@email_message).not_to have_subject(
342
- "(to at example.org) original subject"
336
+ '(to at example.org) original subject'
343
337
  )
344
338
  end
345
339
  end
346
340
 
347
- context "sanitary with funky config" do
348
- before(:each) do
341
+ context 'sanitary with funky config' do
342
+ before do
349
343
  funky_config
350
- SanitizeEmail.force_sanitize = true
344
+ described_class.force_sanitize = true
351
345
  mail_delivery
352
346
  end
353
- it "original to is prepended to subject" do
347
+ it 'original to is prepended to subject' do
354
348
  regex = /\(to at example.org\).*original subject/
355
349
  expect(@email_message).to have_subject(regex)
356
350
  end
357
- it "original to is only prepended once to subject" do
351
+ it 'original to is only prepended once to subject' do
358
352
  regex = /\(to at example.org\).*\(to at example.org\).*original subject/
359
353
  expect(@email_message).not_to have_subject(regex)
360
354
  end
361
- it "should not alter non-sanitized attributes" do
362
- expect(@email_message).to have_from("from@example.org")
363
- expect(@email_message).to have_reply_to("reply_to@example.org")
364
- expect(@email_message).to have_body_text("funky fresh")
355
+ it 'does not alter non-sanitized attributes' do
356
+ expect(@email_message).to have_from('from@example.org')
357
+ expect(@email_message).to have_reply_to('reply_to@example.org')
358
+ expect(@email_message).to have_body_text('funky fresh')
365
359
  end
366
- it "should not prepend overrides" do
360
+ it 'does not prepend overrides' do
367
361
  expect(@email_message).not_to have_to_username(
368
- "to at sanitize_email.org"
362
+ 'to at sanitize_email.org'
369
363
  )
370
364
  regex = /.*\(to at sanitize_email.org\).*/
371
365
  expect(@email_message).not_to have_subject(regex)
372
366
  end
373
- it "should override where original recipients were not nil" do
374
- expect(@email_message).to have_to("funky@sanitize_email.org")
367
+ it 'overrides where original recipients were not nil' do
368
+ expect(@email_message).to have_to('funky@sanitize_email.org')
375
369
  end
376
- it "should not override where original recipients were nil" do
377
- expect(@email_message).not_to have_cc("cc@sanitize_email.org")
378
- expect(@email_message).not_to have_bcc("bcc@sanitize_email.org")
370
+ it 'does not override where original recipients were nil' do
371
+ expect(@email_message).not_to have_cc('cc@sanitize_email.org')
372
+ expect(@email_message).not_to have_bcc('bcc@sanitize_email.org')
379
373
  end
380
- it "should set headers of originals" do
374
+ it 'sets headers of originals' do
381
375
  expect(@email_message).to have_header(
382
- "X-Sanitize-Email-To",
383
- "to@example.org"
376
+ 'X-Sanitize-Email-To',
377
+ 'to@example.org'
384
378
  )
385
379
  expect(@email_message).to have_header(
386
- "X-Sanitize-Email-Cc",
387
- "cc@example.org"
380
+ 'X-Sanitize-Email-Cc',
381
+ 'cc@example.org'
388
382
  )
389
383
  end
390
- it "should not set headers of bcc" do
384
+ it 'does not set headers of bcc' do
391
385
  expect(@email_message).not_to have_header(
392
- "X-Sanitize-Email-Bcc",
393
- "bcc@sanitize_email.org"
386
+ 'X-Sanitize-Email-Bcc',
387
+ 'bcc@sanitize_email.org'
394
388
  )
395
389
  end
396
- it "should not set headers of overrides" do
390
+ it 'does not set headers of overrides' do
397
391
  expect(@email_message).not_to have_header(
398
- "X-Sanitize-Email-To",
399
- "funky@sanitize_email.org"
392
+ 'X-Sanitize-Email-To',
393
+ 'funky@sanitize_email.org'
400
394
  )
401
395
  expect(@email_message).not_to have_header(
402
- "X-Sanitize-Email-Cc",
403
- "cc@sanitize_email.org"
396
+ 'X-Sanitize-Email-Cc',
397
+ 'cc@sanitize_email.org'
404
398
  )
405
399
  expect(@email_message).not_to have_header(
406
- "X-Sanitize-Email-Bcc",
407
- "bcc@sanitize_email.org"
400
+ 'X-Sanitize-Email-Bcc',
401
+ 'bcc@sanitize_email.org'
408
402
  )
409
- #puts "email headers:\n#{@email_message.header}"
403
+ # puts "email headers:\n#{@email_message.header}"
410
404
  end
411
- it "should not prepend originals by default" do
405
+ it 'does not prepend originals by default' do
412
406
  expect(@email_message).not_to have_to_username(
413
- "to at example.org <to@sanitize_email.org>"
407
+ 'to at example.org <to@sanitize_email.org>'
414
408
  )
415
409
  expect(@email_message).not_to have_subject(
416
- "(to at example.org) original subject"
410
+ '(to at example.org) original subject'
417
411
  )
418
412
  end
419
413
  end
420
414
 
421
- context "sanitary with funky config and hot mess delivery" do
422
- before(:each) do
415
+ context 'sanitary with funky config and hot mess delivery' do
416
+ before do
423
417
  funky_config
424
- SanitizeEmail.force_sanitize = true
418
+ described_class.force_sanitize = true
425
419
  mail_delivery_hot_mess
426
420
  end
427
- it "original to is prepended to subject" do
421
+ it 'original to is prepended to subject' do
428
422
  regex = /\(same at example.org\).*original subject/
429
423
  expect(@email_message).to match_subject(regex)
430
424
  end
431
- it "original to is only prepended once to subject" do
425
+ it 'original to is only prepended once to subject' do
432
426
  regex = /\(same at example.org\).*\(same at example.org\).*original subject/
433
427
  expect(@email_message).not_to match_subject(regex)
434
428
  end
435
- it "should not alter non-sanitized attributes" do
436
- expect(@email_message).to have_from("same@example.org")
437
- expect(@email_message).to have_reply_to("same@example.org")
438
- expect(@email_message).to have_body_text("funky fresh")
429
+ it 'does not alter non-sanitized attributes' do
430
+ expect(@email_message).to have_from('same@example.org')
431
+ expect(@email_message).to have_reply_to('same@example.org')
432
+ expect(@email_message).to have_body_text('funky fresh')
439
433
  end
440
- it "should not prepend overrides" do
441
- expect(@email_message).not_to have_to_username("same at example.org")
434
+ it 'does not prepend overrides' do
435
+ expect(@email_message).not_to have_to_username('same at example.org')
442
436
  end
443
- it "should override where original recipients were not nil" do
444
- expect(@email_message).to have_to("same@example.org")
437
+ it 'overrides where original recipients were not nil' do
438
+ expect(@email_message).to have_to('same@example.org')
445
439
  end
446
- it "should not override where original recipients were nil" do
447
- expect(@email_message).not_to have_cc("same@example.org")
448
- expect(@email_message).not_to have_bcc("same@example.org")
440
+ it 'does not override where original recipients were nil' do
441
+ expect(@email_message).not_to have_cc('same@example.org')
442
+ expect(@email_message).not_to have_bcc('same@example.org')
449
443
  end
450
- it "should set headers of originals" do
444
+ it 'sets headers of originals' do
451
445
  expect(@email_message).to have_header(
452
- "X-Sanitize-Email-To",
453
- "same@example.org"
446
+ 'X-Sanitize-Email-To',
447
+ 'same@example.org'
454
448
  )
455
449
  expect(@email_message).to have_header(
456
- "X-Sanitize-Email-Cc",
457
- "same@example.org"
450
+ 'X-Sanitize-Email-Cc',
451
+ 'same@example.org'
458
452
  )
459
453
  end
460
- it "should not set headers of bcc" do
454
+ it 'does not set headers of bcc' do
461
455
  expect(@email_message).not_to have_header(
462
- "X-Sanitize-Email-Bcc",
463
- "same@example.org"
456
+ 'X-Sanitize-Email-Bcc',
457
+ 'same@example.org'
464
458
  )
465
459
  end
466
- it "should not set headers of overrides" do
460
+ it 'does not set headers of overrides' do
467
461
  expect(@email_message).not_to have_header(
468
- "X-Sanitize-Email-Bcc",
469
- "same@example.org"
462
+ 'X-Sanitize-Email-Bcc',
463
+ 'same@example.org'
470
464
  )
471
465
  # puts "email headers:\n#{@email_message.header}"
472
466
  end
473
- it "should not prepend originals by default" do
467
+ it 'does not prepend originals by default' do
474
468
  expect(@email_message).not_to have_to_username(
475
- "same at example.org <same@example.org>"
469
+ 'same at example.org <same@example.org>'
476
470
  )
477
471
  expect(@email_message).not_to have_subject(
478
- "(same at example.org) original subject"
472
+ '(same at example.org) original subject'
479
473
  )
480
474
  end
481
475
  end
482
476
 
483
- context "with frozen string (literals)" do
484
- it "prepends strings without exception" do
477
+ context 'with frozen string (literals)' do
478
+ it 'prepends strings without exception' do
485
479
  configure_sanitize_email(
486
- environment: "{{serverABC}}",
487
- use_actual_environment_prepended_to_subject: true
480
+ :environment => '{{serverABC}}',
481
+ :use_actual_environment_prepended_to_subject => true
488
482
  )
489
- expect { sanitary_mail_delivery_frozen_strings }.to_not raise_exception
483
+ expect { sanitary_mail_delivery_frozen_strings }.not_to raise_exception
490
484
  end
491
485
  end
492
486
 
493
- context "force_sanitize" do
494
- context "true" do
495
- before(:each) do
487
+ context 'force_sanitize' do
488
+ context 'true' do
489
+ before do
496
490
  # Should turn off sanitization using the force_sanitize
497
- configure_sanitize_email(activation_proc: proc { true })
498
- SanitizeEmail.force_sanitize = true
491
+ configure_sanitize_email(:activation_proc => proc { true })
492
+ described_class.force_sanitize = true
499
493
  mail_delivery
500
494
  end
501
- it "should not alter non-sanitized attributes" do
502
- expect(@email_message).to have_from("from@example.org")
503
- expect(@email_message).to have_reply_to("reply_to@example.org")
504
- expect(@email_message).to have_body_text("funky fresh")
495
+ it 'does not alter non-sanitized attributes' do
496
+ expect(@email_message).to have_from('from@example.org')
497
+ expect(@email_message).to have_reply_to('reply_to@example.org')
498
+ expect(@email_message).to have_body_text('funky fresh')
505
499
  end
506
- it "should override" do
507
- expect(@email_message).to have_to("to@sanitize_email.org")
508
- expect(@email_message).to have_cc("cc@sanitize_email.org")
509
- expect(@email_message).to have_bcc("bcc@sanitize_email.org")
500
+ it 'overrides' do
501
+ expect(@email_message).to have_to('to@sanitize_email.org')
502
+ expect(@email_message).to have_cc('cc@sanitize_email.org')
503
+ expect(@email_message).to have_bcc('bcc@sanitize_email.org')
510
504
  end
511
- it "should set headers" do
505
+ it 'sets headers' do
512
506
  expect(@email_message).to have_header(
513
- "X-Sanitize-Email-To",
514
- "to@example.org"
507
+ 'X-Sanitize-Email-To',
508
+ 'to@example.org'
515
509
  )
516
510
  expect(@email_message).to have_header(
517
- "X-Sanitize-Email-Cc",
518
- "cc@example.org"
511
+ 'X-Sanitize-Email-Cc',
512
+ 'cc@example.org'
519
513
  )
520
514
  expect(@email_message).not_to have_header(
521
- "X-Sanitize-Email-Bcc",
522
- "bcc@sanitize_email.org"
515
+ 'X-Sanitize-Email-Bcc',
516
+ 'bcc@sanitize_email.org'
523
517
  )
524
518
  end
525
519
  end
526
- context "false" do
527
- before(:each) do
520
+ context 'false' do
521
+ before do
528
522
  # Should turn off sanitization using the force_sanitize
529
- configure_sanitize_email(activation_proc: proc { true })
530
- SanitizeEmail.force_sanitize = false
523
+ configure_sanitize_email(:activation_proc => proc { true })
524
+ described_class.force_sanitize = false
531
525
  mail_delivery
532
526
  end
533
- it "should not alter non-sanitized attributes" do
534
- expect(@email_message).to have_from("from@example.org")
535
- expect(@email_message).to have_reply_to("reply_to@example.org")
536
- expect(@email_message).to have_body_text("funky fresh")
527
+ it 'does not alter non-sanitized attributes' do
528
+ expect(@email_message).to have_from('from@example.org')
529
+ expect(@email_message).to have_reply_to('reply_to@example.org')
530
+ expect(@email_message).to have_body_text('funky fresh')
537
531
  end
538
- it "should not alter normally sanitized attributes" do
539
- expect(@email_message).to have_to("to@example.org")
540
- expect(@email_message).to have_cc("cc@example.org")
541
- expect(@email_message).to have_bcc("bcc@example.org")
532
+ it 'does not alter normally sanitized attributes' do
533
+ expect(@email_message).to have_to('to@example.org')
534
+ expect(@email_message).to have_cc('cc@example.org')
535
+ expect(@email_message).to have_bcc('bcc@example.org')
542
536
  expect(@email_message).not_to have_header(
543
- "X-Sanitize-Email-To",
544
- "to@example.org"
537
+ 'X-Sanitize-Email-To',
538
+ 'to@example.org'
545
539
  )
546
540
  expect(@email_message).not_to have_header(
547
- "X-Sanitize-Email-Cc",
548
- "cc@example.org"
541
+ 'X-Sanitize-Email-Cc',
542
+ 'cc@example.org'
549
543
  )
550
544
  expect(@email_message).not_to have_header(
551
- "X-Sanitize-Email-Bcc",
552
- "bcc@example.org"
545
+ 'X-Sanitize-Email-Bcc',
546
+ 'bcc@example.org'
553
547
  )
554
548
  end
555
549
  end
556
- context "nil" do
557
- context "activation proc enables" do
558
- before(:each) do
550
+ context 'nil' do
551
+ context 'activation proc enables' do
552
+ before do
559
553
  # Should ignore force_sanitize setting
560
- configure_sanitize_email(activation_proc: proc { true })
561
- SanitizeEmail.force_sanitize = nil
554
+ configure_sanitize_email(:activation_proc => proc { true })
555
+ described_class.force_sanitize = nil
562
556
  mail_delivery
563
557
  end
564
- it "should not alter non-sanitized attributes" do
565
- expect(@email_message).to have_from("from@example.org")
566
- expect(@email_message).to have_reply_to("reply_to@example.org")
567
- expect(@email_message).to have_body_text("funky fresh")
558
+ it 'does not alter non-sanitized attributes' do
559
+ expect(@email_message).to have_from('from@example.org')
560
+ expect(@email_message).to have_reply_to('reply_to@example.org')
561
+ expect(@email_message).to have_body_text('funky fresh')
568
562
  end
569
- it "should override" do
570
- expect(@email_message).to have_to("to@sanitize_email.org")
571
- expect(@email_message).to have_cc("cc@sanitize_email.org")
572
- expect(@email_message).to have_bcc("bcc@sanitize_email.org")
563
+ it 'overrides' do
564
+ expect(@email_message).to have_to('to@sanitize_email.org')
565
+ expect(@email_message).to have_cc('cc@sanitize_email.org')
566
+ expect(@email_message).to have_bcc('bcc@sanitize_email.org')
573
567
  expect(@email_message).to have_header(
574
- "X-Sanitize-Email-To",
575
- "to@example.org"
568
+ 'X-Sanitize-Email-To',
569
+ 'to@example.org'
576
570
  )
577
571
  expect(@email_message).to have_header(
578
- "X-Sanitize-Email-Cc",
579
- "cc@example.org"
572
+ 'X-Sanitize-Email-Cc',
573
+ 'cc@example.org'
580
574
  )
581
575
  expect(@email_message).not_to have_header(
582
- "X-Sanitize-Email-Bcc",
583
- "bcc@sanitize_email.org"
576
+ 'X-Sanitize-Email-Bcc',
577
+ 'bcc@sanitize_email.org'
584
578
  )
585
579
  end
586
580
  end
587
- context "activation proc disables" do
588
- before(:each) do
581
+ context 'activation proc disables' do
582
+ before do
589
583
  # Should ignore force_sanitize setting
590
- configure_sanitize_email(activation_proc: proc { false })
591
- SanitizeEmail.force_sanitize = nil
584
+ configure_sanitize_email(:activation_proc => proc { false })
585
+ described_class.force_sanitize = nil
592
586
  mail_delivery
593
587
  end
594
- it "should not alter non-sanitized attributes" do
595
- expect(@email_message).to have_from("from@example.org")
596
- expect(@email_message).to have_reply_to("reply_to@example.org")
597
- expect(@email_message).to have_body_text("funky fresh")
588
+ it 'does not alter non-sanitized attributes' do
589
+ expect(@email_message).to have_from('from@example.org')
590
+ expect(@email_message).to have_reply_to('reply_to@example.org')
591
+ expect(@email_message).to have_body_text('funky fresh')
598
592
  end
599
- it "should not alter normally sanitized attributes" do
600
- expect(@email_message).to have_to("to@example.org")
601
- expect(@email_message).to have_cc("cc@example.org")
602
- expect(@email_message).to have_bcc("bcc@example.org")
593
+ it 'does not alter normally sanitized attributes' do
594
+ expect(@email_message).to have_to('to@example.org')
595
+ expect(@email_message).to have_cc('cc@example.org')
596
+ expect(@email_message).to have_bcc('bcc@example.org')
603
597
  expect(@email_message).not_to have_header(
604
- "X-Sanitize-Email-To",
605
- "to@example.org"
598
+ 'X-Sanitize-Email-To',
599
+ 'to@example.org'
606
600
  )
607
601
  expect(@email_message).not_to have_header(
608
- "X-Sanitize-Email-Cc",
609
- "cc@example.org"
602
+ 'X-Sanitize-Email-Cc',
603
+ 'cc@example.org'
610
604
  )
611
605
  expect(@email_message).not_to have_header(
612
- "X-Sanitize-Email-Bcc",
613
- "bcc@example.org"
606
+ 'X-Sanitize-Email-Bcc',
607
+ 'bcc@example.org'
614
608
  )
615
609
  end
616
610
  end
@@ -618,331 +612,333 @@ describe SanitizeEmail do
618
612
  end
619
613
  end
620
614
 
621
- context "config options" do
622
- context ":use_actual_environment_prepended_to_subject" do
623
- context "true" do
624
- before(:each) do
615
+ context 'config options' do
616
+ context ':use_actual_environment_prepended_to_subject' do
617
+ context 'true' do
618
+ before do
625
619
  configure_sanitize_email(
626
- environment: "{{serverABC}}",
627
- use_actual_environment_prepended_to_subject: true
620
+ :environment => '{{serverABC}}',
621
+ :use_actual_environment_prepended_to_subject => true
628
622
  )
629
623
  sanitary_mail_delivery
630
624
  end
631
- it "original to is prepended" do
625
+ it 'original to is prepended' do
632
626
  expect(@email_message).to have_subject(
633
- "{{serverABC}} original subject"
627
+ '{{serverABC}} original subject'
634
628
  )
635
629
  end
636
- it "should not alter non-sanitized attributes" do
637
- expect(@email_message).to have_from("from@example.org")
638
- expect(@email_message).to have_reply_to("reply_to@example.org")
639
- expect(@email_message).to have_body_text("funky fresh")
630
+ it 'does not alter non-sanitized attributes' do
631
+ expect(@email_message).to have_from('from@example.org')
632
+ expect(@email_message).to have_reply_to('reply_to@example.org')
633
+ expect(@email_message).to have_body_text('funky fresh')
640
634
  end
641
- it "should not prepend overrides" do
635
+ it 'does not prepend overrides' do
642
636
  expect(@email_message).not_to have_to_username(
643
- "to at sanitize_email.org"
637
+ 'to at sanitize_email.org'
644
638
  )
645
639
  expect(@email_message).not_to have_subject(
646
- "(to at sanitize_email.org)"
640
+ '(to at sanitize_email.org)'
647
641
  )
648
642
  end
649
643
  end
650
- context "false" do
651
- before(:each) do
644
+ context 'false' do
645
+ before do
652
646
  configure_sanitize_email(
653
- environment: "{{serverABC}}",
654
- use_actual_environment_prepended_to_subject: false
647
+ :environment => '{{serverABC}}',
648
+ :use_actual_environment_prepended_to_subject => false
655
649
  )
656
650
  sanitary_mail_delivery
657
651
  end
658
- it "original to is not prepended" do
652
+ it 'original to is not prepended' do
659
653
  expect(@email_message).not_to have_subject(
660
- "{{serverABC}} original subject"
654
+ '{{serverABC}} original subject'
661
655
  )
662
- expect(@email_message.subject).to eq("original subject")
656
+ expect(@email_message.subject).to eq('original subject')
663
657
  end
664
- it "should not alter non-sanitized attributes" do
665
- expect(@email_message).to have_from("from@example.org")
666
- expect(@email_message).to have_reply_to("reply_to@example.org")
667
- expect(@email_message).to have_body_text("funky fresh")
658
+ it 'does not alter non-sanitized attributes' do
659
+ expect(@email_message).to have_from('from@example.org')
660
+ expect(@email_message).to have_reply_to('reply_to@example.org')
661
+ expect(@email_message).to have_body_text('funky fresh')
668
662
  end
669
- it "should not prepend overrides" do
663
+ it 'does not prepend overrides' do
670
664
  expect(@email_message).not_to have_to_username(
671
- "to at sanitize_email.org"
665
+ 'to at sanitize_email.org'
672
666
  )
673
667
  expect(@email_message).not_to have_subject(
674
- "(to at sanitize_email.org)"
668
+ '(to at sanitize_email.org)'
675
669
  )
676
670
  end
677
671
  end
678
672
  end
679
673
 
680
- context ":use_actual_email_prepended_to_subject" do
681
- context "true" do
682
- before(:each) do
683
- configure_sanitize_email(use_actual_email_prepended_to_subject: true)
674
+ context ':use_actual_email_prepended_to_subject' do
675
+ context 'true' do
676
+ before do
677
+ configure_sanitize_email(:use_actual_email_prepended_to_subject => true)
684
678
  end
685
- context "to address is an array" do
679
+ context 'to address is an array' do
686
680
  before do
687
681
  sanitary_mail_delivery_multiple_recipients
688
682
  end
689
- it "original to is prepended" do
683
+ it 'original to is prepended' do
690
684
  expect(@email_message).to have_subject(
691
- "(to1 at example.org,to2 at example.org,to3 at example.org) original subject"
685
+ '(to1 at example.org,to2 at example.org,to3 at example.org) original subject'
692
686
  )
693
687
  end
694
- it "should not alter non-sanitized attributes" do
695
- expect(@email_message).to have_from("from@example.org")
696
- expect(@email_message).to have_reply_to("reply_to@example.org")
697
- expect(@email_message).to have_body_text("funky fresh")
688
+ it 'does not alter non-sanitized attributes' do
689
+ expect(@email_message).to have_from('from@example.org')
690
+ expect(@email_message).to have_reply_to('reply_to@example.org')
691
+ expect(@email_message).to have_body_text('funky fresh')
698
692
  end
699
- it "should not prepend overrides" do
693
+ it 'does not prepend overrides' do
700
694
  expect(@email_message).not_to have_to_username(
701
- "to at sanitize_email.org"
695
+ 'to at sanitize_email.org'
702
696
  )
703
697
  expect(@email_message).not_to have_subject(
704
- "(to at sanitize_email.org)"
698
+ '(to at sanitize_email.org)'
705
699
  )
706
700
  end
707
701
  end
708
- context "to address is not an array" do
702
+ context 'to address is not an array' do
709
703
  before do
710
704
  sanitary_mail_delivery
711
705
  end
712
- it "original to is prepended" do
706
+ it 'original to is prepended' do
713
707
  expect(@email_message).to have_subject(
714
- "(to at example.org) original subject"
708
+ '(to at example.org) original subject'
715
709
  )
716
710
  end
717
- it "should not alter non-sanitized attributes" do
718
- expect(@email_message).to have_from("from@example.org")
719
- expect(@email_message).to have_reply_to("reply_to@example.org")
720
- expect(@email_message).to have_body_text("funky fresh")
711
+ it 'does not alter non-sanitized attributes' do
712
+ expect(@email_message).to have_from('from@example.org')
713
+ expect(@email_message).to have_reply_to('reply_to@example.org')
714
+ expect(@email_message).to have_body_text('funky fresh')
721
715
  end
722
- it "should not prepend overrides" do
716
+ it 'does not prepend overrides' do
723
717
  expect(@email_message).not_to have_to_username(
724
- "to at sanitize_email.org"
718
+ 'to at sanitize_email.org'
725
719
  )
726
720
  expect(@email_message).not_to have_subject(
727
- "(to at sanitize_email.org)"
721
+ '(to at sanitize_email.org)'
728
722
  )
729
723
  end
730
724
  end
731
725
  end
732
- context "false" do
733
- before(:each) do
734
- configure_sanitize_email(use_actual_email_prepended_to_subject: false)
726
+ context 'false' do
727
+ before do
728
+ configure_sanitize_email(:use_actual_email_prepended_to_subject => false)
735
729
  sanitary_mail_delivery
736
730
  end
737
- it "original to is not prepended" do
731
+ it 'original to is not prepended' do
738
732
  expect(@email_message).not_to have_subject(
739
- "(to at example.org) original subject"
733
+ '(to at example.org) original subject'
740
734
  )
741
735
  end
742
- it "should not alter non-sanitized attributes" do
743
- expect(@email_message).to have_from("from@example.org")
744
- expect(@email_message).to have_reply_to("reply_to@example.org")
745
- expect(@email_message).to have_body_text("funky fresh")
736
+ it 'does not alter non-sanitized attributes' do
737
+ expect(@email_message).to have_from('from@example.org')
738
+ expect(@email_message).to have_reply_to('reply_to@example.org')
739
+ expect(@email_message).to have_body_text('funky fresh')
746
740
  end
747
- it "should not prepend overrides" do
741
+ it 'does not prepend overrides' do
748
742
  expect(@email_message).not_to have_to_username(
749
- "to at sanitize_email.org"
743
+ 'to at sanitize_email.org'
750
744
  )
751
745
  expect(@email_message).not_to have_subject(
752
- "(to at sanitize_email.org)"
746
+ '(to at sanitize_email.org)'
753
747
  )
754
748
  end
755
749
  end
756
750
  end
757
751
 
758
- context ":use_actual_email_as_sanitized_user_name" do
759
- context "true" do
760
- before(:each) do
752
+ context ':use_actual_email_as_sanitized_user_name' do
753
+ context 'true' do
754
+ before do
761
755
  configure_sanitize_email(
762
- use_actual_email_as_sanitized_user_name: true
756
+ :use_actual_email_as_sanitized_user_name => true
763
757
  )
764
758
  sanitary_mail_delivery
765
759
  end
766
- it "original to is munged and prepended" do
760
+ it 'original to is munged and prepended' do
767
761
  expect(@email_message).to have_to_username(
768
- "to at example.org <to@sanitize_email.org>"
762
+ 'to at example.org <to@sanitize_email.org>'
769
763
  )
770
764
  end
771
- it "should not alter non-sanitized attributes" do
772
- expect(@email_message).to have_from("from@example.org")
773
- expect(@email_message).to have_reply_to("reply_to@example.org")
774
- expect(@email_message).to have_body_text("funky fresh")
765
+ it 'does not alter non-sanitized attributes' do
766
+ expect(@email_message).to have_from('from@example.org')
767
+ expect(@email_message).to have_reply_to('reply_to@example.org')
768
+ expect(@email_message).to have_body_text('funky fresh')
775
769
  end
776
- it "should not prepend overrides" do
770
+ it 'does not prepend overrides' do
777
771
  expect(@email_message).not_to have_to_username(
778
- "to at sanitize_email.org"
772
+ 'to at sanitize_email.org'
779
773
  )
780
774
  expect(@email_message).not_to have_subject(
781
- "(to at sanitize_email.org)"
775
+ '(to at sanitize_email.org)'
782
776
  )
783
777
  end
784
778
  end
785
- context "false" do
786
- before(:each) do
779
+ context 'false' do
780
+ before do
787
781
  configure_sanitize_email(
788
- use_actual_email_as_sanitized_user_name: false
782
+ :use_actual_email_as_sanitized_user_name => false
789
783
  )
790
784
  sanitary_mail_delivery
791
785
  end
792
- it "original to is not prepended" do
786
+ it 'original to is not prepended' do
793
787
  expect(@email_message).not_to have_to_username(
794
- "to at example.org <to@sanitize_email.org>"
788
+ 'to at example.org <to@sanitize_email.org>'
795
789
  )
796
790
  end
797
- it "should not alter non-sanitized attributes" do
798
- expect(@email_message).to have_from("from@example.org")
799
- expect(@email_message).to have_reply_to("reply_to@example.org")
800
- expect(@email_message).to have_body_text("funky fresh")
791
+ it 'does not alter non-sanitized attributes' do
792
+ expect(@email_message).to have_from('from@example.org')
793
+ expect(@email_message).to have_reply_to('reply_to@example.org')
794
+ expect(@email_message).to have_body_text('funky fresh')
801
795
  end
802
- it "should not prepend overrides" do
796
+ it 'does not prepend overrides' do
803
797
  expect(@email_message).not_to have_to_username(
804
- "to at sanitize_email.org"
798
+ 'to at sanitize_email.org'
805
799
  )
806
800
  expect(@email_message).not_to have_subject(
807
- "(to at sanitize_email.org)"
801
+ '(to at sanitize_email.org)'
808
802
  )
809
803
  end
810
804
  end
811
805
  end
812
806
 
813
- context ":engage" do
814
- context "is true" do
815
- before(:each) do
807
+ context ':engage' do
808
+ context 'is true' do
809
+ before do
816
810
  # Should turn off sanitization using the force_sanitize
817
811
  configure_sanitize_email(
818
- engage: true,
819
- sanitized_recipients: "marv@example.org",
820
- use_actual_email_prepended_to_subject: true,
821
- use_actual_email_as_sanitized_user_name: true
812
+ :engage => true,
813
+ :sanitized_recipients => 'marv@example.org',
814
+ :use_actual_email_prepended_to_subject => true,
815
+ :use_actual_email_as_sanitized_user_name => true
822
816
  )
823
817
  mail_delivery
824
818
  end
825
- it "should not alter non-sanitized attributes" do
826
- expect(@email_message).to have_from("from@example.org")
827
- expect(@email_message).to have_reply_to("reply_to@example.org")
828
- expect(@email_message).to have_body_text("funky fresh")
819
+ it 'does not alter non-sanitized attributes' do
820
+ expect(@email_message).to have_from('from@example.org')
821
+ expect(@email_message).to have_reply_to('reply_to@example.org')
822
+ expect(@email_message).to have_body_text('funky fresh')
829
823
  end
830
- it "should prepend overrides" do
831
- expect(@email_message).to have_to_username("to at example.org")
832
- expect(@email_message).to have_subject("(to at example.org)")
824
+ it 'prepends overrides' do
825
+ expect(@email_message).to have_to_username('to at example.org')
826
+ expect(@email_message).to have_subject('(to at example.org)')
833
827
  end
834
- it "should alter normally sanitized attributes" do
835
- expect(@email_message).not_to have_to("to@example.org")
836
- expect(@email_message).to have_to("marv@example.org")
828
+ it 'alters normally sanitized attributes' do
829
+ expect(@email_message).not_to have_to('to@example.org')
830
+ expect(@email_message).to have_to('marv@example.org')
837
831
  end
838
832
  end
839
- context "is false" do
840
- before(:each) do
833
+ context 'is false' do
834
+ before do
841
835
  # Should turn off sanitization using the force_sanitize
842
836
  configure_sanitize_email(
843
- engage: false,
844
- sanitized_recipients: "marv@example.org",
845
- use_actual_email_prepended_to_subject: true,
846
- use_actual_email_as_sanitized_user_name: true
837
+ :engage => false,
838
+ :sanitized_recipients => 'marv@example.org',
839
+ :use_actual_email_prepended_to_subject => true,
840
+ :use_actual_email_as_sanitized_user_name => true
847
841
  )
848
842
  mail_delivery
849
843
  end
850
- it "should not alter non-sanitized attributes" do
851
- expect(@email_message).to have_from("from@example.org")
852
- expect(@email_message).to have_reply_to("reply_to@example.org")
853
- expect(@email_message).to have_body_text("funky fresh")
844
+ it 'does not alter non-sanitized attributes' do
845
+ expect(@email_message).to have_from('from@example.org')
846
+ expect(@email_message).to have_reply_to('reply_to@example.org')
847
+ expect(@email_message).to have_body_text('funky fresh')
854
848
  end
855
- it "should not prepend overrides" do
856
- expect(@email_message).not_to have_to_username("to at example.org")
857
- expect(@email_message).not_to have_subject("(to at example.org)")
849
+ it 'does not prepend overrides' do
850
+ expect(@email_message).not_to have_to_username('to at example.org')
851
+ expect(@email_message).not_to have_subject('(to at example.org)')
858
852
  end
859
- it "should not alter normally sanitized attributes" do
860
- expect(@email_message).to have_to("to@example.org")
861
- expect(@email_message).not_to have_to("marv@example.org")
853
+ it 'does not alter normally sanitized attributes' do
854
+ expect(@email_message).to have_to('to@example.org')
855
+ expect(@email_message).not_to have_to('marv@example.org')
862
856
  end
863
857
  end
864
858
  end
865
859
 
866
- context "deprecated" do
867
- #before(:each) do
860
+ context 'deprecated' do
861
+ # before(:each) do
868
862
  # SanitizeEmail::Deprecation.deprecate_in_silence = false
869
- #end
870
- context ":local_environments" do
871
- context "matching" do
872
- before(:each) do
873
- configure_sanitize_email(local_environments: ["test"])
874
- expect(SanitizeEmail[:activation_proc].call).to eq(true)
863
+ # end
864
+ context ':local_environments' do
865
+ context 'matching' do
866
+ before do
867
+ configure_sanitize_email(:local_environments => ['test'])
875
868
  mail_delivery
876
869
  end
877
- it "should not alter non-sanitized attributes" do
878
- expect(@email_message).to have_from("from@example.org")
879
- expect(@email_message).to have_reply_to("reply_to@example.org")
880
- expect(@email_message).to have_body_text("funky fresh")
870
+ it 'does not alter non-sanitized attributes' do
871
+ expect(described_class[:activation_proc].call).to eq(true)
872
+ expect(@email_message).to have_from('from@example.org')
873
+ expect(@email_message).to have_reply_to('reply_to@example.org')
874
+ expect(@email_message).to have_body_text('funky fresh')
881
875
  end
882
- it "should use activation_proc for matching environment" do
883
- expect(@email_message).to match_to("to@sanitize_email.org")
884
- expect(@email_message).to match_cc("cc@sanitize_email.org")
885
- expect(@email_message).to match_bcc("bcc@sanitize_email.org")
876
+ it 'uses activation_proc for matching environment' do
877
+ expect(described_class[:activation_proc].call).to eq(true)
878
+ expect(@email_message).to match_to('to@sanitize_email.org')
879
+ expect(@email_message).to match_cc('cc@sanitize_email.org')
880
+ expect(@email_message).to match_bcc('bcc@sanitize_email.org')
886
881
  end
887
882
  end
888
- context "non-matching" do
889
- before(:each) do
890
- sanitize_spec_dryer("production")
883
+ context 'non-matching' do
884
+ before do
885
+ sanitize_spec_dryer('production')
891
886
  # Won't match!
892
- configure_sanitize_email(local_environments: ["development"])
893
- expect(SanitizeEmail[:activation_proc].call).to eq(false)
887
+ configure_sanitize_email(:local_environments => ['development'])
894
888
  mail_delivery
895
889
  end
896
- it "should not alter non-sanitized attributes" do
897
- expect(@email_message).to have_from("from@example.org")
898
- expect(@email_message).to have_reply_to("reply_to@example.org")
899
- expect(@email_message).to have_body_text("funky fresh")
890
+ it 'does not alter non-sanitized attributes' do
891
+ expect(described_class[:activation_proc].call).to eq(false)
892
+ expect(@email_message).to have_from('from@example.org')
893
+ expect(@email_message).to have_reply_to('reply_to@example.org')
894
+ expect(@email_message).to have_body_text('funky fresh')
900
895
  end
901
- it "should use activation_proc for non-matching environment" do
902
- expect(@email_message).to have_to("to@example.org")
903
- expect(@email_message).to have_cc("cc@example.org")
904
- expect(@email_message).to have_bcc("bcc@example.org")
896
+ it 'uses activation_proc for non-matching environment' do
897
+ expect(described_class[:activation_proc].call).to eq(false)
898
+ expect(@email_message).to have_to('to@example.org')
899
+ expect(@email_message).to have_cc('cc@example.org')
900
+ expect(@email_message).to have_bcc('bcc@example.org')
905
901
  end
906
902
  end
907
903
  end
908
904
 
909
- context ":sanitized_recipients" do
910
- before(:each) do
905
+ context ':sanitized_recipients' do
906
+ before do
911
907
  configure_sanitize_email(
912
- sanitized_recipients: "barney@sanitize_email.org"
908
+ :sanitized_recipients => 'barney@sanitize_email.org'
913
909
  )
914
910
  sanitary_mail_delivery
915
911
  end
916
- it "should not alter non-sanitized attributes" do
917
- expect(@email_message).to have_from("from@example.org")
918
- expect(@email_message).to have_reply_to("reply_to@example.org")
919
- expect(@email_message).to have_body_text("funky fresh")
912
+ it 'does not alter non-sanitized attributes' do
913
+ expect(@email_message).to have_from('from@example.org')
914
+ expect(@email_message).to have_reply_to('reply_to@example.org')
915
+ expect(@email_message).to have_body_text('funky fresh')
920
916
  end
921
- it "used as sanitized_to" do
922
- expect(@email_message).to have_to("barney@sanitize_email.org")
917
+ it 'used as sanitized_to' do
918
+ expect(@email_message).to have_to('barney@sanitize_email.org')
923
919
  end
924
920
  end
925
921
 
926
- context ":force_sanitize" do
927
- before(:each) do
922
+ context ':force_sanitize' do
923
+ before do
928
924
  # Should turn off sanitization using the force_sanitize
929
925
  configure_sanitize_email(
930
- activation_proc: proc { true },
931
- force_sanitize: false
926
+ :activation_proc => proc { true },
927
+ :force_sanitize => false
932
928
  )
933
929
  mail_delivery
934
930
  end
935
- it "should not alter non-sanitized attributes" do
936
- expect(@email_message).to have_from("from@example.org")
937
- expect(@email_message).to have_reply_to("reply_to@example.org")
938
- expect(@email_message).to have_body_text("funky fresh")
931
+ it 'does not alter non-sanitized attributes' do
932
+ expect(@email_message).to have_from('from@example.org')
933
+ expect(@email_message).to have_reply_to('reply_to@example.org')
934
+ expect(@email_message).to have_body_text('funky fresh')
939
935
  end
940
- it "should not alter normally sanitized attributes" do
941
- expect(@email_message).to have_to("to@example.org")
936
+ it 'does not alter normally sanitized attributes' do
937
+ expect(@email_message).to have_to('to@example.org')
942
938
  end
943
939
  end
944
940
  end
945
941
  end
946
942
  end
947
943
 
948
- #TODO: test good_list
944
+ # TODO: test good_list