email_spec 0.6.6 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. data/History.txt +21 -26
  2. data/README.rdoc +5 -3
  3. data/Rakefile +16 -27
  4. data/examples/rails3_root/Gemfile +17 -0
  5. data/examples/rails3_root/Gemfile.lock +138 -0
  6. data/examples/rails3_root/README +5 -0
  7. data/examples/rails3_root/Rakefile +11 -0
  8. data/examples/rails3_root/app/controllers/application_controller.rb +3 -0
  9. data/examples/rails3_root/app/controllers/welcome_controller.rb +16 -0
  10. data/examples/rails3_root/app/helpers/application_helper.rb +2 -0
  11. data/examples/rails3_root/app/mailers/user_mailer.rb +39 -0
  12. data/examples/{rails_root → rails3_root}/app/models/user.rb +0 -0
  13. data/examples/{rails_root/app/views/user_mailer/attachments.erb → rails3_root/app/views/user_mailer/attachments.html.erb} +0 -0
  14. data/examples/{rails_root/app/views/user_mailer/newsletter.erb → rails3_root/app/views/user_mailer/newsletter.html.erb} +0 -0
  15. data/examples/{rails_root/app/views/user_mailer/signup.erb → rails3_root/app/views/user_mailer/signup.html.erb} +1 -0
  16. data/examples/rails3_root/app/views/user_mailer/signup.text.erb +4 -0
  17. data/examples/{rails_root → rails3_root}/app/views/welcome/attachments.html.erb +0 -0
  18. data/examples/{rails_root → rails3_root}/app/views/welcome/confirm.html.erb +0 -0
  19. data/examples/{rails_root → rails3_root}/app/views/welcome/index.html.erb +1 -1
  20. data/examples/{rails_root → rails3_root}/app/views/welcome/newsletter.html.erb +0 -0
  21. data/examples/{rails_root → rails3_root}/app/views/welcome/signup.html.erb +0 -0
  22. data/examples/{rails_root → rails3_root}/attachments/document.pdf +0 -0
  23. data/examples/{rails_root → rails3_root}/attachments/image.png +0 -0
  24. data/examples/rails3_root/config.ru +4 -0
  25. data/examples/rails3_root/config/application.rb +43 -0
  26. data/examples/rails3_root/config/boot.rb +14 -0
  27. data/examples/rails3_root/config/cucumber.yml +8 -0
  28. data/examples/{rails_root → rails3_root}/config/database.yml +0 -0
  29. data/examples/rails3_root/config/environment.rb +6 -0
  30. data/examples/rails3_root/config/environments/development.rb +20 -0
  31. data/examples/rails3_root/config/environments/production.rb +42 -0
  32. data/examples/rails3_root/config/environments/test.rb +30 -0
  33. data/examples/rails3_root/config/initializers/backtrace_silencers.rb +7 -0
  34. data/examples/rails3_root/config/initializers/cookie_verification_secret.rb +7 -0
  35. data/examples/rails3_root/config/initializers/delayed_job.rb +1 -0
  36. data/examples/{rails_root → rails3_root}/config/initializers/inflections.rb +0 -0
  37. data/examples/{rails_root → rails3_root}/config/initializers/mime_types.rb +0 -0
  38. data/examples/rails3_root/config/initializers/notifier_job.rb +1 -0
  39. data/examples/rails3_root/config/initializers/rspec_generator.rb +6 -0
  40. data/examples/rails3_root/config/initializers/session_store.rb +10 -0
  41. data/examples/rails3_root/config/locales/en.yml +5 -0
  42. data/examples/rails3_root/config/routes.rb +7 -0
  43. data/examples/{rails_root → rails3_root}/db/migrate/20090125013728_create_users.rb +0 -0
  44. data/examples/{rails_root → rails3_root}/db/migrate/20090908054656_create_delayed_jobs.rb +0 -0
  45. data/examples/{rails_root → rails3_root}/db/schema.rb +7 -6
  46. data/examples/rails3_root/db/seeds.rb +7 -0
  47. data/examples/rails3_root/doc/README_FOR_APP +2 -0
  48. data/examples/{rails_root → rails3_root}/features/attachments.feature +0 -0
  49. data/examples/{rails_root → rails3_root}/features/delayed_job.feature +0 -0
  50. data/examples/{rails_root → rails3_root}/features/errors.feature +0 -0
  51. data/examples/{sinatra → rails3_root}/features/example.feature +9 -0
  52. data/examples/{rails_root → rails3_root}/features/step_definitions/user_steps.rb +2 -2
  53. data/examples/rails3_root/features/step_definitions/web_steps.rb +219 -0
  54. data/examples/{rails_root → rails3_root}/features/support/env.rb +10 -10
  55. data/examples/rails3_root/features/support/env_ext.rb +2 -0
  56. data/examples/{rails_root → rails3_root}/features/support/paths.rb +2 -2
  57. data/examples/rails3_root/lib/notifier_job.rb +5 -0
  58. data/examples/{rails_root → rails3_root}/lib/tasks/cucumber.rake +6 -0
  59. data/examples/rails3_root/lib/tasks/rspec.rake +69 -0
  60. data/examples/rails3_root/public/404.html +26 -0
  61. data/examples/rails3_root/public/422.html +26 -0
  62. data/examples/rails3_root/public/500.html +26 -0
  63. data/examples/{rails_root → rails3_root}/public/favicon.ico +0 -0
  64. data/examples/{rails_root → rails3_root}/public/images/rails.png +0 -0
  65. data/examples/{rails_root → rails3_root}/public/javascripts/application.js +0 -0
  66. data/examples/{rails_root → rails3_root}/public/javascripts/controls.js +5 -3
  67. data/examples/{rails_root → rails3_root}/public/javascripts/dragdrop.js +7 -6
  68. data/examples/{rails_root → rails3_root}/public/javascripts/effects.js +8 -13
  69. data/examples/{rails_root → rails3_root}/public/javascripts/prototype.js +1573 -1019
  70. data/examples/rails3_root/public/javascripts/rails.js +109 -0
  71. data/examples/{rails_root → rails3_root}/public/robots.txt +0 -0
  72. data/examples/{rails_root → rails3_root}/script/cucumber +0 -0
  73. data/examples/rails3_root/script/rails +9 -0
  74. data/examples/rails3_root/spec/controllers/welcome_controller_spec.rb +20 -0
  75. data/examples/{rails_root → rails3_root}/spec/models/user_mailer_spec.rb +7 -18
  76. data/examples/rails3_root/spec/spec_helper.rb +19 -0
  77. data/examples/sinatra_root/config.ru +4 -0
  78. data/examples/{sinatra → sinatra_root}/features/errors.feature +0 -0
  79. data/examples/{rails_root → sinatra_root}/features/example.feature +0 -0
  80. data/examples/{sinatra → sinatra_root}/features/step_definitions/user_steps.rb +2 -2
  81. data/examples/sinatra_root/features/step_definitions/web_steps.rb +219 -0
  82. data/examples/sinatra_root/features/support/env.rb +21 -0
  83. data/examples/{sinatra → sinatra_root}/features/support/paths.rb +9 -4
  84. data/examples/sinatra_root/lib/example_sinatra_app.rb +35 -0
  85. data/lib/email_spec.rb +2 -2
  86. data/lib/email_spec/deliveries.rb +7 -11
  87. data/lib/email_spec/email_viewer.rb +1 -1
  88. data/lib/email_spec/helpers.rb +7 -7
  89. data/lib/email_spec/mail_ext.rb +11 -0
  90. data/lib/email_spec/matchers.rb +31 -26
  91. data/lib/generators/email_spec/steps/USAGE +5 -0
  92. data/lib/generators/email_spec/steps/steps_generator.rb +14 -0
  93. data/{examples/rails3_root/features/step_definitions → lib/generators/email_spec/steps/templates}/email_steps.rb +0 -0
  94. data/spec/email_spec/helpers_spec.rb +4 -6
  95. data/spec/email_spec/mail_ext_spec.rb +34 -0
  96. data/spec/email_spec/matchers_spec.rb +227 -37
  97. data/spec/spec_helper.rb +14 -2
  98. metadata +174 -207
  99. data/examples/rails_root/Rakefile +0 -13
  100. data/examples/rails_root/app/controllers/application_controller.rb +0 -15
  101. data/examples/rails_root/app/controllers/welcome_controller.rb +0 -16
  102. data/examples/rails_root/app/helpers/application_helper.rb +0 -3
  103. data/examples/rails_root/app/helpers/welcome_helper.rb +0 -2
  104. data/examples/rails_root/app/models/user_mailer.rb +0 -39
  105. data/examples/rails_root/config/boot.rb +0 -110
  106. data/examples/rails_root/config/cucumber.yml +0 -7
  107. data/examples/rails_root/config/environment.rb +0 -28
  108. data/examples/rails_root/config/environments/cucumber.rb +0 -29
  109. data/examples/rails_root/config/environments/development.rb +0 -17
  110. data/examples/rails_root/config/environments/production.rb +0 -28
  111. data/examples/rails_root/config/environments/test.rb +0 -28
  112. data/examples/rails_root/config/initializers/new_rails_defaults.rb +0 -17
  113. data/examples/rails_root/config/routes.rb +0 -45
  114. data/examples/rails_root/doc/README_FOR_APP +0 -5
  115. data/examples/rails_root/features/step_definitions/web_steps.rb +0 -273
  116. data/examples/rails_root/features/support/env_ext.rb +0 -6
  117. data/examples/rails_root/public/404.html +0 -30
  118. data/examples/rails_root/public/422.html +0 -30
  119. data/examples/rails_root/public/500.html +0 -33
  120. data/examples/rails_root/public/dispatch.rb +0 -10
  121. data/examples/rails_root/script/about +0 -4
  122. data/examples/rails_root/script/autospec +0 -5
  123. data/examples/rails_root/script/console +0 -3
  124. data/examples/rails_root/script/dbconsole +0 -3
  125. data/examples/rails_root/script/delayed_job +0 -5
  126. data/examples/rails_root/script/destroy +0 -3
  127. data/examples/rails_root/script/generate +0 -3
  128. data/examples/rails_root/script/performance/benchmarker +0 -3
  129. data/examples/rails_root/script/performance/profiler +0 -3
  130. data/examples/rails_root/script/performance/request +0 -3
  131. data/examples/rails_root/script/plugin +0 -3
  132. data/examples/rails_root/script/process/inspector +0 -3
  133. data/examples/rails_root/script/process/reaper +0 -3
  134. data/examples/rails_root/script/process/spawner +0 -3
  135. data/examples/rails_root/script/runner +0 -3
  136. data/examples/rails_root/script/server +0 -3
  137. data/examples/rails_root/script/spec +0 -5
  138. data/examples/rails_root/script/spec_server +0 -125
  139. data/examples/rails_root/spec/controllers/welcome_controller_spec.rb +0 -15
  140. data/examples/rails_root/spec/model_factory.rb +0 -6
  141. data/examples/rails_root/spec/models/user_spec.rb +0 -5
  142. data/examples/rails_root/spec/rcov.opts +0 -2
  143. data/examples/rails_root/spec/spec.opts +0 -4
  144. data/examples/rails_root/spec/spec_helper.rb +0 -51
  145. data/examples/sinatra/app.rb +0 -33
  146. data/examples/sinatra/features/step_definitions/email_steps.rb +0 -182
  147. data/examples/sinatra/features/step_definitions/web_steps.rb +0 -273
  148. data/examples/sinatra/features/support/env.rb +0 -39
  149. data/examples/sinatra_root/features/step_definitions/email_steps.rb +0 -194
  150. data/lib/email_spec/#helpers.rb# +0 -168
  151. data/spec/spec.opts +0 -4
@@ -1,39 +0,0 @@
1
- # Sinatra configuration - http://wiki.github.com/aslakhellesoy/cucumber/sinatra
2
- ENV["RAILS_ENV"] ||= "cucumber"
3
- app_file = File.expand_path(File.dirname(__FILE__) + '/../../app.rb')
4
- require app_file
5
- # Force the application name because polyglot breaks the auto-detection logic.
6
- Sinatra::Application.app_file = app_file
7
-
8
- require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
9
- require 'cucumber/web/tableish'
10
-
11
- require 'spec/expectations'
12
- require 'rack/test'
13
- require 'test/unit'
14
- require 'webrat'
15
-
16
- Webrat.configure do |config|
17
- config.mode = :rack
18
- config.open_error_files = false # Set to true if you want error pages to pop up in the browser
19
- end
20
-
21
- # email testing in cucumber
22
- require 'activesupport'
23
- require File.expand_path(File.dirname(__FILE__) + '../../../../../lib/email_spec')
24
- require 'email_spec/cucumber'
25
-
26
- class AppWorld
27
- include Rack::Test::Methods
28
- include Test::Unit::Assertions
29
- include Webrat::Methods
30
- include Webrat::Matchers
31
-
32
- Webrat::Methods.delegate_to_session :response_code, :response_body
33
-
34
- def app
35
- Sinatra::Application.new
36
- end
37
- end
38
-
39
- World { AppWorld.new }
@@ -1,194 +0,0 @@
1
- # Commonly used email steps
2
- #
3
- # To add your own steps make a custom_email_steps.rb
4
- # The provided methods are:
5
- #
6
- # last_email_address
7
- # reset_mailer
8
- # open_last_email
9
- # visit_in_email
10
- # unread_emails_for
11
- # mailbox_for
12
- # current_email
13
- # open_email
14
- # read_emails_for
15
- # find_email
16
- #
17
- # General form for email scenarios are:
18
- # - clear the email queue (done automatically by email_spec)
19
- # - execute steps that sends an email
20
- # - check the user received an/no/[0-9] emails
21
- # - open the email
22
- # - inspect the email contents
23
- # - interact with the email (e.g. click links)
24
- #
25
- # The Cucumber steps below are setup in this order.
26
-
27
- module EmailHelpers
28
- def current_email_address
29
- # Replace with your a way to find your current email. e.g @current_user.email
30
- # last_email_address will return the last email address used by email spec to find an email.
31
- # Note that last_email_address will be reset after each Scenario.
32
- last_email_address || "example@example.com"
33
- end
34
- end
35
-
36
- World(EmailHelpers)
37
-
38
- #
39
- # Reset the e-mail queue within a scenario.
40
- # This is done automatically before each scenario.
41
- #
42
-
43
- Given /^(?:a clear email queue|no emails have been sent)$/ do
44
- reset_mailer
45
- end
46
-
47
- #
48
- # Check how many emails have been sent/received
49
- #
50
-
51
- Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails?$/ do |address, amount|
52
- unread_emails_for(address).size.should == parse_email_count(amount)
53
- end
54
-
55
- Then /^(?:I|they|"([^"]*?)") should have (an|no|\d+) emails?$/ do |address, amount|
56
- mailbox_for(address).size.should == parse_email_count(amount)
57
- end
58
-
59
- Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails? with subject "([^"]*?)"$/ do |address, amount, subject|
60
- unread_emails_for(address).select { |m| m.subject =~ Regexp.new(subject) }.size.should == parse_email_count(amount)
61
- end
62
-
63
- Then /^(?:I|they|"([^"]*?)") should receive an email with the following body:$/ do |address, expected_body|
64
- open_email(address, :with_text => expected_body)
65
- end
66
-
67
- #
68
- # Accessing emails
69
- #
70
-
71
- # Opens the most recently received email
72
- When /^(?:I|they|"([^"]*?)") opens? the email$/ do |address|
73
- open_email(address)
74
- end
75
-
76
- When /^(?:I|they|"([^"]*?)") opens? the email with subject "([^"]*?)"$/ do |address, subject|
77
- open_email(address, :with_subject => subject)
78
- end
79
-
80
- When /^(?:I|they|"([^"]*?)") opens? the email with text "([^"]*?)"$/ do |address, text|
81
- open_email(address, :with_text => text)
82
- end
83
-
84
- #
85
- # Inspect the Email Contents
86
- #
87
-
88
- Then /^(?:I|they) should see "([^"]*?)" in the email subject$/ do |text|
89
- current_email.should have_subject(text)
90
- end
91
-
92
- Then /^(?:I|they) should see \/([^"]*?)\/ in the email subject$/ do |text|
93
- current_email.should have_subject(Regexp.new(text))
94
- end
95
-
96
- Then /^(?:I|they) should see "([^"]*?)" in the email body$/ do |text|
97
- current_email.default_part_body.to_s.should include(text)
98
- end
99
-
100
- Then /^(?:I|they) should see \/([^"]*?)\/ in the email body$/ do |text|
101
- current_email.default_part_body.to_s.should =~ Regexp.new(text)
102
- end
103
-
104
- Then /^(?:I|they) should see the email delivered from "([^"]*?)"$/ do |text|
105
- current_email.should be_delivered_from(text)
106
- end
107
-
108
- Then /^(?:I|they) should see "([^\"]*)" in the email "([^"]*?)" header$/ do |text, name|
109
- current_email.should have_header(name, text)
110
- end
111
-
112
- Then /^(?:I|they) should see \/([^\"]*)\/ in the email "([^"]*?)" header$/ do |text, name|
113
- current_email.should have_header(name, Regexp.new(text))
114
- end
115
-
116
- Then /^I should see it is a multi\-part email$/ do
117
- current_email.should be_multipart
118
- end
119
-
120
- Then /^(?:I|they) should see "([^"]*?)" in the email html part body$/ do |text|
121
- current_email.html_part.body.to_s.should include(text)
122
- end
123
-
124
- Then /^(?:I|they) should see "([^"]*?)" in the email text part body$/ do |text|
125
- current_email.text_part.body.to_s.should include(text)
126
- end
127
-
128
- #
129
- # Inspect the Email Attachments
130
- #
131
-
132
- Then /^(?:I|they) should see (an|no|\d+) attachments? with the email$/ do |amount|
133
- current_email_attachments.size.should == parse_email_count(amount)
134
- end
135
-
136
- Then /^there should be (an|no|\d+) attachments? named "([^"]*?)"$/ do |amount, filename|
137
- current_email_attachments.select { |a| a.filename == filename }.size.should == parse_email_count(amount)
138
- end
139
-
140
- Then /^attachment (\d+) should be named "([^"]*?)"$/ do |index, filename|
141
- current_email_attachments[(index.to_i - 1)].filename.should == filename
142
- end
143
-
144
- Then /^there should be (an|no|\d+) attachments? of type "([^"]*?)"$/ do |amount, content_type|
145
- current_email_attachments.select { |a| a.content_type.include?(content_type) }.size.should == parse_email_count(amount)
146
- end
147
-
148
- Then /^attachment (\d+) should be of type "([^"]*?)"$/ do |index, content_type|
149
- current_email_attachments[(index.to_i - 1)].content_type.should include(content_type)
150
- end
151
-
152
- Then /^all attachments should not be blank$/ do
153
- current_email_attachments.each do |attachment|
154
- attachment.read.size.should_not == 0
155
- end
156
- end
157
-
158
- Then /^show me a list of email attachments$/ do
159
- EmailSpec::EmailViewer::save_and_open_email_attachments_list(current_email)
160
- end
161
-
162
- #
163
- # Interact with Email Contents
164
- #
165
-
166
- When /^(?:I|they) follow "([^"]*?)" in the email$/ do |link|
167
- visit_in_email(link)
168
- end
169
-
170
- When /^(?:I|they) click the first link in the email$/ do
171
- click_first_link_in_email
172
- end
173
-
174
- #
175
- # Debugging
176
- # These only work with Rails and OSx ATM since EmailViewer uses RAILS_ROOT and OSx's 'open' command.
177
- # Patches accepted. ;)
178
- #
179
-
180
- Then /^save and open current email$/ do
181
- EmailSpec::EmailViewer::save_and_open_email(current_email)
182
- end
183
-
184
- Then /^save and open all text emails$/ do
185
- EmailSpec::EmailViewer::save_and_open_all_text_emails
186
- end
187
-
188
- Then /^save and open all html emails$/ do
189
- EmailSpec::EmailViewer::save_and_open_all_html_emails
190
- end
191
-
192
- Then /^save and open all raw emails$/ do
193
- EmailSpec::EmailViewer::save_and_open_all_raw_emails
194
- end
@@ -1,168 +0,0 @@
1
- require 'uri'
2
- require 'email_spec/deliveries'
3
-
4
- module EmailSpec
5
-
6
- module Helpers
7
- include Deliveries
8
-
9
- def visit_in_email(link_text, opts={})
10
- visit(parse_email_for_link(current_email, link_text, opts))
11
- end
12
-
13
- def click_email_link_matching(regex, email = current_email)
14
- url = links_in_email(email).detect { |link| link =~ regex }
15
- raise "No link found matching #{regex.inspect} in #{email.default_part_body}" unless url
16
- visit request_uri(url)
17
- end
18
-
19
- def click_first_link_in_email(email = current_email, opts={})
20
- link = links_in_email(email).first
21
- visit request_uri(link, opts)
22
- end
23
-
24
- def open_email(address, opts={})
25
- set_current_email(find_email!(address, opts))
26
- end
27
-
28
- alias_method :open_email_for, :open_email
29
-
30
- def open_last_email
31
- set_current_email(last_email_sent)
32
- end
33
-
34
- def open_last_email_for(address)
35
- set_current_email(mailbox_for(address).last)
36
- end
37
-
38
- def current_email(address=nil)
39
- address = convert_address(address)
40
- email = address ? email_spec_hash[:current_emails][address] : email_spec_hash[:current_email]
41
- raise RSpec::Expectations::ExpectationNotMetError, "Expected an open email but none was found. Did you forget to call open_email?" unless email
42
- email
43
- end
44
-
45
- def current_email_attachments(address=nil)
46
- current_email(address).attachments || Array.new
47
- end
48
-
49
- def unread_emails_for(address)
50
- mailbox_for(address) - read_emails_for(address)
51
- end
52
-
53
- def read_emails_for(address)
54
- email_spec_hash[:read_emails][convert_address(address)] ||= []
55
- end
56
-
57
- def find_email(address, opts={})
58
- address = convert_address(address)
59
- if opts[:with_subject]
60
- mailbox_for(address).find { |m| m.subject =~ Regexp.new(opts[:with_subject]) }
61
- elsif opts[:with_text]
62
- mailbox_for(address).find { |m| m.default_part_body =~ Regexp.new(opts[:with_text]) }
63
- else
64
- mailbox_for(address).first
65
- end
66
- end
67
-
68
- def links_in_email(email)
69
- URI.extract(email.default_part_body.to_s, ['http', 'https'])
70
- end
71
-
72
- private
73
-
74
- def email_spec_hash
75
- @email_spec_hash ||= {:read_emails => {}, :unread_emails => {}, :current_emails => {}, :current_email => nil}
76
- end
77
-
78
- def find_email!(address, opts={})
79
- email = find_email(address, opts)
80
- if email.nil?
81
- error = "#{opts.keys.first.to_s.humanize unless opts.empty?} #{('"' + opts.values.first.to_s.humanize + '"') unless opts.empty?}"
82
- raise RSpec::Expectations::ExpectationNotMetError, "Could not find email #{error}. \n Found the following emails:\n\n #{all_emails.to_s}"
83
- end
84
- email
85
- end
86
-
87
- def set_current_email(email)
88
- return unless email
89
- [email.to, email.cc, email.bcc].compact.flatten.each do |to|
90
- read_emails_for(to) << email
91
- email_spec_hash[:current_emails][to] = email
92
- end
93
- email_spec_hash[:current_email] = email
94
- end
95
-
96
- def parse_email_for_link(email, text_or_regex, opts={})
97
- email.should have_body_text(text_or_regex)
98
-
99
- url = parse_email_for_explicit_link(email, text_or_regex, opts)
100
- url ||= parse_email_for_anchor_text_link(email, text_or_regex, opts)
101
-
102
- raise "No link found matching #{text_or_regex.inspect} in #{email}" unless url
103
- url
104
- end
105
-
106
- def request_uri(link, opts={})
107
- return unless link
108
- url = URI::parse(link)
109
- # url.fragment ? (url.request_uri + "#" + url.fragment) : url.request_uri
110
- path = url.fragment ? (url.request_uri + "#" + url.fragment) : url.request_uri
111
- opts[:path_only] != false ? path : url.to_s
112
- end
113
-
114
- # e.g. confirm in http://confirm
115
- def parse_email_for_explicit_link(email, regex, opts={})
116
- regex = /#{Regexp.escape(regex)}/ unless regex.is_a?(Regexp)
117
- url = links_in_email(email).detect { |link| link =~ regex }
118
- request_uri(url, opts)
119
- end
120
-
121
- # e.g. Click here in <a href="http://confirm">Click here</a>
122
- def parse_email_for_anchor_text_link(email, link_text, opts={})
123
- if textify_images(email.default_part_body) =~ %r{<a[^>]*href=['"]?([^'"]*)['"]?[^>]*?>[^<]*?#{link_text}[^<]*?</a>}
124
- url = $1
125
- path = URI.split(url)[5..-1].compact!.join("?").gsub("&amp;", "&")
126
- opts[:path_only] ? path : url.to_s
127
- # sub correct ampersand after rails switches it (http://dev.rubyonrails.org/ticket/4002)
128
- else
129
- return nil
130
- end
131
- end
132
-
133
- def textify_images(email_body)
134
- email_body.to_s.gsub(%r{<img[^>]*alt=['"]?([^'"]*)['"]?[^>]*?/>}) { $1 }
135
- end
136
-
137
- def parse_email_count(amount)
138
- case amount
139
- when "no"
140
- 0
141
- when "an"
142
- 1
143
- else
144
- amount.to_i
145
- end
146
- end
147
-
148
- attr_reader :last_email_address
149
-
150
- def convert_address(address)
151
- @last_email_address = (address || current_email_address)
152
- AddressConverter.instance.convert(@last_email_address)
153
- end
154
-
155
-
156
- def mailbox_for(address)
157
- super(convert_address(address)) # super resides in Deliveries
158
- end
159
-
160
- def email_spec_deprecate(text)
161
- puts ""
162
- puts "DEPRECATION: #{text.split.join(' ')}"
163
- puts ""
164
- end
165
-
166
- end
167
- end
168
-
@@ -1,4 +0,0 @@
1
- --colour
2
- --format s
3
- --loadby mtime
4
- --reverse