rspec-mail-matchers 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 03250152d487351c2e2151c58fc6637b167a63d5
4
+ data.tar.gz: 304f47e3cb2c480160974f158117a84657508df9
5
+ SHA512:
6
+ metadata.gz: 4cbd8ebccac58c25da4990e71cae8333aa0eff0a8a4133ceb4ce406718495c4b796cc377b21139bed1428b977cf07faf6ec0d591c2933978deb755941be82e9b
7
+ data.tar.gz: e6f78bdd8a62753a68defc7c99faa78f09cf549c23a51e44d83ef0454649fb52bb485f6d82378a47462bb269df8b1f5d95615ef428d1a125e94a971e40218c8d
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rspec-mail-matchers.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Ed Robinson
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,72 @@
1
+ # RSpec Mail Matchers
2
+
3
+ These are some RSpec matchers to be used with the [Mail gem](https://github.com/mikel/mail).
4
+
5
+ The mail gem allready includes some rspec matchers but these are for if you want to use the expect syntax in your specs.
6
+
7
+ You can make assertions against a specific Mail::Message, but there is no functionality for finding the message for you like the included matchers.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile in the test group:
12
+
13
+ gem 'rspec-mail-matchers'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+
23
+ describe 'sending an email' do
24
+
25
+ end
26
+ ```
27
+ Mail.defaults do
28
+ delivery_method :test # in practice you'd do this in spec_helper.rb
29
+ end
30
+
31
+ describe "sending an email" do
32
+ before(:each) do
33
+ Mail::TestMailer.deliveries.clear
34
+
35
+ Mail.deliver do
36
+ to ['ed@reevoo.com', 'foo@bar.com']
37
+ from 'test@example.com'
38
+ subject 'testing'
39
+
40
+ text_part do
41
+ body 'This is plain text'
42
+ end
43
+
44
+ html_part do
45
+ content_type 'text/html; charset=UTF-8'
46
+ body '<h1>This is HTML</h1>'
47
+ end
48
+ end
49
+ end
50
+
51
+ let(:email) { Mail::TestMailer.deliveries.last }
52
+
53
+ specify { expect(email).to be_to('ed@reevoo.com') } }
54
+
55
+ specify { expect(email).to be_to('foo@bar.com') }
56
+
57
+ specify { expect(email).to be_to('foo@bar.com', 'ed@reevoo.com') }
58
+
59
+ it 'has a text and a html part' do
60
+ expect(email).to have_html_body('<h1>This is HTML</h1>')
61
+ expect(email).to have_text_body('This is plain text')
62
+ end
63
+
64
+ end
65
+
66
+ # Contributing
67
+
68
+ 1. Fork it ( http://github.com/reevoo/rspec-mail-matchers/fork )
69
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
70
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
71
+ 4. Push to the branch (`git push origin my-new-feature`)
72
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,54 @@
1
+ require 'rspec/expectations'
2
+
3
+ RSpec::Matchers.define :be_to do |*expected|
4
+ match do |actual|
5
+ expected.all? { |e| actual.to.include?(e) }
6
+ end
7
+
8
+ failure_message do |actual|
9
+ "To: #{actual.to.join(', ')} should include #{expected.join(' and ')}"
10
+ end
11
+ end
12
+
13
+ RSpec::Matchers.define :be_from do |*expected|
14
+ match do |actual|
15
+ expected.all? { |e| actual.from.include?(e) }
16
+ end
17
+
18
+ failure_message do |actual|
19
+ "From: #{actual.from.join(', ')} should include #{expected.join(' and ')}"
20
+ end
21
+ end
22
+
23
+ RSpec::Matchers.define :be_cc_to do |*expected|
24
+ match do |actual|
25
+ expected.all? { |e| actual.cc.include?(e) }
26
+ end
27
+
28
+ failure_message do |actual|
29
+ "Cc: #{actual.cc.join(', ')} should include #{expected.join(' and ')}"
30
+ end
31
+ end
32
+
33
+ RSpec::Matchers.define :be_cc_to do |*expected|
34
+ match do |actual|
35
+ expected.all? { |e| actual.bcc.include?(e) }
36
+ end
37
+
38
+ failure_message do |actual|
39
+ "Cc: #{actual.bcc.join(', ')} should include #{expected.join(' and ')}"
40
+ end
41
+ end
42
+
43
+
44
+ RSpec::Matchers.define :have_text_body do |expected|
45
+ match do |actual|
46
+ actual.text_part.body == expected
47
+ end
48
+ end
49
+
50
+ RSpec::Matchers.define :have_html_body do |expected|
51
+ match do |actual|
52
+ actual.html_part.body == expected
53
+ end
54
+ end
@@ -0,0 +1,7 @@
1
+ module Rspec
2
+ module Mail
3
+ module Matchers
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rspec-mail-matchers/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rspec-mail-matchers"
8
+ spec.version = Rspec::Mail::Matchers::VERSION
9
+ spec.authors = ["Ed Robinson"]
10
+ spec.email = ["ed.robinson@reevoo.com"]
11
+ spec.summary = %q{ RSpec Matchers for the Mail gem}
12
+ spec.homepage = "http://reevoo.github.io"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "rspec-expectations", "> 2.11"
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-mail-matchers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ed Robinson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec-expectations
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.11'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - ed.robinson@reevoo.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/rspec-mail-matchers.rb
68
+ - lib/rspec-mail-matchers/version.rb
69
+ - rspec-mail-matchers.gemspec
70
+ homepage: http://reevoo.github.io
71
+ licenses:
72
+ - MIT
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 2.4.5
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: RSpec Matchers for the Mail gem
94
+ test_files: []