email_spec 1.6.0 → 2.0.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.
- checksums.yaml +7 -0
- data/History.txt +18 -0
- data/README.md +30 -28
- data/examples/rails4_root/Gemfile +19 -0
- data/examples/rails4_root/Gemfile.lock +180 -0
- data/examples/rails4_root/README +5 -0
- data/examples/rails4_root/Rakefile +11 -0
- data/examples/rails4_root/app/controllers/application_controller.rb +3 -0
- data/examples/rails4_root/app/controllers/welcome_controller.rb +18 -0
- data/examples/rails4_root/app/helpers/application_helper.rb +2 -0
- data/examples/rails4_root/app/mailers/user_mailer.rb +39 -0
- data/examples/rails4_root/app/models/user.rb +2 -0
- data/examples/rails4_root/app/views/user_mailer/email_with_attachment.html.erb +6 -0
- data/examples/rails4_root/app/views/user_mailer/newsletter.html.erb +8 -0
- data/examples/rails4_root/app/views/user_mailer/signup.html.erb +4 -0
- data/examples/rails4_root/app/views/user_mailer/signup.text.erb +4 -0
- data/examples/rails4_root/app/views/welcome/attachments.html.erb +0 -0
- data/examples/rails4_root/app/views/welcome/confirm.html.erb +1 -0
- data/examples/rails4_root/app/views/welcome/index.html.erb +8 -0
- data/examples/rails4_root/app/views/welcome/newsletter.html.erb +0 -0
- data/examples/rails4_root/app/views/welcome/signup.html.erb +1 -0
- data/examples/rails4_root/attachments/document.pdf +0 -0
- data/examples/rails4_root/attachments/image.png +0 -0
- data/examples/rails4_root/config.ru +4 -0
- data/examples/rails4_root/config/application.rb +45 -0
- data/examples/rails4_root/config/boot.rb +14 -0
- data/examples/rails4_root/config/cucumber.yml +8 -0
- data/examples/rails4_root/config/database.yml +25 -0
- data/examples/rails4_root/config/environment.rb +6 -0
- data/examples/rails4_root/config/environments/development.rb +19 -0
- data/examples/rails4_root/config/environments/production.rb +42 -0
- data/examples/rails4_root/config/environments/test.rb +32 -0
- data/examples/rails4_root/config/initializers/backtrace_silencers.rb +7 -0
- data/examples/rails4_root/config/initializers/cookie_verification_secret.rb +7 -0
- data/examples/rails4_root/config/initializers/delayed_job.rb +1 -0
- data/examples/rails4_root/config/initializers/inflections.rb +10 -0
- data/examples/rails4_root/config/initializers/mime_types.rb +5 -0
- data/examples/rails4_root/config/initializers/notifier_job.rb +1 -0
- data/examples/rails4_root/config/initializers/rspec_generator.rb +6 -0
- data/examples/rails4_root/config/initializers/session_store.rb +10 -0
- data/examples/rails4_root/config/locales/en.yml +5 -0
- data/examples/rails4_root/config/routes.rb +7 -0
- data/examples/rails4_root/config/secrets.yml +22 -0
- data/examples/rails4_root/db/migrate/20090125013728_create_users.rb +11 -0
- data/examples/rails4_root/db/migrate/20090908054656_create_delayed_jobs.rb +20 -0
- data/examples/rails4_root/db/migrate/20141119224309_add_queue_to_delayed_jobs.rb +9 -0
- data/examples/rails4_root/db/schema.rb +35 -0
- data/examples/rails4_root/db/seeds.rb +7 -0
- data/examples/rails4_root/db/test.sqlite3 +0 -0
- data/examples/rails4_root/doc/README_FOR_APP +2 -0
- data/examples/rails4_root/features/attachments.feature +27 -0
- data/examples/rails4_root/features/delayed_job.feature +13 -0
- data/examples/rails4_root/features/errors.feature +40 -0
- data/examples/rails4_root/features/example.feature +93 -0
- data/examples/rails4_root/features/step_definitions/email_steps.rb +210 -0
- data/examples/rails4_root/features/step_definitions/user_steps.rb +26 -0
- data/examples/rails4_root/features/step_definitions/web_steps.rb +219 -0
- data/examples/rails4_root/features/support/env.rb +59 -0
- data/examples/rails4_root/features/support/env_ext.rb +4 -0
- data/examples/rails4_root/features/support/paths.rb +33 -0
- data/examples/rails4_root/lib/notifier_job.rb +5 -0
- data/examples/rails4_root/lib/tasks/cucumber.rake +65 -0
- data/examples/rails4_root/lib/tasks/rspec.rake +69 -0
- data/examples/rails4_root/log/development.log +0 -0
- data/examples/rails4_root/log/test.log +43813 -0
- data/examples/rails4_root/public/404.html +26 -0
- data/examples/rails4_root/public/422.html +26 -0
- data/examples/rails4_root/public/500.html +26 -0
- data/examples/rails4_root/public/favicon.ico +0 -0
- data/examples/rails4_root/public/images/rails.png +0 -0
- data/examples/rails4_root/public/javascripts/application.js +2 -0
- data/examples/rails4_root/public/javascripts/controls.js +965 -0
- data/examples/rails4_root/public/javascripts/dragdrop.js +974 -0
- data/examples/rails4_root/public/javascripts/effects.js +1123 -0
- data/examples/rails4_root/public/javascripts/prototype.js +4874 -0
- data/examples/rails4_root/public/javascripts/rails.js +109 -0
- data/examples/rails4_root/public/robots.txt +5 -0
- data/examples/rails4_root/script/cucumber +10 -0
- data/examples/rails4_root/script/delayed_job +5 -0
- data/examples/rails4_root/script/rails +9 -0
- data/examples/rails4_root/spec/controllers/welcome_controller_spec.rb +20 -0
- data/examples/rails4_root/spec/models/user_mailer_spec.rb +47 -0
- data/examples/rails4_root/spec/spec_helper.rb +20 -0
- data/examples/rails4_root/test/mailers/user_mailer_classic_test.rb +27 -0
- data/examples/rails4_root/test/mailers/user_mailer_spec_test.rb +29 -0
- data/examples/rails4_root/test/test_helper.rb +10 -0
- data/{rails_generators → examples/rails4_root/vendor/plugins/email_spec/rails_generators}/email_spec/email_spec_generator.rb +0 -0
- data/{rails_generators → examples/rails4_root/vendor/plugins/email_spec/rails_generators}/email_spec/templates/email_steps.rb +22 -18
- data/examples/sinatra_root/Gemfile +15 -0
- data/examples/sinatra_root/Gemfile.lock +95 -0
- data/examples/sinatra_root/config.ru +4 -0
- data/examples/sinatra_root/features/errors.feature +40 -0
- data/examples/sinatra_root/features/example.feature +93 -0
- data/examples/sinatra_root/features/step_definitions/email_steps.rb +210 -0
- data/examples/sinatra_root/features/step_definitions/user_steps.rb +26 -0
- data/examples/sinatra_root/features/step_definitions/web_steps.rb +219 -0
- data/examples/sinatra_root/features/support/env.rb +21 -0
- data/examples/sinatra_root/features/support/paths.rb +29 -0
- data/examples/sinatra_root/lib/example_sinatra_app.rb +45 -0
- data/features/rails4_app.feature +32 -0
- data/features/sinatra_app.feature +14 -0
- data/features/step_definitions/app_steps.rb +58 -0
- data/features/support/env.rb +16 -0
- data/lib/email_spec.rb +1 -1
- data/lib/email_spec/deliveries.rb +0 -1
- data/lib/email_spec/email_viewer.rb +1 -1
- data/lib/email_spec/helpers.rb +16 -5
- data/lib/email_spec/matchers.rb +2 -1
- data/lib/email_spec/version.rb +3 -0
- data/lib/generators/email_spec/steps/templates/email_steps.rb +24 -20
- data/spec/email_spec/email_viewer_spec.rb +20 -0
- data/spec/email_spec/helpers_spec.rb +316 -0
- data/spec/email_spec/mail_ext_spec.rb +34 -0
- data/spec/email_spec/matchers_spec.rb +513 -0
- data/spec/spec_helper.rb +24 -0
- metadata +161 -150
- data/lib/email_spec/background_processes.rb +0 -45
- data/lib/generators/email_spec/steps/USAGE +0 -5
@@ -0,0 +1,109 @@
|
|
1
|
+
document.observe("dom:loaded", function() {
|
2
|
+
var authToken = $$('meta[name=csrf-token]').first().readAttribute('content'),
|
3
|
+
authParam = $$('meta[name=csrf-param]').first().readAttribute('content'),
|
4
|
+
formTemplate = '<form method="#{method}" action="#{action}">\
|
5
|
+
#{realmethod}<input name="#{param}" value="#{token}" type="hidden">\
|
6
|
+
</form>',
|
7
|
+
realmethodTemplate = '<input name="_method" value="#{method}" type="hidden">';
|
8
|
+
|
9
|
+
function handleRemote(element) {
|
10
|
+
var method, url, params;
|
11
|
+
|
12
|
+
if (element.tagName.toLowerCase() == 'form') {
|
13
|
+
method = element.readAttribute('method') || 'post';
|
14
|
+
url = element.readAttribute('action');
|
15
|
+
params = element.serialize(true);
|
16
|
+
} else {
|
17
|
+
method = element.readAttribute('data-method') || 'get';
|
18
|
+
url = element.readAttribute('href');
|
19
|
+
params = {};
|
20
|
+
}
|
21
|
+
|
22
|
+
var event = element.fire("ajax:before");
|
23
|
+
if (event.stopped) return false;
|
24
|
+
|
25
|
+
new Ajax.Request(url, {
|
26
|
+
method: method,
|
27
|
+
parameters: params,
|
28
|
+
asynchronous: true,
|
29
|
+
evalScripts: true,
|
30
|
+
|
31
|
+
onLoading: function(request) { element.fire("ajax:loading", {request: request}); },
|
32
|
+
onLoaded: function(request) { element.fire("ajax:loaded", {request: request}); },
|
33
|
+
onInteractive: function(request) { element.fire("ajax:interactive", {request: request}); },
|
34
|
+
onComplete: function(request) { element.fire("ajax:complete", {request: request}); },
|
35
|
+
onSuccess: function(request) { element.fire("ajax:success", {request: request}); },
|
36
|
+
onFailure: function(request) { element.fire("ajax:failure", {request: request}); }
|
37
|
+
});
|
38
|
+
|
39
|
+
element.fire("ajax:after");
|
40
|
+
}
|
41
|
+
|
42
|
+
$(document.body).observe("click", function(event) {
|
43
|
+
var message = event.element().readAttribute('data-confirm');
|
44
|
+
if (message && !confirm(message)) {
|
45
|
+
event.stop();
|
46
|
+
return false;
|
47
|
+
}
|
48
|
+
|
49
|
+
var element = event.findElement("a[data-remote=true]");
|
50
|
+
if (element) {
|
51
|
+
handleRemote(element);
|
52
|
+
event.stop();
|
53
|
+
}
|
54
|
+
|
55
|
+
var element = event.findElement("a[data-method]");
|
56
|
+
if (element && element.readAttribute('data-remote') != 'true') {
|
57
|
+
var method = element.readAttribute('data-method'),
|
58
|
+
piggyback = method.toLowerCase() != 'post',
|
59
|
+
formHTML = formTemplate.interpolate({
|
60
|
+
method: 'POST',
|
61
|
+
realmethod: piggyback ? realmethodTemplate.interpolate({ method: method }) : '',
|
62
|
+
action: element.readAttribute('href'),
|
63
|
+
token: authToken,
|
64
|
+
param: authParam
|
65
|
+
});
|
66
|
+
|
67
|
+
var form = new Element('div').update(formHTML).down().hide();
|
68
|
+
this.insert({ bottom: form });
|
69
|
+
|
70
|
+
form.submit();
|
71
|
+
event.stop();
|
72
|
+
}
|
73
|
+
});
|
74
|
+
|
75
|
+
// TODO: I don't think submit bubbles in IE
|
76
|
+
$(document.body).observe("submit", function(event) {
|
77
|
+
var message = event.element().readAttribute('data-confirm');
|
78
|
+
if (message && !confirm(message)) {
|
79
|
+
event.stop();
|
80
|
+
return false;
|
81
|
+
}
|
82
|
+
|
83
|
+
var inputs = event.element().select("input[type=submit][data-disable-with]");
|
84
|
+
inputs.each(function(input) {
|
85
|
+
input.disabled = true;
|
86
|
+
input.writeAttribute('data-original-value', input.value);
|
87
|
+
input.value = input.readAttribute('data-disable-with');
|
88
|
+
});
|
89
|
+
|
90
|
+
var element = event.findElement("form[data-remote=true]");
|
91
|
+
if (element) {
|
92
|
+
handleRemote(element);
|
93
|
+
event.stop();
|
94
|
+
}
|
95
|
+
});
|
96
|
+
|
97
|
+
$(document.body).observe("ajax:complete", function(event) {
|
98
|
+
var element = event.element();
|
99
|
+
|
100
|
+
if (element.tagName.toLowerCase() == 'form') {
|
101
|
+
var inputs = element.select("input[type=submit][disabled=true][data-disable-with]");
|
102
|
+
inputs.each(function(input) {
|
103
|
+
input.value = input.readAttribute('data-original-value');
|
104
|
+
input.writeAttribute('data-original-value', null);
|
105
|
+
input.disabled = false;
|
106
|
+
});
|
107
|
+
}
|
108
|
+
});
|
109
|
+
});
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
4
|
+
if vendored_cucumber_bin
|
5
|
+
load File.expand_path(vendored_cucumber_bin)
|
6
|
+
else
|
7
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
8
|
+
require 'cucumber'
|
9
|
+
load Cucumber::BINARY
|
10
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
|
3
|
+
|
4
|
+
ENV_PATH = File.expand_path('../../config/environment', __FILE__)
|
5
|
+
BOOT_PATH = File.expand_path('../../config/boot', __FILE__)
|
6
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
7
|
+
|
8
|
+
require BOOT_PATH
|
9
|
+
require 'rails/commands'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe WelcomeController, :type => :controller do
|
4
|
+
|
5
|
+
describe "POST /signup (#signup)" do
|
6
|
+
it "should deliver the signup email" do
|
7
|
+
expect {
|
8
|
+
post :signup, "Email" => "email@example.com", "Name" => "Jimmy Bean"
|
9
|
+
}.to change(ActionMailer::Base.deliveries, :size).by(1)
|
10
|
+
|
11
|
+
last_delivery = ActionMailer::Base.deliveries.last
|
12
|
+
expect(last_delivery.to).to include "email@example.com"
|
13
|
+
#message is now multipart, make sure both parts include Jimmy Bean
|
14
|
+
expect(last_delivery.parts[0].body.to_s).to include "Jimmy Bean"
|
15
|
+
expect(last_delivery.parts[1].body.to_s).to include "Jimmy Bean"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
# These two example groups are specifying the exact same behavior. However, the documentation style is different
|
4
|
+
# and the value that each one provides is different with various trade-offs. Run these examples with the specdoc
|
5
|
+
# formatter to get an idea of how they differ.
|
6
|
+
# Example of documenting the behaviour explicitly and expressing the intent in the example's sentence.
|
7
|
+
describe "Signup Email", :type => :model do
|
8
|
+
include EmailSpec::Helpers
|
9
|
+
include EmailSpec::Matchers
|
10
|
+
include ::Rails.application.routes.url_helpers
|
11
|
+
|
12
|
+
subject { UserMailer.signup("jojo@yahoo.com", "Jojo Binks") }
|
13
|
+
|
14
|
+
it "should be delivered to the email passed in" do
|
15
|
+
is_expected.to deliver_to("jojo@yahoo.com")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should contain the user's name in the mail body" do
|
19
|
+
is_expected.to have_body_text(/Jojo Binks/)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should contain a link to the confirmation page" do
|
23
|
+
is_expected.to have_body_text(/#{confirm_account_url(:host => 'example.com')}/)
|
24
|
+
end
|
25
|
+
|
26
|
+
it { is_expected.to have_subject(/Account confirmation/) }
|
27
|
+
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
# In this example group more of the documentation is placed in the context trying to allow for more concise specs.
|
32
|
+
describe "Signup Email", :type => :model do
|
33
|
+
include EmailSpec::Helpers
|
34
|
+
include EmailSpec::Matchers
|
35
|
+
include ::Rails.application.routes.url_helpers
|
36
|
+
|
37
|
+
subject { UserMailer.signup("jojo@yahoo.com", "Jojo Binks") }
|
38
|
+
|
39
|
+
it { is_expected.to have_body_text(/#{confirm_account_url(:host => 'example.com')}/) }
|
40
|
+
it { is_expected.to have_subject(/Account confirmation/) }
|
41
|
+
|
42
|
+
describe "sent with email address of 'jojo@yahoo.com', and users name 'Jojo Binks'" do
|
43
|
+
subject { UserMailer.signup("jojo@yahoo.com", "Jojo Binks") }
|
44
|
+
it { is_expected.to deliver_to("jojo@yahoo.com") }
|
45
|
+
it { is_expected.to have_body_text(/Jojo Binks/) }
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
|
2
|
+
# from the project root directory.
|
3
|
+
ENV["RAILS_ENV"] ||= 'test'
|
4
|
+
require File.dirname(__FILE__) + "/../config/environment"
|
5
|
+
require 'rspec/rails'
|
6
|
+
|
7
|
+
# Requires supporting files with custom matchers and macros, etc,
|
8
|
+
# in ./support/ and its subdirectories.
|
9
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
10
|
+
RSpec.configure do |config|
|
11
|
+
# == Mock Framework
|
12
|
+
#
|
13
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
14
|
+
#
|
15
|
+
# config.mock_with :mocha
|
16
|
+
# config.mock_with :flexmock
|
17
|
+
# config.mock_with :rr
|
18
|
+
config.mock_with :rspec
|
19
|
+
config.raise_errors_for_deprecations!
|
20
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class TestUserMailer < Minitest::Test
|
4
|
+
include ::Rails.application.routes.url_helpers
|
5
|
+
include EmailSpec::Helpers
|
6
|
+
include EmailSpec::Matchers
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@email = UserMailer.signup("jojo@yahoo.com", "Jojo Binks")
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_delivered
|
13
|
+
assert_must deliver_to("jojo@yahoo.com"), @email
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_contains_users_name
|
17
|
+
assert_must have_body_text(/Jojo Binks/), @email
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_link_to_confirmation_page
|
21
|
+
assert_must have_body_text(/#{confirm_account_url(:host => 'example.com')}/), @email
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_subject
|
25
|
+
assert_must have_subject(/Account confirmation/), @email
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
# Uncomment this line when RSpec no longer loads the DSL in every project that
|
4
|
+
# has a dependency on it in the Gemfile, and stomps on MiniTest's `describe`...
|
5
|
+
# This is not an issue for Rails projects that don't use RSpec.
|
6
|
+
#describe UserMailer, :signup do
|
7
|
+
class UserMailerSpec < Minitest::Spec
|
8
|
+
include ::Rails.application.routes.url_helpers
|
9
|
+
include EmailSpec::Helpers
|
10
|
+
include EmailSpec::Matchers
|
11
|
+
|
12
|
+
let(:email) { UserMailer.signup("jojo@yahoo.com", "Jojo Binks") }
|
13
|
+
|
14
|
+
def test_is_delivered_to_the_email_passed_in
|
15
|
+
email.must deliver_to("jojo@yahoo.com")
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_contains_the_users_name_in_the_mail_body
|
19
|
+
email.must have_body_text(/Jojo Binks/)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_contains_a_link_to_the_confirmation_page
|
23
|
+
email.must have_body_text(/#{confirm_account_url(:host => 'example.com')}/)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_contains_the_correct_subject
|
27
|
+
email.must have_subject(/Account confirmation/)
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
2
|
+
require File.expand_path('../../config/environment', __FILE__)
|
3
|
+
require 'rails/test_help'
|
4
|
+
require "minitest/autorun"
|
5
|
+
|
6
|
+
class ActiveSupport::TestCase
|
7
|
+
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
8
|
+
fixtures :all
|
9
|
+
|
10
|
+
end
|
File without changes
|
@@ -49,15 +49,15 @@ end
|
|
49
49
|
#
|
50
50
|
|
51
51
|
Then /^(?:I|they|he|she|"([^"]*?)") should receive (an|no|\d+) emails?$/ do |address, amount|
|
52
|
-
unread_emails_for(address).size.
|
52
|
+
expect(unread_emails_for(address).size).to eql parse_email_count(amount)
|
53
53
|
end
|
54
54
|
|
55
55
|
Then /^(?:I|they|he|she|"([^"]*?)") should have (an|no|\d+) emails?$/ do |address, amount|
|
56
|
-
mailbox_for(address).size.
|
56
|
+
expect(mailbox_for(address).size).to eql parse_email_count(amount)
|
57
57
|
end
|
58
58
|
|
59
59
|
Then /^(?:I|they|he|she|"([^"]*?)") should receive (an|no|\d+) emails? with subject "([^"]*?)"$/ do |address, amount, subject|
|
60
|
-
unread_emails_for(address).select { |m| m.subject =~ Regexp.new(Regexp.escape(subject)) }.size.
|
60
|
+
expect(unread_emails_for(address).select { |m| m.subject =~ Regexp.new(Regexp.escape(subject)) }.size).to eql parse_email_count(amount)
|
61
61
|
end
|
62
62
|
|
63
63
|
Then /^(?:I|they|he|she|"([^"]*?)") should receive an email with the following body:$/ do |address, expected_body|
|
@@ -86,7 +86,7 @@ end
|
|
86
86
|
#
|
87
87
|
|
88
88
|
Then /^(?:I|they|he|she) should see "([^"]*?)" in the email subject$/ do |text|
|
89
|
-
current_email.
|
89
|
+
expect(current_email).to have_subject(text)
|
90
90
|
end
|
91
91
|
|
92
92
|
Then /^(?:I|they|he|she) should see "([^"]*?)" in the email body$/ do |text|
|
@@ -94,36 +94,40 @@ Then /^(?:I|they|he|she) should see "([^"]*?)" in the email body$/ do |text|
|
|
94
94
|
Then %(I should see "#{text}" in the html part of the email body)
|
95
95
|
Then %(I should see "#{text}" in the text part of the email body)
|
96
96
|
else
|
97
|
-
current_email.body.
|
97
|
+
expect(current_email.body).to match Regexp.new(text)
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
101
|
Then /^(?:I|they|he|she) should see "([^"]*?)" in the html part of the email body$/ do |text|
|
102
|
-
current_email.html_part.body.
|
102
|
+
expect(current_email.html_part.body).to match Regexp.new(text)
|
103
103
|
end
|
104
104
|
|
105
105
|
Then /^(?:I|they|he|she) should see "([^"]*?)" in the text part of the email body$/ do |text|
|
106
|
-
current_email.text_part.body.
|
106
|
+
expect(current_email.text_part.body).to match Regexp.new(text)
|
107
107
|
end
|
108
108
|
|
109
109
|
Then /^(?:I|they|he|she) should see "([^"]*?)" in the email body$/ do |text|
|
110
|
-
current_email.body.
|
110
|
+
expect(current_email.body).to include(text)
|
111
111
|
end
|
112
112
|
|
113
113
|
Then /^(?:I|they|he|she) should see \/([^"]*?)\/ in the email body$/ do |text|
|
114
|
-
current_email.body.
|
114
|
+
expect(current_email.body).to match Regexp.new(text)
|
115
115
|
end
|
116
116
|
|
117
117
|
Then /^(?:I|they|he|she) should see the email delivered from "([^"]*?)"$/ do |text|
|
118
|
-
current_email.
|
118
|
+
expect(current_email).to be_delivered_from(text)
|
119
|
+
end
|
120
|
+
|
121
|
+
Then /^(?:I|they) should see the email reply to "([^"]*?)"$/ do |text|
|
122
|
+
current_email.should have_reply_to(text)
|
119
123
|
end
|
120
124
|
|
121
125
|
Then /^(?:I|they|he|she) should see "([^\"]*)" in the email "([^"]*?)" header$/ do |text, name|
|
122
|
-
current_email.
|
126
|
+
expect(current_email).to have_header(name, text)
|
123
127
|
end
|
124
128
|
|
125
129
|
Then /^(?:I|they|he|she) should see \/([^\"]*)\/ in the email "([^"]*?)" header$/ do |text, name|
|
126
|
-
current_email.
|
130
|
+
expect(current_email).to have_header(name, Regexp.new(text))
|
127
131
|
end
|
128
132
|
|
129
133
|
#
|
@@ -131,28 +135,28 @@ end
|
|
131
135
|
#
|
132
136
|
|
133
137
|
Then /^(?:I|they|he|she) should see (an|no|\d+) attachments? with the email$/ do |amount|
|
134
|
-
current_email_attachments.size.
|
138
|
+
expect(current_email_attachments.size).to eql parse_email_count(amount)
|
135
139
|
end
|
136
140
|
|
137
141
|
Then /^there should be (an|no|\d+) attachments? named "([^"]*?)"$/ do |amount, filename|
|
138
|
-
current_email_attachments.select { |a| a.original_filename == filename }.size.
|
142
|
+
expect(current_email_attachments.select { |a| a.original_filename == filename }.size).to eql parse_email_count(amount)
|
139
143
|
end
|
140
144
|
|
141
145
|
Then /^attachment (\d+) should be named "([^"]*?)"$/ do |index, filename|
|
142
|
-
current_email_attachments[(index.to_i - 1)].original_filename.
|
146
|
+
expect(current_email_attachments[(index.to_i - 1)].original_filename).to eql filename
|
143
147
|
end
|
144
148
|
|
145
149
|
Then /^there should be (an|no|\d+) attachments? of type "([^"]*?)"$/ do |amount, content_type|
|
146
|
-
current_email_attachments.select { |a| a.content_type == content_type }.size.
|
150
|
+
expect(current_email_attachments.select { |a| a.content_type == content_type }.size).to eql parse_email_count(amount)
|
147
151
|
end
|
148
152
|
|
149
153
|
Then /^attachment (\d+) should be of type "([^"]*?)"$/ do |index, content_type|
|
150
|
-
current_email_attachments[(index.to_i - 1)].content_type.
|
154
|
+
expect(current_email_attachments[(index.to_i - 1)].content_type).to eql content_type
|
151
155
|
end
|
152
156
|
|
153
157
|
Then /^all attachments should not be blank$/ do
|
154
158
|
current_email_attachments.each do |attachment|
|
155
|
-
attachment.size.
|
159
|
+
expect(attachment.size).to_not eql 0
|
156
160
|
end
|
157
161
|
end
|
158
162
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'sinatra'
|
4
|
+
|
5
|
+
group :test do
|
6
|
+
gem 'cucumber'
|
7
|
+
gem "cucumber-sinatra", :require => false
|
8
|
+
gem 'pony'
|
9
|
+
gem 'capybara'
|
10
|
+
gem 'nokogiri'
|
11
|
+
gem 'xpath'
|
12
|
+
gem 'rspec'
|
13
|
+
gem 'rack-test'
|
14
|
+
gem "email_spec", :path => "../../", :require => "email_spec"
|
15
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../../
|
3
|
+
specs:
|
4
|
+
email_spec (2.0.0)
|
5
|
+
htmlentities (~> 4.3.3)
|
6
|
+
launchy (~> 2.1)
|
7
|
+
mail (~> 2.6.3)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: http://rubygems.org/
|
11
|
+
specs:
|
12
|
+
addressable (2.3.8)
|
13
|
+
builder (3.2.2)
|
14
|
+
capybara (2.4.4)
|
15
|
+
mime-types (>= 1.16)
|
16
|
+
nokogiri (>= 1.3.3)
|
17
|
+
rack (>= 1.0.0)
|
18
|
+
rack-test (>= 0.5.4)
|
19
|
+
xpath (~> 2.0)
|
20
|
+
cucumber (2.0.0)
|
21
|
+
builder (>= 2.1.2)
|
22
|
+
cucumber-core (~> 1.1.3)
|
23
|
+
diff-lcs (>= 1.1.3)
|
24
|
+
gherkin (~> 2.12)
|
25
|
+
multi_json (>= 1.7.5, < 2.0)
|
26
|
+
multi_test (>= 0.1.2)
|
27
|
+
cucumber-core (1.1.3)
|
28
|
+
gherkin (~> 2.12.0)
|
29
|
+
cucumber-sinatra (0.5.0)
|
30
|
+
templater (>= 1.0.0)
|
31
|
+
diff-lcs (1.2.5)
|
32
|
+
extlib (0.9.16)
|
33
|
+
gherkin (2.12.2)
|
34
|
+
multi_json (~> 1.3)
|
35
|
+
highline (1.7.2)
|
36
|
+
htmlentities (4.3.3)
|
37
|
+
launchy (2.4.3)
|
38
|
+
addressable (~> 2.3)
|
39
|
+
mail (2.6.3)
|
40
|
+
mime-types (>= 1.16, < 3)
|
41
|
+
mime-types (2.6.1)
|
42
|
+
mini_portile (0.6.2)
|
43
|
+
multi_json (1.11.1)
|
44
|
+
multi_test (0.1.2)
|
45
|
+
nokogiri (1.6.6.2)
|
46
|
+
mini_portile (~> 0.6.0)
|
47
|
+
pony (1.11)
|
48
|
+
mail (>= 2.0)
|
49
|
+
rack (1.6.4)
|
50
|
+
rack-protection (1.5.3)
|
51
|
+
rack
|
52
|
+
rack-test (0.6.3)
|
53
|
+
rack (>= 1.0)
|
54
|
+
rspec (3.3.0)
|
55
|
+
rspec-core (~> 3.3.0)
|
56
|
+
rspec-expectations (~> 3.3.0)
|
57
|
+
rspec-mocks (~> 3.3.0)
|
58
|
+
rspec-core (3.3.1)
|
59
|
+
rspec-support (~> 3.3.0)
|
60
|
+
rspec-expectations (3.3.0)
|
61
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
62
|
+
rspec-support (~> 3.3.0)
|
63
|
+
rspec-mocks (3.3.1)
|
64
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
65
|
+
rspec-support (~> 3.3.0)
|
66
|
+
rspec-support (3.3.0)
|
67
|
+
sinatra (1.4.6)
|
68
|
+
rack (~> 1.4)
|
69
|
+
rack-protection (~> 1.4)
|
70
|
+
tilt (>= 1.3, < 3)
|
71
|
+
templater (1.0.0)
|
72
|
+
diff-lcs (>= 1.1.2)
|
73
|
+
extlib (>= 0.9.5)
|
74
|
+
highline (>= 1.4.0)
|
75
|
+
tilt (2.0.1)
|
76
|
+
xpath (2.0.0)
|
77
|
+
nokogiri (~> 1.3)
|
78
|
+
|
79
|
+
PLATFORMS
|
80
|
+
ruby
|
81
|
+
|
82
|
+
DEPENDENCIES
|
83
|
+
capybara
|
84
|
+
cucumber
|
85
|
+
cucumber-sinatra
|
86
|
+
email_spec!
|
87
|
+
nokogiri
|
88
|
+
pony
|
89
|
+
rack-test
|
90
|
+
rspec
|
91
|
+
sinatra
|
92
|
+
xpath
|
93
|
+
|
94
|
+
BUNDLED WITH
|
95
|
+
1.10.5
|