bmabey-email_spec 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/lib/email_spec/matchers.rb +31 -0
- data/spec/email_spec/matchers_spec.rb +13 -2
- metadata +2 -2
data/History.txt
CHANGED
data/lib/email_spec/matchers.rb
CHANGED
@@ -37,6 +37,37 @@ module EmailSpec
|
|
37
37
|
|
38
38
|
alias :be_delivered_to :deliver_to
|
39
39
|
|
40
|
+
class DeliverFrom
|
41
|
+
|
42
|
+
def initialize(email)
|
43
|
+
@expected_email_addresses = email
|
44
|
+
end
|
45
|
+
|
46
|
+
def description
|
47
|
+
"be delivered from #{@expected_email_addresses.inspect}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def matches?(email)
|
51
|
+
@email = email
|
52
|
+
@actual_sender = (email.from || []).first
|
53
|
+
@actual_sender.eql? @expected_email_addresses
|
54
|
+
end
|
55
|
+
|
56
|
+
def failure_message
|
57
|
+
"expected #{@email.inspect} to deliver from #{@expected_email_addresses.inspect}, but it delievered from #{@actual_recipients.inspect}"
|
58
|
+
end
|
59
|
+
|
60
|
+
def negative_failure_message
|
61
|
+
"expected #{@email.inspect} not to deliver from #{@expected_email_addresses.inspect}, but it did"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def deliver_from(email)
|
66
|
+
DeliverFrom.new(email)
|
67
|
+
end
|
68
|
+
|
69
|
+
alias :be_delivered_from :deliver_from
|
70
|
+
|
40
71
|
class BccTo
|
41
72
|
|
42
73
|
def initialize(expected_email_addresses_or_objects_that_respond_to_email)
|
@@ -45,7 +45,6 @@ describe EmailSpec::Matchers do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
describe "#deliver_to" do
|
48
|
-
|
49
48
|
it "should match when the email is set to deliver to the specidied address" do
|
50
49
|
email = mock_email(:to => "jimmy_bean@yahoo.com")
|
51
50
|
|
@@ -74,6 +73,18 @@ describe EmailSpec::Matchers do
|
|
74
73
|
|
75
74
|
end
|
76
75
|
|
76
|
+
describe "#deliver_from" do
|
77
|
+
it "should match when the email is set to deliver from the specidied address" do
|
78
|
+
email = mock_email(:from => ["jimmy_bean@yahoo.com"])
|
79
|
+
deliver_from("jimmy_bean@yahoo.com").should match(email)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should not match when the email is not set to deliver from the specified address" do
|
83
|
+
email = mock_email(:from => nil)
|
84
|
+
deliver_from("jimmy_bean@yahoo.com").should_not match(email)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
77
88
|
describe "#bcc_to" do
|
78
89
|
|
79
90
|
it "should match when the email is set to deliver to the specidied address" do
|
@@ -182,7 +193,7 @@ describe EmailSpec::Matchers do
|
|
182
193
|
describe "#have_body_text" do
|
183
194
|
it "should have specs!"
|
184
195
|
end
|
185
|
-
|
196
|
+
|
186
197
|
describe "#have_header" do
|
187
198
|
it "should have specs!"
|
188
199
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bmabey-email_spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Mabey
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2009-09-
|
14
|
+
date: 2009-09-18 00:00:00 -07:00
|
15
15
|
default_executable:
|
16
16
|
dependencies: []
|
17
17
|
|