email_spec 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,15 @@
1
1
  (In Git)
2
2
 
3
3
  === New features
4
+
4
5
  === Bufixes
5
6
 
7
+ == 0.3.6 2009-12-16
8
+
9
+ === New features
10
+ * Cucumber steps for be_delivered_from, have_header matchers. (Joseph Holsten)
11
+ * Explicit regular expression steps. i.e. "I should see /foo/ in the email body" (Joseph Holsten)
12
+
6
13
  == 0.3.5 2009-09-30 The Pony Release!
7
14
 
8
15
  === New features
@@ -8,11 +8,11 @@ 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
-
12
- gem install bmabey-email_spec
11
+
12
+ gem install email_spec
13
13
 
14
14
  # config/environments/test.rb
15
- config.gem 'bmabey-email_spec', :lib => 'email_spec'
15
+ config.gem 'email_spec', :lib => 'email_spec'
16
16
 
17
17
  === Cucumber
18
18
 
@@ -32,20 +32,20 @@ This will give you a bunch of steps to get started with in step_definitions/emai
32
32
 
33
33
  === RSpec
34
34
 
35
- First you need to require the helpers and matchers in your spec_helper.rb like so:
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"
39
39
 
40
- You will then need to include EmailSpec::Helpers and EmailSpec::Matchers in your example groups.
41
- If you want to have access to the helpers and matchers in all of your examples you can do the following in your spec_helper.rb:
40
+ You will then need to include EmailSpec::Helpers and EmailSpec::Matchers in your example groups.
41
+ If you want to have access to the helpers and matchers in all of your examples you can do the following in your spec_helper.rb:
42
42
 
43
43
  Spec::Runner.configure do |config|
44
44
  config.include(EmailSpec::Helpers)
45
45
  config.include(EmailSpec::Matchers)
46
46
  end
47
47
 
48
- Otherwise, you will need to include them in the example groups you wish to use them:
48
+ Otherwise, you will need to include them in the example groups you wish to use them:
49
49
 
50
50
  describe "Signup Email" do
51
51
  include EmailSpec::Helpers
@@ -71,52 +71,52 @@ For more examples, check out examples/rails_root in the source for a small examp
71
71
 
72
72
  === RSpec
73
73
 
74
- ==== Testing In Isolation ====
75
- It is often useful to test your mailers in isolation. You can accomplish this by using mocks to verify that the mailer is being called in the correct place and then write focued examples for the actual mailer. This is a simple example from the sample app found in the gem:
76
-
77
- Verify that the mailer is used correctly in the controller (this would apply to a model as well):
74
+ ==== Testing In Isolation
75
+ It is often useful to test your mailers in isolation. You can accomplish this by using mocks to verify that the mailer is being called in the correct place and then write focued examples for the actual mailer. This is a simple example from the sample app found in the gem:
78
76
 
79
- describe "POST /signup (#signup)" do
80
- it "should deliver the signup email" do
81
- # expect
82
- UserMailer.should_receive(:deliver_signup).with("email@example.com", "Jimmy Bean")
83
- # when
84
- post :signup, "Email" => "email@example.com", "Name" => "Jimmy Bean"
85
- end
86
- end
77
+ Verify that the mailer is used correctly in the controller (this would apply to a model as well):
87
78
 
88
- Examples for the #signup method in UserMailer:
79
+ describe "POST /signup (#signup)" do
80
+ it "should deliver the signup email" do
81
+ # expect
82
+ UserMailer.should_receive(:deliver_signup).with("email@example.com", "Jimmy Bean")
83
+ # when
84
+ post :signup, "Email" => "email@example.com", "Name" => "Jimmy Bean"
85
+ end
86
+ end
89
87
 
90
- describe "Signup Email" do
91
- include EmailSpec::Helpers
92
- include EmailSpec::Matchers
93
- include ActionController::UrlWriter
88
+ Examples for the #signup method in UserMailer:
94
89
 
95
- before(:all) do
96
- @email = UserMailer.create_signup("jojo@yahoo.com", "Jojo Binks")
97
- end
90
+ describe "Signup Email" do
91
+ include EmailSpec::Helpers
92
+ include EmailSpec::Matchers
93
+ include ActionController::UrlWriter
98
94
 
99
- it "should be set to be delivered to the email passed in" do
100
- @email.should deliver_to("jojo@yahoo.com")
101
- end
95
+ before(:all) do
96
+ @email = UserMailer.create_signup("jojo@yahoo.com", "Jojo Binks")
97
+ end
102
98
 
103
- it "should contain the user's message in the mail body" do
104
- @email.should have_text(/Jojo Binks/)
105
- end
99
+ it "should be set to be delivered to the email passed in" do
100
+ @email.should deliver_to("jojo@yahoo.com")
101
+ end
106
102
 
107
- it "should contain a link to the confirmation link" do
108
- @email.should have_text(/#{confirm_account_url}/)
109
- end
103
+ it "should contain the user's message in the mail body" do
104
+ @email.should have_text(/Jojo Binks/)
105
+ end
110
106
 
111
- it "should have the correct subject" do
112
- @email.should have_subject(/Account confirmation/)
113
- end
107
+ it "should contain a link to the confirmation link" do
108
+ @email.should have_text(/#{confirm_account_url}/)
109
+ end
114
110
 
111
+ it "should have the correct subject" do
112
+ @email.should have_subject(/Account confirmation/)
115
113
  end
116
114
 
117
- ==== Using the helpers when not testing in isolation ====
115
+ end
116
+
117
+ ==== Using the helpers when not testing in isolation
118
118
 
119
- Don't. :) Seriously, if you do just take a look at the helpers and use them as you wish.
119
+ Don't. :) Seriously, if you do just take a look at the helpers and use them as you wish.
120
120
 
121
121
  == Original Authors
122
122
 
@@ -87,13 +87,34 @@ end
87
87
  #
88
88
 
89
89
  Then /^(?:I|they) should see "([^"]*?)" in the email subject$/ do |text|
90
+ current_email.should have_subject(text)
91
+ end
92
+
93
+ Then /^(?:I|they) should see \/([^"]*?)\/ in the email subject$/ do |text|
90
94
  current_email.should have_subject(Regexp.new(text))
91
95
  end
92
96
 
93
97
  Then /^(?:I|they) should see "([^"]*?)" in the email body$/ do |text|
98
+ current_email.body.should include(text)
99
+ end
100
+
101
+ Then /^(?:I|they) should see \/([^"]*?)\/ in the email body$/ do |text|
94
102
  current_email.body.should =~ Regexp.new(text)
95
103
  end
96
104
 
105
+ Then /^(?:I|they) should see the email delivered from "([^"]*?)"$/ do |text|
106
+ current_email.should be_delivered_from(text)
107
+ end
108
+
109
+ Then /^(?:I|they) should see "([^\"]*)" in the email "([^"]*?)" header$/ do |text, name|
110
+ current_email.should have_header(name, text)
111
+ end
112
+
113
+ Then /^(?:I|they) should see \/([^\"]*)\/ in the email "([^"]*?)" header$/ do |text, name|
114
+ current_email.should have_header(name, Regexp.new(text))
115
+ end
116
+
117
+
97
118
  # DEPRECATED
98
119
  # The following methods are left in for backwards compatibility and
99
120
  # should be removed by version 0.4.0.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: email_spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
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-10-08 00:00:00 -06:00
14
+ date: 2009-12-16 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies: []
17
17
 
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
65
  requirements: []
66
66
 
67
67
  rubyforge_project: email-spec
68
- rubygems_version: 1.3.3
68
+ rubygems_version: 1.3.5
69
69
  signing_key:
70
70
  specification_version: 3
71
71
  summary: Easily test email in rspec and cucumber
@@ -148,7 +148,6 @@ test_files:
148
148
  - examples/sinatra/app.rb
149
149
  - examples/sinatra/features/errors.feature
150
150
  - examples/sinatra/features/example.feature
151
- - examples/sinatra/features/step_definitions/email_steps.rb
152
151
  - examples/sinatra/features/step_definitions/user_steps.rb
153
152
  - examples/sinatra/features/step_definitions/webrat_steps.rb
154
153
  - examples/sinatra/features/support/env.rb
@@ -1,122 +0,0 @@
1
- # Commonly used email steps
2
- #
3
- # To add your own steps make a custom_email_steps.rb
4
- # The provided methods are:
5
- #
6
- # last_email_address
7
- # reset_mailer
8
- # open_last_email
9
- # visit_in_email
10
- # unread_emails_for
11
- # mailbox_for
12
- # current_email
13
- # open_email
14
- # read_emails_for
15
- # find_email
16
- #
17
- # General form for email scenarios are:
18
- # - clear the email queue (done automatically by email_spec)
19
- # - execute steps that sends an email
20
- # - check the user received an/no/[0-9] emails
21
- # - open the email
22
- # - inspect the email contents
23
- # - interact with the email (e.g. click links)
24
- #
25
- # The Cucumber steps below are setup in this order.
26
-
27
- module EmailHelpers
28
- def current_email_address
29
- # Replace with your a way to find your current email. e.g @current_user.email
30
- # last_email_address will return the last email address used by email spec to find an email.
31
- # Note that last_email_address will be reset after each Scenario.
32
- last_email_address || "example@example.com"
33
- end
34
- end
35
-
36
- World(EmailHelpers)
37
-
38
- #
39
- # Reset the e-mail queue within a scenario.
40
- # This is done automatically before each scenario.
41
- #
42
-
43
- Given /^(?:a clear email queue|no emails have been sent)$/ do
44
- reset_mailer
45
- end
46
-
47
- #
48
- # Check how many emails have been sent/received
49
- #
50
-
51
- Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails?$/ do |address, amount|
52
- unread_emails_for(address).size.should == parse_email_count(amount)
53
- end
54
-
55
- Then /^(?:I|they|"([^"]*?)") should have (an|no|\d+) emails?$/ do |address, amount|
56
- mailbox_for(address).size.should == parse_email_count(amount)
57
- end
58
-
59
- # DEPRECATED
60
- # The following methods are left in for backwards compatibility and
61
- # should be removed by version 0.4.0
62
- Then /^(?:I|they|"([^"]*?)") should not receive an email$/ do |address|
63
- email_spec_deprecate "The step 'I/they/[email] should not receive an email' is no longer supported.
64
- Please use 'I/they/[email] should receive no emails' instead."
65
- unread_emails_for(address).size.should == 0
66
- end
67
-
68
- #
69
- # Accessing emails
70
- #
71
-
72
- # Opens the most recently received email
73
- When /^(?:I|they|"([^"]*?)") opens? the email$/ do |address|
74
- open_email(address)
75
- end
76
-
77
- When /^(?:I|they|"([^"]*?)") opens? the email with subject "([^"]*?)"$/ do |address, subject|
78
- open_email(address, :with_subject => subject)
79
- end
80
-
81
- When /^(?:I|they|"([^"]*?)") opens? the email with text "([^"]*?)"$/ do |address, text|
82
- open_email(address, :with_text => text)
83
- end
84
-
85
- #
86
- # Inspect the Email Contents
87
- #
88
-
89
- Then /^(?:I|they) should see "([^"]*?)" in the email subject$/ do |text|
90
- current_email.should have_subject(Regexp.new(text))
91
- end
92
-
93
- Then /^(?:I|they) should see "([^"]*?)" in the email body$/ do |text|
94
- current_email.body.should =~ Regexp.new(text)
95
- end
96
-
97
- # DEPRECATED
98
- # The following methods are left in for backwards compatibility and
99
- # should be removed by version 0.4.0.
100
- Then /^(?:I|they) should see "([^"]*?)" in the subject$/ do |text|
101
- email_spec_deprecate "The step 'I/they should see [text] in the subject' is no longer supported.
102
- Please use 'I/they should see [text] in the email subject' instead."
103
- current_email.should have_subject(Regexp.new(text))
104
- end
105
- Then /^(?:I|they) should see "([^"]*?)" in the email$/ do |text|
106
- email_spec_deprecate "The step 'I/they should see [text] in the email' is no longer supported.
107
- Please use 'I/they should see [text] in the email body' instead."
108
- current_email.body.should =~ Regexp.new(text)
109
- end
110
-
111
- #
112
- # Interact with Email Contents
113
- #
114
-
115
- When /^(?:I|they) follow "([^"]*?)" in the email$/ do |link|
116
- visit_in_email(link)
117
- end
118
-
119
- When /^(?:I|they) click the first link in the email$/ do
120
- click_first_link_in_email
121
- end
122
-