email_spec 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,15 @@
1
+ == 1.5.0 2012-07-22
2
+
3
+ * Upgraded use of Capybara to avoid deprecation warnings.
4
+ * Upgraded use of RSpec to deal with new expect API (Thomas Drake-Brockman)
5
+
6
+ === New features
7
+ * visit_in_email now works for emails that are not the current_email (Ernesto Tagwerker)
8
+ * emails can be found based on :from field (John Cant)
9
+
10
+ === Bug fixes
11
+ * Emails that are not found when clicking a link now raise an exception. (Adam Berlin & Alex Kramer)
12
+
1
13
  == 1.4.0 2012-10-30
2
14
 
3
15
  * removed jeweler in favor of just using bundler for all gem management.
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  ## Email Spec
5
5
 
6
- A collection of RSpec matchers and Cucumber steps to make testing emails go smoothly.
6
+ A collection of matchers for RSpec/MiniTest and Cucumber steps to make testing emails go smoothly.
7
7
 
8
8
  This library works with ActionMailer and Pony. When using it with ActionMailer it works with
9
9
  DelayedJob, ActiveRecord Mailer, and action_mailer_cache_delivery.
@@ -1,4 +1,4 @@
1
- require 'uri'
1
+ require 'uri'
2
2
  require 'email_spec/deliveries'
3
3
 
4
4
  module EmailSpec
@@ -6,8 +6,13 @@ module EmailSpec
6
6
  module Helpers
7
7
  include Deliveries
8
8
 
9
- def visit_in_email(link_text)
10
- visit(parse_email_for_link(current_email, link_text))
9
+ def visit_in_email(link_text, address = '')
10
+ if address.nil? || address.empty?
11
+ email = current_email
12
+ else
13
+ email = find_email!(address)
14
+ end
15
+ visit(parse_email_for_link(email, link_text))
11
16
  end
12
17
 
13
18
  def click_email_link_matching(regex, email = current_email)
@@ -63,6 +68,8 @@ module EmailSpec
63
68
  elsif opts[:with_text]
64
69
  expected_text = (opts[:with_text].is_a?(String) ? Regexp.escape(opts[:with_text]) : opts[:with_text])
65
70
  mailbox_for(address).find { |m| m.default_part_body =~ Regexp.new(expected_text) }
71
+ elsif opts[:from]
72
+ mailbox_for(address).find { |m| m.from.include? opts[:from] }
66
73
  else
67
74
  mailbox_for(address).first
68
75
  end
@@ -81,7 +88,7 @@ module EmailSpec
81
88
  def find_email!(address, opts={})
82
89
  email = find_email(address, opts)
83
90
  if current_email_address.nil?
84
- raise EmailSpec::NoEmailAddressProvided, "No email address has been provided. Make sure current_email_address is returning something."
91
+ raise EmailSpec::NoEmailAddressProvided, "No email address has been provided. Make sure current_email_address is returning something."
85
92
  elsif email.nil?
86
93
  error = "#{opts.keys.first.to_s.humanize.downcase unless opts.empty?} #{('"' + opts.values.first.to_s + '"') unless opts.empty?}"
87
94
  raise EmailSpec::CouldNotFindEmailError, "Could not find email #{error} in the mailbox for #{current_email_address}. \n Found the following emails:\n\n #{all_emails.to_s}"
@@ -99,7 +106,8 @@ module EmailSpec
99
106
  end
100
107
 
101
108
  def parse_email_for_link(email, text_or_regex)
102
- email.should have_body_text(text_or_regex)
109
+ matcher = EmailSpec::Matchers::HaveBodyText.new(text_or_regex)
110
+ RSpec::Expectations::PositiveExpectationHandler.handle_matcher(email, matcher)
103
111
 
104
112
  url = parse_email_for_explicit_link(email, text_or_regex)
105
113
  url ||= parse_email_for_anchor_text_link(email, text_or_regex)
@@ -175,8 +175,8 @@ end
175
175
  # Interact with Email Contents
176
176
  #
177
177
 
178
- When /^(?:I|they) follow "([^"]*?)" in the email$/ do |link|
179
- visit_in_email(link)
178
+ When /^(?:I|they|"([^"]*?)") follows? "([^"]*?)" in the email$/ do |address, link|
179
+ visit_in_email(link, address)
180
180
  end
181
181
 
182
182
  When /^(?:I|they) click the first link in the email$/ do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: email_spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-04-08 00:00:00.000000000 Z
14
+ date: 2012-07-22 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: launchy
@@ -116,7 +116,7 @@ dependencies:
116
116
  requirements:
117
117
  - - ! '>='
118
118
  - !ruby/object:Gem::Version
119
- version: 2.0.1
119
+ version: 2.14.0
120
120
  type: :development
121
121
  prerelease: false
122
122
  version_requirements: !ruby/object:Gem::Requirement
@@ -124,7 +124,7 @@ dependencies:
124
124
  requirements:
125
125
  - - ! '>='
126
126
  - !ruby/object:Gem::Version
127
- version: 2.0.1
127
+ version: 2.14.0
128
128
  - !ruby/object:Gem::Dependency
129
129
  name: delayed_job
130
130
  requirement: !ruby/object:Gem::Requirement
@@ -285,7 +285,7 @@ dependencies:
285
285
  - - ! '>='
286
286
  - !ruby/object:Gem::Version
287
287
  version: '0'
288
- description: Easily test email in rspec and cucumber
288
+ description: Easily test email in RSpec, Cucumber, and MiniTest
289
289
  email: ben@benmabey.com
290
290
  executables: []
291
291
  extensions: []
@@ -337,6 +337,6 @@ rubyforge_project: email-spec
337
337
  rubygems_version: 1.8.23
338
338
  signing_key:
339
339
  specification_version: 3
340
- summary: Easily test email in rspec and cucumber
340
+ summary: Easily test email in rspec and cucumber and minitest
341
341
  test_files: []
342
342
  has_rdoc: