email_spec 1.2.1 → 1.4.0
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.
- data/History.txt +17 -1
- data/README.md +340 -0
- data/Rakefile +3 -50
- data/lib/email_spec.rb +3 -2
- data/lib/email_spec/email_viewer.rb +10 -6
- data/lib/email_spec/errors.rb +7 -0
- data/lib/email_spec/helpers.rb +5 -3
- data/lib/email_spec/matchers.rb +166 -66
- data/rails_generators/email_spec/templates/email_steps.rb +1 -1
- metadata +290 -236
- data/README.rdoc +0 -148
- data/examples/rails3_root/Gemfile +0 -17
- data/examples/rails3_root/Gemfile.lock +0 -135
- data/examples/rails3_root/README +0 -5
- data/examples/rails3_root/Rakefile +0 -11
- data/examples/rails3_root/app/controllers/application_controller.rb +0 -3
- data/examples/rails3_root/app/controllers/welcome_controller.rb +0 -16
- data/examples/rails3_root/app/helpers/application_helper.rb +0 -2
- data/examples/rails3_root/app/mailers/user_mailer.rb +0 -39
- data/examples/rails3_root/app/models/user.rb +0 -2
- data/examples/rails3_root/app/views/user_mailer/attachments.html.erb +0 -6
- data/examples/rails3_root/app/views/user_mailer/newsletter.html.erb +0 -8
- data/examples/rails3_root/app/views/user_mailer/signup.html.erb +0 -4
- data/examples/rails3_root/app/views/user_mailer/signup.text.erb +0 -4
- data/examples/rails3_root/app/views/welcome/attachments.html.erb +0 -0
- data/examples/rails3_root/app/views/welcome/confirm.html.erb +0 -1
- data/examples/rails3_root/app/views/welcome/index.html.erb +0 -8
- data/examples/rails3_root/app/views/welcome/newsletter.html.erb +0 -0
- data/examples/rails3_root/app/views/welcome/signup.html.erb +0 -1
- data/examples/rails3_root/attachments/document.pdf +0 -0
- data/examples/rails3_root/attachments/image.png +0 -0
- data/examples/rails3_root/config.ru +0 -4
- data/examples/rails3_root/config/application.rb +0 -43
- data/examples/rails3_root/config/boot.rb +0 -14
- data/examples/rails3_root/config/cucumber.yml +0 -8
- data/examples/rails3_root/config/database.yml +0 -25
- data/examples/rails3_root/config/environment.rb +0 -6
- data/examples/rails3_root/config/environments/development.rb +0 -20
- data/examples/rails3_root/config/environments/production.rb +0 -42
- data/examples/rails3_root/config/environments/test.rb +0 -30
- data/examples/rails3_root/config/initializers/backtrace_silencers.rb +0 -7
- data/examples/rails3_root/config/initializers/cookie_verification_secret.rb +0 -7
- data/examples/rails3_root/config/initializers/delayed_job.rb +0 -1
- data/examples/rails3_root/config/initializers/inflections.rb +0 -10
- data/examples/rails3_root/config/initializers/mime_types.rb +0 -5
- data/examples/rails3_root/config/initializers/notifier_job.rb +0 -1
- data/examples/rails3_root/config/initializers/rspec_generator.rb +0 -6
- data/examples/rails3_root/config/initializers/session_store.rb +0 -10
- data/examples/rails3_root/config/locales/en.yml +0 -5
- data/examples/rails3_root/config/routes.rb +0 -7
- data/examples/rails3_root/db/migrate/20090125013728_create_users.rb +0 -11
- data/examples/rails3_root/db/migrate/20090908054656_create_delayed_jobs.rb +0 -20
- data/examples/rails3_root/db/schema.rb +0 -33
- data/examples/rails3_root/db/seeds.rb +0 -7
- data/examples/rails3_root/doc/README_FOR_APP +0 -2
- data/examples/rails3_root/features/attachments.feature +0 -27
- data/examples/rails3_root/features/delayed_job.feature +0 -13
- data/examples/rails3_root/features/errors.feature +0 -40
- data/examples/rails3_root/features/example.feature +0 -93
- data/examples/rails3_root/features/step_definitions/user_steps.rb +0 -26
- data/examples/rails3_root/features/step_definitions/web_steps.rb +0 -219
- data/examples/rails3_root/features/support/env.rb +0 -58
- data/examples/rails3_root/features/support/env_ext.rb +0 -2
- data/examples/rails3_root/features/support/paths.rb +0 -33
- data/examples/rails3_root/lib/notifier_job.rb +0 -5
- data/examples/rails3_root/lib/tasks/cucumber.rake +0 -53
- data/examples/rails3_root/lib/tasks/rspec.rake +0 -69
- data/examples/rails3_root/public/404.html +0 -26
- data/examples/rails3_root/public/422.html +0 -26
- data/examples/rails3_root/public/500.html +0 -26
- data/examples/rails3_root/public/favicon.ico +0 -0
- data/examples/rails3_root/public/images/rails.png +0 -0
- data/examples/rails3_root/public/javascripts/application.js +0 -2
- data/examples/rails3_root/public/javascripts/controls.js +0 -965
- data/examples/rails3_root/public/javascripts/dragdrop.js +0 -974
- data/examples/rails3_root/public/javascripts/effects.js +0 -1123
- data/examples/rails3_root/public/javascripts/prototype.js +0 -4874
- data/examples/rails3_root/public/javascripts/rails.js +0 -109
- data/examples/rails3_root/public/robots.txt +0 -5
- data/examples/rails3_root/script/cucumber +0 -10
- data/examples/rails3_root/script/rails +0 -9
- data/examples/rails3_root/spec/controllers/welcome_controller_spec.rb +0 -20
- data/examples/rails3_root/spec/models/user_mailer_spec.rb +0 -47
- data/examples/rails3_root/spec/spec_helper.rb +0 -19
- data/examples/sinatra_root/config.ru +0 -4
- data/examples/sinatra_root/features/errors.feature +0 -40
- data/examples/sinatra_root/features/example.feature +0 -93
- data/examples/sinatra_root/features/step_definitions/user_steps.rb +0 -26
- data/examples/sinatra_root/features/step_definitions/web_steps.rb +0 -219
- data/examples/sinatra_root/features/support/env.rb +0 -21
- data/examples/sinatra_root/features/support/paths.rb +0 -29
- data/examples/sinatra_root/lib/example_sinatra_app.rb +0 -45
- data/install.rb +0 -0
- data/spec/email_spec/helpers_spec.rb +0 -220
- data/spec/email_spec/mail_ext_spec.rb +0 -34
- data/spec/email_spec/matchers_spec.rb +0 -486
- data/spec/spec_helper.rb +0 -16
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# Generated by cucumber-sinatra. (Tue Jul 27 10:45:23 -0400 2010)
|
|
2
|
-
|
|
3
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'lib/example_sinatra_app.rb')
|
|
4
|
-
require 'capybara'
|
|
5
|
-
require 'capybara/cucumber'
|
|
6
|
-
require 'rspec/core'
|
|
7
|
-
#require 'activesupport'
|
|
8
|
-
require File.expand_path(File.dirname(__FILE__) + '../../../../../lib/email_spec')
|
|
9
|
-
require 'email_spec/cucumber'
|
|
10
|
-
|
|
11
|
-
ExampleSinatraApp.set(:environment, :test)
|
|
12
|
-
|
|
13
|
-
Capybara.app = ExampleSinatraApp
|
|
14
|
-
|
|
15
|
-
class ExampleSinatraAppWorld
|
|
16
|
-
include Capybara
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
World do
|
|
20
|
-
ExampleSinatraAppWorld.new
|
|
21
|
-
end
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# Taken from the cucumber-rails project.
|
|
2
|
-
|
|
3
|
-
module NavigationHelpers
|
|
4
|
-
# Maps a name to a path. Used by the
|
|
5
|
-
#
|
|
6
|
-
# When /^I go to (.+)$/ do |page_name|
|
|
7
|
-
#
|
|
8
|
-
# step definition in web_steps.rb
|
|
9
|
-
#
|
|
10
|
-
def path_to(page_name)
|
|
11
|
-
case page_name
|
|
12
|
-
|
|
13
|
-
when /the home\s?page/
|
|
14
|
-
'/'
|
|
15
|
-
|
|
16
|
-
# Add more mappings here.
|
|
17
|
-
# Here is an example that pulls values out of the Regexp:
|
|
18
|
-
#
|
|
19
|
-
# when /^(.*)'s profile page$/i
|
|
20
|
-
# user_profile_path(User.find_by_login($1))
|
|
21
|
-
|
|
22
|
-
else
|
|
23
|
-
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
|
24
|
-
"Now, go and add a mapping in #{__FILE__}"
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
World(NavigationHelpers)
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
require 'sinatra/base'
|
|
2
|
-
require 'pony'
|
|
3
|
-
|
|
4
|
-
class ExampleSinatraApp < Sinatra::Base
|
|
5
|
-
get '/' do
|
|
6
|
-
<<-EOHTML
|
|
7
|
-
<form method="post" action="/signup">
|
|
8
|
-
<label for="Name">Name</label>
|
|
9
|
-
<input type="text" id="Name" name="user[name]">
|
|
10
|
-
<label for="Email">Email</label>
|
|
11
|
-
<input type="text" id="Email" name="user[email]">
|
|
12
|
-
<input type="submit" value="Sign up">
|
|
13
|
-
</form>
|
|
14
|
-
EOHTML
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
post '/signup' do
|
|
18
|
-
user = params[:user]
|
|
19
|
-
body = <<-EOTEXT
|
|
20
|
-
Hello #{user['name']}!
|
|
21
|
-
|
|
22
|
-
Copy and paste this URL into your browser to confirm your account!
|
|
23
|
-
|
|
24
|
-
http://www.example.com/confirm
|
|
25
|
-
This is the text part.
|
|
26
|
-
EOTEXT
|
|
27
|
-
html_body = <<-EOHTML
|
|
28
|
-
Hello #{user['name']}!
|
|
29
|
-
|
|
30
|
-
<a href="http://www.example.com/confirm">Click here to confirm your account!</a>
|
|
31
|
-
This is the HTML part.
|
|
32
|
-
EOHTML
|
|
33
|
-
Pony.mail(:from => 'admin@example.com',
|
|
34
|
-
:to => user['email'],
|
|
35
|
-
:subject => 'Account confirmation',
|
|
36
|
-
:body => body,
|
|
37
|
-
:html_body => html_body
|
|
38
|
-
)
|
|
39
|
-
'Thanks! Go check your email!'
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
get '/confirm' do
|
|
43
|
-
'Confirm your new account!'
|
|
44
|
-
end
|
|
45
|
-
end
|
data/install.rb
DELETED
|
File without changes
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
-
|
|
3
|
-
describe EmailSpec::Helpers do
|
|
4
|
-
include EmailSpec::Helpers
|
|
5
|
-
describe "#parse_email_for_link" do
|
|
6
|
-
it "properly finds links with text" do
|
|
7
|
-
email = Mail.new(:body => %(<a href="/path/to/page">Click Here</a>))
|
|
8
|
-
parse_email_for_link(email, "Click Here").should == "/path/to/page"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it "recognizes img alt properties as text" do
|
|
12
|
-
email = Mail.new(:body => %(<a href="/path/to/page"><img src="http://host.com/images/image.gif" alt="an image" /></a>))
|
|
13
|
-
parse_email_for_link(email, "an image").should == "/path/to/page"
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "causes a spec to fail if the body doesn't contain the text specified to click" do
|
|
17
|
-
email = Mail.new(:body => "")
|
|
18
|
-
lambda { parse_email_for_link(email, "non-existent text") }.should raise_error( RSpec::Expectations::ExpectationNotMetError)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
describe "#set_current_email" do
|
|
23
|
-
it "should cope with a nil email" do
|
|
24
|
-
lambda do
|
|
25
|
-
out = set_current_email(nil)
|
|
26
|
-
out.should be_nil
|
|
27
|
-
email_spec_hash[:current_email].should be_nil
|
|
28
|
-
end.should_not raise_error
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it "should cope with a real email" do
|
|
32
|
-
email = Mail.new
|
|
33
|
-
lambda do
|
|
34
|
-
out = set_current_email(email)
|
|
35
|
-
out.should == email
|
|
36
|
-
email_spec_hash[:current_email].should == email
|
|
37
|
-
end.should_not raise_error
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
shared_examples_for 'something that sets the current email for recipients' do
|
|
41
|
-
before do
|
|
42
|
-
@email = Mail.new(@recipient_type => 'dave@example.com')
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it "should record that the email has been read for that recipient" do
|
|
46
|
-
set_current_email(@email)
|
|
47
|
-
email_spec_hash[:read_emails]['dave@example.com'].should include(@email)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it "should record that the email has been read for all the recipient of that type" do
|
|
51
|
-
@email.send(@recipient_type) << 'dave_2@example.com'
|
|
52
|
-
set_current_email(@email)
|
|
53
|
-
email_spec_hash[:read_emails]['dave@example.com'].should include(@email)
|
|
54
|
-
email_spec_hash[:read_emails]['dave_2@example.com'].should include(@email)
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
it "should record that the email is the current email for the recipient" do
|
|
58
|
-
set_current_email(@email)
|
|
59
|
-
email_spec_hash[:current_emails]['dave@example.com'].should == @email
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
it "should record that the email is the current email for all the recipients of that type" do
|
|
63
|
-
@email.send(@recipient_type) << 'dave_2@example.com'
|
|
64
|
-
set_current_email(@email)
|
|
65
|
-
email_spec_hash[:current_emails]['dave@example.com'].should == @email
|
|
66
|
-
email_spec_hash[:current_emails]['dave_2@example.com'].should == @email
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
it "should overwrite current email for the recipient with this one" do
|
|
70
|
-
other_mail = Mail.new
|
|
71
|
-
email_spec_hash[:current_emails]['dave@example.com'] = other_mail
|
|
72
|
-
set_current_email(@email)
|
|
73
|
-
email_spec_hash[:current_emails]['dave@example.com'].should == @email
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
it "should overwrite the current email for all the recipients of that type" do
|
|
77
|
-
other_mail = Mail.new
|
|
78
|
-
email_spec_hash[:current_emails]['dave@example.com'] = other_mail
|
|
79
|
-
email_spec_hash[:current_emails]['dave_2@example.com'] = other_mail
|
|
80
|
-
@email.send(@recipient_type) << 'dave_2@example.com'
|
|
81
|
-
set_current_email(@email)
|
|
82
|
-
email_spec_hash[:current_emails]['dave@example.com'].should == @email
|
|
83
|
-
email_spec_hash[:current_emails]['dave_2@example.com'].should == @email
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
it "should not complain when the email has recipients of that type" do
|
|
87
|
-
@email.send(:"#{@recipient_type}=", nil)
|
|
88
|
-
lambda { set_current_email(@email) }.should_not raise_error
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
describe "#request_uri(link)" do
|
|
93
|
-
context "without query and anchor" do
|
|
94
|
-
it "returns the path" do
|
|
95
|
-
request_uri('http://www.path.se/to/page').should == '/to/page'
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
context "with query and anchor" do
|
|
100
|
-
it "returns the path and query and the anchor" do
|
|
101
|
-
request_uri('http://www.path.se/to/page?q=adam#task').should == '/to/page?q=adam#task'
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
context "with anchor" do
|
|
106
|
-
it "returns the path and query and the anchor" do
|
|
107
|
-
request_uri('http://www.path.se/to/page#task').should == '/to/page#task'
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
describe 'for mails with recipients in the to address' do
|
|
113
|
-
before do
|
|
114
|
-
@recipient_type = :to
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
it_should_behave_like 'something that sets the current email for recipients'
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
describe 'for mails with recipients in the cc address' do
|
|
121
|
-
before do
|
|
122
|
-
@recipient_type = :cc
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
it_should_behave_like 'something that sets the current email for recipients'
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
describe 'for mails with recipients in the bcc address' do
|
|
129
|
-
before do
|
|
130
|
-
@recipient_type = :bcc
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
it_should_behave_like 'something that sets the current email for recipients'
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
describe '#open_email' do
|
|
138
|
-
describe 'with subject' do
|
|
139
|
-
shared_examples_for 'something that opens the email with subject' do
|
|
140
|
-
before do
|
|
141
|
-
@to = "jimmy_bean@yahoo.com"
|
|
142
|
-
@email = Mail::Message.new(:to => @to, :subject => @subject)
|
|
143
|
-
stub!(:mailbox_for).with(@to).and_return([@email])
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
it "should open the email with subject" do
|
|
147
|
-
open_email(@to, :with_subject => @expected).should == @email
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
describe 'simple string subject' do
|
|
152
|
-
before do
|
|
153
|
-
@subject = 'This is a simple subject'
|
|
154
|
-
@expected = 'a simple'
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
it_should_behave_like 'something that opens the email with subject'
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
describe 'string with regex sensitive characters' do
|
|
161
|
-
before do
|
|
162
|
-
@subject = '[app name] Contains regex characters?'
|
|
163
|
-
@expected = 'regex characters?'
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
it_should_behave_like 'something that opens the email with subject'
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
describe 'regular expression' do
|
|
170
|
-
before do
|
|
171
|
-
@subject = "This is a simple subject"
|
|
172
|
-
@expected = /a simple/
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
it_should_behave_like 'something that opens the email with subject'
|
|
176
|
-
end
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
describe 'with text' do
|
|
180
|
-
shared_examples_for 'something that opens the email with text' do
|
|
181
|
-
before do
|
|
182
|
-
@to = "jimmy_bean@yahoo.com"
|
|
183
|
-
@email = Mail::Message.new(:to => @to, :body => @body)
|
|
184
|
-
stub!(:mailbox_for).with(@to).and_return([@email])
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
it "should open the email with text" do
|
|
188
|
-
open_email(@to, :with_text => @text).should == @email
|
|
189
|
-
end
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
describe 'simple string text' do
|
|
193
|
-
before do
|
|
194
|
-
@body = 'This is an email body that is very simple'
|
|
195
|
-
@text = 'email body'
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
it_should_behave_like 'something that opens the email with text'
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
describe 'string with regex sensitive characters' do
|
|
202
|
-
before do
|
|
203
|
-
@body = 'This is an email body. It contains some [regex] characters?'
|
|
204
|
-
@text = '[regex] characters?'
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
it_should_behave_like 'something that opens the email with text'
|
|
208
|
-
end
|
|
209
|
-
|
|
210
|
-
describe 'regular expression' do
|
|
211
|
-
before do
|
|
212
|
-
@body = 'This is an email body.'
|
|
213
|
-
@text = /an\ email/
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
it_should_behave_like 'something that opens the email with text'
|
|
217
|
-
end
|
|
218
|
-
end
|
|
219
|
-
end
|
|
220
|
-
end
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe EmailSpec::MailExt do
|
|
4
|
-
describe "#default_part" do
|
|
5
|
-
it "prefers html_part over text_part" do
|
|
6
|
-
email = Mail.new do
|
|
7
|
-
text_part { body "This is text" }
|
|
8
|
-
html_part { body "This is html" }
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
email.default_part.body.to_s.should == "This is html"
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it "returns text_part if html_part not available" do
|
|
15
|
-
email = Mail.new do
|
|
16
|
-
text_part { body "This is text" }
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
email.default_part.body.to_s.should == "This is text"
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it "returns the email if not multi-part" do
|
|
23
|
-
email = Mail.new { body "This is the body" }
|
|
24
|
-
email.default_part.body.to_s.should == "This is the body"
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
describe "#default_part_body" do
|
|
29
|
-
it "returns default_part.body" do
|
|
30
|
-
email = Mail.new(:body => "hi")
|
|
31
|
-
email.default_part.body.should == email.default_part_body
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
@@ -1,486 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
-
|
|
3
|
-
describe EmailSpec::Matchers do
|
|
4
|
-
include EmailSpec::Matchers
|
|
5
|
-
|
|
6
|
-
class MatcherMatch
|
|
7
|
-
def initialize(object_to_test_match)
|
|
8
|
-
@object_to_test_match = object_to_test_match
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def description
|
|
12
|
-
"match when provided #{@object_to_test_match.inspect}"
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def matches?(matcher)
|
|
16
|
-
@matcher = matcher
|
|
17
|
-
matcher.matches?(@object_to_test_match)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def failure_message
|
|
21
|
-
"expected #{@matcher.inspect} to match when provided #{@object_to_test_match.inspect}, but it did not"
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def negative_failure_message
|
|
25
|
-
"expected #{@matcher.inspect} not to match when provided #{@object_to_test_match.inspect}, but it did"
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def match(object_to_test_match)
|
|
30
|
-
if object_to_test_match.is_a?(Regexp)
|
|
31
|
-
super # delegate to rspec's built in 'match' matcher
|
|
32
|
-
else
|
|
33
|
-
MatcherMatch.new(object_to_test_match)
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
describe "#reply_to" do
|
|
38
|
-
it "should match when the email is set to deliver to the specified address" do
|
|
39
|
-
email = Mail::Message.new(:reply_to => ["test@gmail.com"])
|
|
40
|
-
reply_to("test@gmail.com").should match(email)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it "should match given a name and address" do
|
|
44
|
-
email = Mail::Message.new(:reply_to => ["test@gmail.com"])
|
|
45
|
-
reply_to("David Balatero <test@gmail.com>").should match(email)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it "should give correct failure message when the email is not set to deliver to the specified address" do
|
|
49
|
-
matcher = reply_to("jimmy_bean@yahoo.com")
|
|
50
|
-
matcher.matches?(Mail::Message.new(:reply_to => ['freddy_noe@yahoo.com']).with_inspect_stub)
|
|
51
|
-
matcher.failure_message.should == %{expected email to reply to "jimmy_bean@yahoo.com", but it replied to "freddy_noe@yahoo.com"}
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
describe "#deliver_to" do
|
|
57
|
-
it "should match when the email is set to deliver to the specified address" do
|
|
58
|
-
email = Mail::Message.new(:to => "jimmy_bean@yahoo.com")
|
|
59
|
-
|
|
60
|
-
deliver_to("jimmy_bean@yahoo.com").should match(email)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it "should match when the email is set to deliver to the specified name and address" do
|
|
64
|
-
email = Mail::Message.new(:to => "Jimmy Bean <jimmy_bean@yahoo.com>")
|
|
65
|
-
deliver_to("Jimmy Bean <jimmy_bean@yahoo.com>").should match(email)
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
it "should match when a list of emails is exact same as all of the email's recipients" do
|
|
69
|
-
email = Mail::Message.new(:to => ["james@yahoo.com", "karen@yahoo.com"])
|
|
70
|
-
|
|
71
|
-
deliver_to("karen@yahoo.com", "james@yahoo.com").should match(email)
|
|
72
|
-
deliver_to("karen@yahoo.com").should_not match(email)
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
it "should match when an array of emails is exact same as all of the email's recipients" do
|
|
76
|
-
addresses = ["james@yahoo.com", "karen@yahoo.com"]
|
|
77
|
-
email = Mail::Message.new(:to => addresses)
|
|
78
|
-
deliver_to(addresses).should match(email)
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
it "should match when the names and email addresses match in any order" do
|
|
82
|
-
addresses = ["James <james@yahoo.com>", "Karen <karen@yahoo.com>"]
|
|
83
|
-
email = Mail::Message.new(:to => addresses.reverse)
|
|
84
|
-
deliver_to(addresses).should match(email)
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
it "should use the passed in objects :email method if not a string" do
|
|
88
|
-
email = Mail::Message.new(:to => "jimmy_bean@yahoo.com")
|
|
89
|
-
user = mock("user", :email => "jimmy_bean@yahoo.com")
|
|
90
|
-
|
|
91
|
-
deliver_to(user).should match(email)
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
it "should not match when the email does not have a recipient" do
|
|
95
|
-
email = Mail::Message.new(:to => nil)
|
|
96
|
-
deliver_to("jimmy_bean@yahoo.com").should_not match(email)
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
it "should not match when the email addresses match but the names do not" do
|
|
100
|
-
email = Mail::Message.new(:to => "Jimmy Bean <jimmy_bean@yahoo.com>")
|
|
101
|
-
deliver_to("Freddy Noe <jimmy_bean@yahoo.com>").should_not match(email)
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
it "should not match when the names match but the email addresses do not" do
|
|
105
|
-
email = Mail::Message.new(:to => "Jimmy Bean <jimmy_bean@yahoo.com>")
|
|
106
|
-
deliver_to("Jimmy Bean <freddy_noe@yahoo.com>").should_not match(email)
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
it "should give correct failure message when the email is not set to deliver to the specified address" do
|
|
110
|
-
matcher = deliver_to("jimmy_bean@yahoo.com")
|
|
111
|
-
message = Mail::Message.new(:to => 'freddy_noe@yahoo.com')
|
|
112
|
-
message.stub(:inspect).and_return("email")
|
|
113
|
-
matcher.matches?(message)
|
|
114
|
-
matcher.failure_message.should == %{expected email to deliver to ["jimmy_bean@yahoo.com"], but it delivered to ["freddy_noe@yahoo.com"]}
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
describe "#deliver_from" do
|
|
120
|
-
it "should match when the email is set to deliver from the specified address" do
|
|
121
|
-
email = Mail::Message.new(:from => "jimmy_bean@yahoo.com")
|
|
122
|
-
deliver_from("jimmy_bean@yahoo.com").should match(email)
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
it "should match when the email is set to deliver from the specified name and address" do
|
|
126
|
-
email = Mail::Message.new(:from => "Jimmy Bean <jimmy_bean@yahoo.com>")
|
|
127
|
-
deliver_from("Jimmy Bean <jimmy_bean@yahoo.com>").should match(email)
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
it "should not match when the email does not have a sender" do
|
|
131
|
-
email = Mail::Message.new(:from => nil)
|
|
132
|
-
deliver_from("jimmy_bean@yahoo.com").should_not match(email)
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
it "should not match when the email addresses match but the names do not" do
|
|
136
|
-
email = Mail::Message.new(:from => "Jimmy Bean <jimmy_bean@yahoo.com>")
|
|
137
|
-
deliver_from("Freddy Noe <jimmy_bean@yahoo.com>").should_not match(email)
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
it "should not match when the names match but the email addresses do not" do
|
|
141
|
-
email = Mail::Message.new(:from => "Jimmy Bean <jimmy_bean@yahoo.com>")
|
|
142
|
-
deliver_from("Jimmy Bean <freddy_noe@yahoo.com>").should_not match(email)
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
it "should not match when the email is not set to deliver from the specified address" do
|
|
146
|
-
email = Mail::Message.new(:from => "freddy_noe@yahoo.com")
|
|
147
|
-
deliver_from("jimmy_bean@yahoo.com").should_not match(email)
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
it "should give correct failure message when the email is not set to deliver from the specified address" do
|
|
151
|
-
matcher = deliver_from("jimmy_bean@yahoo.com")
|
|
152
|
-
matcher.matches?(Mail::Message.new(:from => "freddy_noe@yahoo.com"))
|
|
153
|
-
matcher.failure_message.should =~ /expected .+ to deliver from "jimmy_bean@yahoo\.com", but it delivered from "freddy_noe@yahoo\.com"/
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
describe "#bcc_to" do
|
|
159
|
-
|
|
160
|
-
it "should match when the email is set to deliver to the specidied address" do
|
|
161
|
-
email = Mail::Message.new(:bcc => "jimmy_bean@yahoo.com")
|
|
162
|
-
|
|
163
|
-
bcc_to("jimmy_bean@yahoo.com").should match(email)
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
it "should match when a list of emails is exact same as all of the email's recipients" do
|
|
167
|
-
email = Mail::Message.new(:bcc => ["james@yahoo.com", "karen@yahoo.com"])
|
|
168
|
-
|
|
169
|
-
bcc_to("karen@yahoo.com", "james@yahoo.com").should match(email)
|
|
170
|
-
bcc_to("karen@yahoo.com").should_not match(email)
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
it "should match when an array of emails is exact same as all of the email's recipients" do
|
|
174
|
-
addresses = ["james@yahoo.com", "karen@yahoo.com"]
|
|
175
|
-
email = Mail::Message.new(:bcc => addresses)
|
|
176
|
-
bcc_to(addresses).should match(email)
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
it "should use the passed in objects :email method if not a string" do
|
|
180
|
-
email = Mail::Message.new(:bcc => "jimmy_bean@yahoo.com")
|
|
181
|
-
user = mock("user", :email => "jimmy_bean@yahoo.com")
|
|
182
|
-
|
|
183
|
-
bcc_to(user).should match(email)
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
describe "#cc_to" do
|
|
189
|
-
|
|
190
|
-
it "should match when the email is set to deliver to the specified address" do
|
|
191
|
-
email = Mail::Message.new(:cc => "jimmy_bean@yahoo.com")
|
|
192
|
-
|
|
193
|
-
cc_to("jimmy_bean@yahoo.com").should match(email)
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
it "should match when a list of emails is exact same as all of the email's recipients" do
|
|
197
|
-
email = Mail::Message.new(:cc => ["james@yahoo.com", "karen@yahoo.com"])
|
|
198
|
-
|
|
199
|
-
cc_to("karen@yahoo.com", "james@yahoo.com").should match(email)
|
|
200
|
-
cc_to("karen@yahoo.com").should_not match(email)
|
|
201
|
-
end
|
|
202
|
-
|
|
203
|
-
it "should match when an array of emails is exact same as all of the email's recipients" do
|
|
204
|
-
addresses = ["james@yahoo.com", "karen@yahoo.com"]
|
|
205
|
-
email = Mail::Message.new(:cc => addresses)
|
|
206
|
-
cc_to(addresses).should match(email)
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
it "should use the passed in objects :email method if not a string" do
|
|
210
|
-
email = Mail::Message.new(:cc => "jimmy_bean@yahoo.com")
|
|
211
|
-
user = mock("user", :email => "jimmy_bean@yahoo.com")
|
|
212
|
-
|
|
213
|
-
cc_to(user).should match(email)
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
describe "#have_subject" do
|
|
219
|
-
|
|
220
|
-
describe "when regexps are used" do
|
|
221
|
-
|
|
222
|
-
it "should match when the subject matches regexp" do
|
|
223
|
-
email = Mail::Message.new(:subject => ' -- The Subject --')
|
|
224
|
-
|
|
225
|
-
have_subject(/The Subject/).should match(email)
|
|
226
|
-
have_subject(/foo/).should_not match(email)
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
it "should have a helpful description" do
|
|
230
|
-
matcher = have_subject(/foo/)
|
|
231
|
-
matcher.matches?(Mail::Message.new(:subject => "bar"))
|
|
232
|
-
|
|
233
|
-
matcher.description.should == "have subject matching /foo/"
|
|
234
|
-
end
|
|
235
|
-
|
|
236
|
-
it "should offer helpful failing messages" do
|
|
237
|
-
matcher = have_subject(/foo/)
|
|
238
|
-
matcher.matches?(Mail::Message.new(:subject => "bar"))
|
|
239
|
-
|
|
240
|
-
matcher.failure_message.should == 'expected the subject to match /foo/, but did not. Actual subject was: "bar"'
|
|
241
|
-
end
|
|
242
|
-
|
|
243
|
-
it "should offer helpful negative failing messages" do
|
|
244
|
-
matcher = have_subject(/b/)
|
|
245
|
-
matcher.matches?(Mail::Message.new(:subject => "bar"))
|
|
246
|
-
|
|
247
|
-
matcher.negative_failure_message.should == 'expected the subject not to match /b/ but "bar" does match it.'
|
|
248
|
-
end
|
|
249
|
-
end
|
|
250
|
-
|
|
251
|
-
describe "when strings are used" do
|
|
252
|
-
it "should match when the subject equals the passed in string exactly" do
|
|
253
|
-
email = Mail::Message.new(:subject => 'foo')
|
|
254
|
-
|
|
255
|
-
have_subject("foo").should match(email)
|
|
256
|
-
have_subject(" - foo -").should_not match(email)
|
|
257
|
-
end
|
|
258
|
-
|
|
259
|
-
it "should have a helpful description" do
|
|
260
|
-
matcher = have_subject("foo")
|
|
261
|
-
matcher.matches?(Mail::Message.new(:subject => "bar"))
|
|
262
|
-
|
|
263
|
-
matcher.description.should == 'have subject of "foo"'
|
|
264
|
-
end
|
|
265
|
-
|
|
266
|
-
it "should offer helpful failing messages" do
|
|
267
|
-
matcher = have_subject("foo")
|
|
268
|
-
matcher.matches?(Mail::Message.new(:subject => "bar"))
|
|
269
|
-
|
|
270
|
-
matcher.failure_message.should == 'expected the subject to be "foo" but was "bar"'
|
|
271
|
-
end
|
|
272
|
-
|
|
273
|
-
it "should offer helpful negative failing messages" do
|
|
274
|
-
matcher = have_subject("bar")
|
|
275
|
-
matcher.matches?(Mail::Message.new(:subject => "bar"))
|
|
276
|
-
|
|
277
|
-
matcher.negative_failure_message.should == 'expected the subject not to be "bar" but was'
|
|
278
|
-
end
|
|
279
|
-
end
|
|
280
|
-
end
|
|
281
|
-
|
|
282
|
-
describe "#include_email_with_subject" do
|
|
283
|
-
|
|
284
|
-
describe "when regexps are used" do
|
|
285
|
-
|
|
286
|
-
it "should match when any email's subject matches passed in regexp" do
|
|
287
|
-
emails = [Mail::Message.new(:subject => "foobar"), Mail::Message.new(:subject => "bazqux")]
|
|
288
|
-
|
|
289
|
-
include_email_with_subject(/foo/).should match(emails)
|
|
290
|
-
include_email_with_subject(/quux/).should_not match(emails)
|
|
291
|
-
end
|
|
292
|
-
|
|
293
|
-
it "should have a helpful description" do
|
|
294
|
-
matcher = include_email_with_subject(/foo/)
|
|
295
|
-
matcher.matches?([])
|
|
296
|
-
|
|
297
|
-
matcher.description.should == 'include email with subject matching /foo/'
|
|
298
|
-
end
|
|
299
|
-
|
|
300
|
-
it "should offer helpful failing messages" do
|
|
301
|
-
matcher = include_email_with_subject(/foo/)
|
|
302
|
-
matcher.matches?([Mail::Message.new(:subject => "bar")])
|
|
303
|
-
|
|
304
|
-
matcher.failure_message.should == 'expected at least one email to have a subject matching /foo/, but none did. Subjects were ["bar"]'
|
|
305
|
-
end
|
|
306
|
-
|
|
307
|
-
it "should offer helpful negative failing messages" do
|
|
308
|
-
matcher = include_email_with_subject(/foo/)
|
|
309
|
-
matcher.matches?([Mail::Message.new(:subject => "foo")])
|
|
310
|
-
|
|
311
|
-
matcher.negative_failure_message.should == 'expected no email to have a subject matching /foo/ but found at least one. Subjects were ["foo"]'
|
|
312
|
-
end
|
|
313
|
-
end
|
|
314
|
-
|
|
315
|
-
describe "when strings are used" do
|
|
316
|
-
it "should match when any email's subject equals passed in subject exactly" do
|
|
317
|
-
emails = [Mail::Message.new(:subject => "foobar"), Mail::Message.new(:subject => "bazqux")]
|
|
318
|
-
|
|
319
|
-
include_email_with_subject("foobar").should match(emails)
|
|
320
|
-
include_email_with_subject("foo").should_not match(emails)
|
|
321
|
-
end
|
|
322
|
-
|
|
323
|
-
it "should have a helpful description" do
|
|
324
|
-
matcher = include_email_with_subject("foo")
|
|
325
|
-
matcher.matches?([])
|
|
326
|
-
|
|
327
|
-
matcher.description.should == 'include email with subject of "foo"'
|
|
328
|
-
end
|
|
329
|
-
|
|
330
|
-
it "should offer helpful failing messages" do
|
|
331
|
-
matcher = include_email_with_subject("foo")
|
|
332
|
-
matcher.matches?([Mail::Message.new(:subject => "bar")])
|
|
333
|
-
|
|
334
|
-
matcher.failure_message.should == 'expected at least one email to have the subject "foo" but none did. Subjects were ["bar"]'
|
|
335
|
-
end
|
|
336
|
-
|
|
337
|
-
it "should offer helpful negative failing messages" do
|
|
338
|
-
matcher = include_email_with_subject("foo")
|
|
339
|
-
matcher.matches?([Mail::Message.new(:subject => "foo")])
|
|
340
|
-
|
|
341
|
-
matcher.negative_failure_message.should == 'expected no email with the subject "foo" but found at least one. Subjects were ["foo"]'
|
|
342
|
-
end
|
|
343
|
-
end
|
|
344
|
-
end
|
|
345
|
-
|
|
346
|
-
describe "#have_body_text" do
|
|
347
|
-
describe "when regexps are used" do
|
|
348
|
-
it "should match when the body matches regexp" do
|
|
349
|
-
email = Mail::Message.new(:body => 'foo bar baz')
|
|
350
|
-
|
|
351
|
-
have_body_text(/bar/).should match(email)
|
|
352
|
-
have_body_text(/qux/).should_not match(email)
|
|
353
|
-
end
|
|
354
|
-
|
|
355
|
-
it "should have a helpful description" do
|
|
356
|
-
matcher = have_body_text(/qux/)
|
|
357
|
-
matcher.matches?(Mail::Message.new(:body => 'foo bar baz'))
|
|
358
|
-
|
|
359
|
-
matcher.description.should == 'have body matching /qux/'
|
|
360
|
-
end
|
|
361
|
-
|
|
362
|
-
it "should offer helpful failing messages" do
|
|
363
|
-
matcher = have_body_text(/qux/)
|
|
364
|
-
matcher.matches?(Mail::Message.new(:body => 'foo bar baz'))
|
|
365
|
-
|
|
366
|
-
matcher.failure_message.should == 'expected the body to match /qux/, but did not. Actual body was: "foo bar baz"'
|
|
367
|
-
end
|
|
368
|
-
|
|
369
|
-
it "should offer helpful negative failing messages" do
|
|
370
|
-
matcher = have_body_text(/bar/)
|
|
371
|
-
matcher.matches?(Mail::Message.new(:body => 'foo bar baz'))
|
|
372
|
-
|
|
373
|
-
matcher.negative_failure_message.should == 'expected the body not to match /bar/ but "foo bar baz" does match it.'
|
|
374
|
-
end
|
|
375
|
-
end
|
|
376
|
-
|
|
377
|
-
describe "when strings are used" do
|
|
378
|
-
it "should match when the body includes the text" do
|
|
379
|
-
email = Mail::Message.new(:body => 'foo bar baz')
|
|
380
|
-
|
|
381
|
-
have_body_text('bar').should match(email)
|
|
382
|
-
have_body_text('qux').should_not match(email)
|
|
383
|
-
end
|
|
384
|
-
|
|
385
|
-
it "should have a helpful description" do
|
|
386
|
-
matcher = have_body_text('qux')
|
|
387
|
-
matcher.matches?(Mail::Message.new(:body => 'foo bar baz'))
|
|
388
|
-
|
|
389
|
-
matcher.description.should == 'have body including "qux"'
|
|
390
|
-
end
|
|
391
|
-
|
|
392
|
-
it "should offer helpful failing messages" do
|
|
393
|
-
matcher = have_body_text('qux')
|
|
394
|
-
matcher.matches?(Mail::Message.new(:body => 'foo bar baz'))
|
|
395
|
-
|
|
396
|
-
matcher.failure_message.should == 'expected the body to contain "qux" but was "foo bar baz"'
|
|
397
|
-
end
|
|
398
|
-
|
|
399
|
-
it "should offer helpful negative failing messages" do
|
|
400
|
-
matcher = have_body_text('bar')
|
|
401
|
-
matcher.matches?(Mail::Message.new(:body => 'foo bar baz'))
|
|
402
|
-
|
|
403
|
-
matcher.negative_failure_message.should == 'expected the body not to contain "bar" but was "foo bar baz"'
|
|
404
|
-
end
|
|
405
|
-
end
|
|
406
|
-
|
|
407
|
-
describe "when dealing with multipart messages" do
|
|
408
|
-
it "should look at the html part" do
|
|
409
|
-
email = Mail.new do
|
|
410
|
-
text_part do
|
|
411
|
-
body "This is text"
|
|
412
|
-
end
|
|
413
|
-
html_part do
|
|
414
|
-
body "This is html"
|
|
415
|
-
end
|
|
416
|
-
end
|
|
417
|
-
have_body_text(/This is html/).should match(email)
|
|
418
|
-
have_body_text(/This is text/).should_not match(email)
|
|
419
|
-
end
|
|
420
|
-
end
|
|
421
|
-
end
|
|
422
|
-
|
|
423
|
-
describe "#have_header" do
|
|
424
|
-
describe "when regexps are used" do
|
|
425
|
-
it "should match when header matches passed in regexp" do
|
|
426
|
-
email = Mail::Message.new(:content_type => "text/html")
|
|
427
|
-
|
|
428
|
-
have_header(:content_type, /text/).should match(email)
|
|
429
|
-
have_header(:foo, /text/).should_not match(email)
|
|
430
|
-
have_header(:content_type, /bar/).should_not match(email)
|
|
431
|
-
end
|
|
432
|
-
|
|
433
|
-
it "should have a helpful description" do
|
|
434
|
-
matcher = have_header(:content_type, /bar/)
|
|
435
|
-
matcher.matches?(Mail::Message.new(:content_type => "text/html"))
|
|
436
|
-
|
|
437
|
-
matcher.description.should == 'have header content_type with value matching /bar/'
|
|
438
|
-
end
|
|
439
|
-
|
|
440
|
-
it "should offer helpful failing messages" do
|
|
441
|
-
matcher = have_header(:content_type, /bar/)
|
|
442
|
-
matcher.matches?(Mail::Message.new(:content_type => "text/html"))
|
|
443
|
-
|
|
444
|
-
matcher.failure_message.should == 'expected the headers to include \'content_type\' with a value matching /bar/ but they were {"content-type"=>"text/html"}'
|
|
445
|
-
end
|
|
446
|
-
|
|
447
|
-
it "should offer helpful negative failing messages" do
|
|
448
|
-
matcher = have_header(:content_type, /text/)
|
|
449
|
-
matcher.matches?(Mail::Message.new(:content_type => "text/html"))
|
|
450
|
-
|
|
451
|
-
matcher.negative_failure_message.should == 'expected the headers not to include \'content_type\' with a value matching /text/ but they were {"content-type"=>"text/html"}'
|
|
452
|
-
end
|
|
453
|
-
end
|
|
454
|
-
|
|
455
|
-
describe "when strings are used" do
|
|
456
|
-
it "should match when header equals passed in value exactly" do
|
|
457
|
-
email = Mail::Message.new(:content_type => "text/html")
|
|
458
|
-
|
|
459
|
-
have_header(:content_type, 'text/html').should match(email)
|
|
460
|
-
have_header(:foo, 'text/html').should_not match(email)
|
|
461
|
-
have_header(:content_type, 'text').should_not match(email)
|
|
462
|
-
end
|
|
463
|
-
|
|
464
|
-
it "should have a helpful description" do
|
|
465
|
-
matcher = have_header(:content_type, 'text')
|
|
466
|
-
matcher.matches?(Mail::Message.new(:content_type => "text/html"))
|
|
467
|
-
|
|
468
|
-
matcher.description.should == 'have header content_type: text'
|
|
469
|
-
end
|
|
470
|
-
|
|
471
|
-
it "should offer helpful failing messages" do
|
|
472
|
-
matcher = have_header(:content_type, 'text')
|
|
473
|
-
matcher.matches?(Mail::Message.new(:content_type => "text/html"))
|
|
474
|
-
|
|
475
|
-
matcher.failure_message.should == 'expected the headers to include \'content_type: text\' but they were {"content-type"=>"text/html"}'
|
|
476
|
-
end
|
|
477
|
-
|
|
478
|
-
it "should offer helpful negative failing messages" do
|
|
479
|
-
matcher = have_header(:content_type, 'text/html')
|
|
480
|
-
matcher.matches?(Mail::Message.new(:content_type => "text/html"))
|
|
481
|
-
|
|
482
|
-
matcher.negative_failure_message == 'expected the headers not to include \'content_type: text/html\' but they were {:content_type=>"text/html"}'
|
|
483
|
-
end
|
|
484
|
-
end
|
|
485
|
-
end
|
|
486
|
-
end
|