email-test-helpers 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.yardopts +1 -0
- data/LICENSE +10 -0
- data/README.markdown +33 -0
- data/email-test-helpers.gemspec +19 -0
- data/lib/cody_robbins/email_test_helpers/matchers.rb +71 -0
- data/lib/cody_robbins/email_test_helpers/methods.rb +17 -0
- data/lib/email-test-helpers.rb +9 -0
- metadata +76 -0
data/.gitignore
ADDED
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--charset UTF-8 --markup markdown lib/**/*.rb - LICENSE
|
data/LICENSE
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
The MIT License
|
2
|
+
===============
|
3
|
+
|
4
|
+
© 2011 Cody Robbins
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
7
|
+
|
8
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
9
|
+
|
10
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
Email Test Helpers
|
2
|
+
==================
|
3
|
+
|
4
|
+
This gem provides some simple helpers for [RSpec](http://relishapp.com/rspec) and [Cucumber](http://cukes.info/) for testing ActionMailer deliveries.
|
5
|
+
|
6
|
+
Full documentation is at [RubyDoc.info](http://rubydoc.info/gems/email-test-helpers).
|
7
|
+
|
8
|
+
Colophon
|
9
|
+
--------
|
10
|
+
|
11
|
+
### See also
|
12
|
+
|
13
|
+
If you like this gem, you may also want to check out: [Static Model](http://codyrobbins.com/software/static-model), [Active Model Email Validator](http://codyrobbins.com/software/active-model-email-validator), or [HTTP Error](http://codyrobbins.com/software/http-error).
|
14
|
+
|
15
|
+
### Tested with
|
16
|
+
|
17
|
+
* RSpec 2.6.0 — 20 May 2011
|
18
|
+
* Cucumber 0.10.3 — 20 May 2011
|
19
|
+
|
20
|
+
### Contributing
|
21
|
+
|
22
|
+
* [Source](https://github.com/codyrobbins/email-test-helpers)
|
23
|
+
* [Bug reports](https://github.com/codyrobbins/email-test-helpers/issues)
|
24
|
+
|
25
|
+
To send patches, please fork on GitHub and submit a pull request.
|
26
|
+
|
27
|
+
### Credits
|
28
|
+
|
29
|
+
© 2011 [Cody Robbins](http://codyrobbins.com/). See LICENSE for details.
|
30
|
+
|
31
|
+
* [Homepage](http://codyrobbins.com/software/email-test-helpers)
|
32
|
+
* [My other gems](http://codyrobbins.com/software#gems)
|
33
|
+
* [Follow me on Twitter](http://twitter.com/codyrobbins)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'email-test-helpers'
|
3
|
+
s.version = '1.0.0'
|
4
|
+
s.summary = 'Some helpers for RSpec and Cucumber for testing ActionMailer email delivery.'
|
5
|
+
s.homepage = 'http://codyrobbins.com/software/email-test-helpers'
|
6
|
+
s.author = 'Cody Robbins'
|
7
|
+
s.email = 'cody@codyrobbins.com'
|
8
|
+
|
9
|
+
s.post_install_message = '
|
10
|
+
-------------------------------------------------------------
|
11
|
+
Follow me on Twitter! http://twitter.com/codyrobbins
|
12
|
+
-------------------------------------------------------------
|
13
|
+
|
14
|
+
'
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split
|
17
|
+
|
18
|
+
s.add_dependency('rspec', '>= 2')
|
19
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module CodyRobbins
|
2
|
+
module EmailTestHelpers
|
3
|
+
module Matchers
|
4
|
+
# @method be_sent_to(address)
|
5
|
+
#
|
6
|
+
# Verifies the address an email is sent to.
|
7
|
+
#
|
8
|
+
# @param address [String] The email address.
|
9
|
+
#
|
10
|
+
# @return [RSpec::Matchers::Matcher]
|
11
|
+
#
|
12
|
+
# @example
|
13
|
+
# last_email.should.be_sent_to 'dagny@taggart.com'
|
14
|
+
RSpec::Matchers.define(:be_sent_to) do |address|
|
15
|
+
match do |mail|
|
16
|
+
mail.to.should == [address]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# @method be_sent_from_address(address)
|
21
|
+
#
|
22
|
+
# Verifies the address an email is sent from.
|
23
|
+
#
|
24
|
+
# @param address [String] The email address.
|
25
|
+
#
|
26
|
+
# @return [RSpec::Matchers::Matcher]
|
27
|
+
#
|
28
|
+
# @example
|
29
|
+
# last_email.should.be_sent_from_address 'dagny@taggart.com'
|
30
|
+
RSpec::Matchers.define(:be_sent_from_address) do |address|
|
31
|
+
match do |mail|
|
32
|
+
mail.from.should == [address]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# @method be_sent_from_display_name(name)
|
37
|
+
#
|
38
|
+
# Verifies the display name an email is sent from. The display name is the optional text outside the angle brackets in a `From` header such as `Dagny Taggart <dagny@taggart.com>`.
|
39
|
+
#
|
40
|
+
# @param name [String] The display name.
|
41
|
+
#
|
42
|
+
# @return [RSpec::Matchers::Matcher]
|
43
|
+
#
|
44
|
+
# @example
|
45
|
+
# last_email.should.be_sent_from_display_name 'Dagny Taggart'
|
46
|
+
RSpec::Matchers.define(:be_sent_from_display_name) do |name|
|
47
|
+
match do |mail|
|
48
|
+
mail[:from].display_names.should == [name]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# @method be_sent_from(name, address)
|
53
|
+
#
|
54
|
+
# Verifies both the address and display name an email is sent from. This just combines the `be_sent_from_address` and `be_sent_from_display_name` matchers.
|
55
|
+
#
|
56
|
+
# @param name [String] The display name.
|
57
|
+
# @param address [String] The email address.
|
58
|
+
#
|
59
|
+
# @return [RSpec::Matchers::Matcher]
|
60
|
+
#
|
61
|
+
# @example
|
62
|
+
# last_email.should.be_sent_from 'Dagny Taggart', 'dagny@taggart.com'
|
63
|
+
RSpec::Matchers.define(:be_sent_from) do |name, address|
|
64
|
+
match do |mail|
|
65
|
+
mail.should be_sent_from_display_name name
|
66
|
+
mail.should be_sent_from_address address
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module CodyRobbins
|
2
|
+
module EmailTestHelpers
|
3
|
+
module Methods
|
4
|
+
# A more readable alias for `ActionMailer::Base.deliveries`.
|
5
|
+
#
|
6
|
+
# @return [Array] All emails sent by ActionMailer.
|
7
|
+
def emails
|
8
|
+
ActionMailer::Base.deliveries
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [Mail::Message] The last email sent by ActionMailer.
|
12
|
+
def last_email
|
13
|
+
emails.first
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require('rspec')
|
2
|
+
|
3
|
+
require('cody_robbins/email_test_helpers/methods')
|
4
|
+
require('cody_robbins/email_test_helpers/matchers')
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
config.include(CodyRobbins::EmailTestHelpers::Methods)
|
8
|
+
config.include(CodyRobbins::EmailTestHelpers::Matchers)
|
9
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: email-test-helpers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 1.0.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Cody Robbins
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-06-01 00:00:00 -04:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rspec
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "2"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
description:
|
28
|
+
email: cody@codyrobbins.com
|
29
|
+
executables: []
|
30
|
+
|
31
|
+
extensions: []
|
32
|
+
|
33
|
+
extra_rdoc_files: []
|
34
|
+
|
35
|
+
files:
|
36
|
+
- .gitignore
|
37
|
+
- .yardopts
|
38
|
+
- LICENSE
|
39
|
+
- README.markdown
|
40
|
+
- email-test-helpers.gemspec
|
41
|
+
- lib/cody_robbins/email_test_helpers/matchers.rb
|
42
|
+
- lib/cody_robbins/email_test_helpers/methods.rb
|
43
|
+
- lib/email-test-helpers.rb
|
44
|
+
has_rdoc: true
|
45
|
+
homepage: http://codyrobbins.com/software/email-test-helpers
|
46
|
+
licenses: []
|
47
|
+
|
48
|
+
post_install_message: "\n\
|
49
|
+
-------------------------------------------------------------\n\
|
50
|
+
Follow me on Twitter! http://twitter.com/codyrobbins\n\
|
51
|
+
-------------------------------------------------------------\n\n"
|
52
|
+
rdoc_options: []
|
53
|
+
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "0"
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
requirements: []
|
69
|
+
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 1.6.2
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: Some helpers for RSpec and Cucumber for testing ActionMailer email delivery.
|
75
|
+
test_files: []
|
76
|
+
|