bmabey-email_spec 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/README.rdoc +10 -10
- data/lib/email_spec/matchers.rb +2 -2
- data/spec/email_spec/matchers_spec.rb +13 -0
- metadata +2 -2
data/History.txt
CHANGED
data/README.rdoc
CHANGED
@@ -8,12 +8,12 @@ A collection of RSpec matchers and Cucumber steps to make testing emails go smoo
|
|
8
8
|
script/plugin install git://github.com/bmabey/email-spec.git
|
9
9
|
|
10
10
|
=== Gem Setup
|
11
|
-
|
11
|
+
|
12
12
|
gem install bmabey-email_spec
|
13
13
|
|
14
14
|
# config/environments/test.rb
|
15
15
|
config.gem 'bmabey-email_spec', :lib => 'email_spec'
|
16
|
-
|
16
|
+
|
17
17
|
=== Cucumber
|
18
18
|
|
19
19
|
To use the steps in features put the following in your env.rb:
|
@@ -21,7 +21,7 @@ To use the steps in features put the following in your env.rb:
|
|
21
21
|
# Make sure this require is after you require cucumber/rails/world.
|
22
22
|
require 'email_spec/cucumber'
|
23
23
|
|
24
|
-
This will load all the helpers that the steps rely on.
|
24
|
+
This will load all the helpers that the steps rely on.
|
25
25
|
It will also add a Before hook for Cucumber so that emails are cleared at the start of each scenario.
|
26
26
|
|
27
27
|
Then:
|
@@ -32,7 +32,7 @@ This will give you a bunch of steps to get started with in step_definitions/emai
|
|
32
32
|
|
33
33
|
=== RSpec
|
34
34
|
|
35
|
-
|
35
|
+
First you need to require the helpers and matchers in your spec_helper.rb like so:
|
36
36
|
|
37
37
|
require "email_spec/helpers"
|
38
38
|
require "email_spec/matchers"
|
@@ -95,11 +95,11 @@ For more examples, check out examples/rails_root in the source for a small examp
|
|
95
95
|
before(:all) do
|
96
96
|
@email = UserMailer.create_signup("jojo@yahoo.com", "Jojo Binks")
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
99
|
it "should be set to be delivered to the email passed in" do
|
100
100
|
@email.should deliver_to("jojo@yahoo.com")
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
103
|
it "should contain the user's message in the mail body" do
|
104
104
|
@email.should have_text(/Jojo Binks/)
|
105
105
|
end
|
@@ -107,14 +107,14 @@ For more examples, check out examples/rails_root in the source for a small examp
|
|
107
107
|
it "should contain a link to the confirmation link" do
|
108
108
|
@email.should have_text(/#{confirm_account_url}/)
|
109
109
|
end
|
110
|
-
|
110
|
+
|
111
111
|
it "should have the correct subject" do
|
112
112
|
@email.should have_subject(/Account confirmation/)
|
113
113
|
end
|
114
|
-
|
114
|
+
|
115
115
|
end
|
116
|
-
|
117
|
-
==== Using the helpers when not testing in isolation ====
|
116
|
+
|
117
|
+
==== Using the helpers when not testing in isolation ====
|
118
118
|
|
119
119
|
Don't. :) Seriously, if you do just take a look at the helpers and use them as you wish.
|
120
120
|
|
data/lib/email_spec/matchers.rb
CHANGED
@@ -23,7 +23,7 @@ module EmailSpec
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def failure_message
|
26
|
-
"expected #{@email.inspect} to deliver to #{@expected_email_addresses.inspect}, but it
|
26
|
+
"expected #{@email.inspect} to deliver to #{@expected_email_addresses.inspect}, but it delivered to #{@actual_recipients.inspect}"
|
27
27
|
end
|
28
28
|
|
29
29
|
def negative_failure_message
|
@@ -54,7 +54,7 @@ module EmailSpec
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def failure_message
|
57
|
-
"expected #{@email.inspect} to deliver from #{@expected_email_addresses.inspect}, but it
|
57
|
+
"expected #{@email.inspect} to deliver from #{@expected_email_addresses.inspect}, but it delivered from #{@actual_sender.inspect}"
|
58
58
|
end
|
59
59
|
|
60
60
|
def negative_failure_message
|
@@ -71,6 +71,12 @@ describe EmailSpec::Matchers do
|
|
71
71
|
deliver_to(user).should match(email)
|
72
72
|
end
|
73
73
|
|
74
|
+
it "should give correct failure message when the email is not set to deliver to the specified address" do
|
75
|
+
matcher = deliver_to("jimmy_bean@yahoo.com")
|
76
|
+
matcher.matches?(mock_email(:inspect => 'email', :to => 'freddy_noe@yahoo.com'))
|
77
|
+
matcher.failure_message.should == %{expected email to deliver to ["jimmy_bean@yahoo.com"], but it delivered to ["freddy_noe@yahoo.com"]}
|
78
|
+
end
|
79
|
+
|
74
80
|
end
|
75
81
|
|
76
82
|
describe "#deliver_from" do
|
@@ -83,6 +89,13 @@ describe EmailSpec::Matchers do
|
|
83
89
|
email = mock_email(:from => nil)
|
84
90
|
deliver_from("jimmy_bean@yahoo.com").should_not match(email)
|
85
91
|
end
|
92
|
+
|
93
|
+
it "should give correct failure message when the email is not set to deliver from the specified address" do
|
94
|
+
matcher = deliver_from("jimmy_bean@yahoo.com")
|
95
|
+
matcher.matches?(mock_email(:inspect => 'email', :from => ['freddy_noe@yahoo.com']))
|
96
|
+
matcher.failure_message.should == %{expected email to deliver from "jimmy_bean@yahoo.com", but it delivered from "freddy_noe@yahoo.com"}
|
97
|
+
end
|
98
|
+
|
86
99
|
end
|
87
100
|
|
88
101
|
describe "#bcc_to" do
|
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.4
|
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-26 00:00:00 -07:00
|
15
15
|
default_executable:
|
16
16
|
dependencies: []
|
17
17
|
|