bmabey-email_spec 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -3
- data/README.rdoc +4 -5
- data/Rakefile +6 -6
- data/{spec → examples}/rails_root/Rakefile +0 -0
- data/{spec → examples}/rails_root/app/controllers/application.rb +0 -0
- data/{spec → examples}/rails_root/app/controllers/welcome_controller.rb +0 -0
- data/{spec → examples}/rails_root/app/helpers/application_helper.rb +0 -0
- data/{spec → examples}/rails_root/app/helpers/welcome_helper.rb +0 -0
- data/{spec → examples}/rails_root/app/models/user_mailer.rb +0 -0
- data/{spec → examples}/rails_root/app/views/user_mailer/signup.erb +0 -0
- data/{spec → examples}/rails_root/app/views/welcome/confirm.html.erb +0 -0
- data/{spec → examples}/rails_root/app/views/welcome/index.html.erb +0 -0
- data/{spec → examples}/rails_root/app/views/welcome/signup.html.erb +0 -0
- data/{spec → examples}/rails_root/config/boot.rb +0 -0
- data/{spec → examples}/rails_root/config/database.yml +0 -0
- data/{spec → examples}/rails_root/config/environment.rb +0 -0
- data/{spec → examples}/rails_root/config/environments/development.rb +0 -0
- data/{spec → examples}/rails_root/config/environments/production.rb +0 -0
- data/{spec → examples}/rails_root/config/environments/test.rb +0 -0
- data/{spec → examples}/rails_root/config/initializers/inflections.rb +0 -0
- data/{spec → examples}/rails_root/config/initializers/mime_types.rb +0 -0
- data/{spec → examples}/rails_root/config/initializers/new_rails_defaults.rb +0 -0
- data/{spec → examples}/rails_root/config/routes.rb +0 -0
- data/{spec → examples}/rails_root/db/schema.rb +0 -0
- data/{spec → examples}/rails_root/doc/README_FOR_APP +0 -0
- data/{spec → examples}/rails_root/features/errors.feature +0 -0
- data/{spec → examples}/rails_root/features/example.feature +0 -0
- data/{spec/rails_root/vendor/plugins/email_spec/generators/email_spec/templates → examples/rails_root/features/step_definitions}/email_steps.rb +1 -1
- data/{spec → examples}/rails_root/features/step_definitions/webrat_steps.rb +0 -0
- data/{spec → examples}/rails_root/features/support/env.rb +0 -0
- data/examples/rails_root/lib/tasks/rspec.rake +158 -0
- data/{spec → examples}/rails_root/public/404.html +0 -0
- data/{spec → examples}/rails_root/public/422.html +0 -0
- data/{spec → examples}/rails_root/public/500.html +0 -0
- data/{spec → examples}/rails_root/public/dispatch.rb +0 -0
- data/{spec → examples}/rails_root/public/favicon.ico +0 -0
- data/{spec → examples}/rails_root/public/images/rails.png +0 -0
- data/{spec → examples}/rails_root/public/javascripts/application.js +0 -0
- data/{spec → examples}/rails_root/public/javascripts/controls.js +0 -0
- data/{spec → examples}/rails_root/public/javascripts/dragdrop.js +0 -0
- data/{spec → examples}/rails_root/public/javascripts/effects.js +0 -0
- data/{spec → examples}/rails_root/public/javascripts/prototype.js +0 -0
- data/{spec → examples}/rails_root/public/robots.txt +0 -0
- data/{spec → examples}/rails_root/script/about +0 -0
- data/{spec → examples}/rails_root/script/autospec +0 -0
- data/{spec → examples}/rails_root/script/console +0 -0
- data/{spec → examples}/rails_root/script/cucumber +0 -0
- data/{spec → examples}/rails_root/script/dbconsole +0 -0
- data/{spec → examples}/rails_root/script/destroy +0 -0
- data/{spec → examples}/rails_root/script/generate +0 -0
- data/{spec → examples}/rails_root/script/performance/benchmarker +0 -0
- data/{spec → examples}/rails_root/script/performance/profiler +0 -0
- data/{spec → examples}/rails_root/script/performance/request +0 -0
- data/{spec → examples}/rails_root/script/plugin +0 -0
- data/{spec → examples}/rails_root/script/process/inspector +0 -0
- data/{spec → examples}/rails_root/script/process/reaper +0 -0
- data/{spec → examples}/rails_root/script/process/spawner +0 -0
- data/{spec → examples}/rails_root/script/runner +0 -0
- data/{spec → examples}/rails_root/script/server +0 -0
- data/{spec → examples}/rails_root/script/spec +0 -0
- data/{spec → examples}/rails_root/script/spec_server +17 -8
- data/{spec → examples}/rails_root/spec/controllers/welcome_controller_spec.rb +0 -0
- data/{spec → examples}/rails_root/spec/models/user_mailer_spec.rb +8 -6
- data/{spec → examples}/rails_root/spec/rcov.opts +0 -0
- data/{spec → examples}/rails_root/spec/spec.opts +1 -1
- data/{spec → examples}/rails_root/spec/spec_helper.rb +6 -6
- data/examples/rails_root/stories/all.rb +4 -0
- data/examples/rails_root/stories/helper.rb +3 -0
- data/{spec → examples}/rails_root/vendor/plugins/email_spec/generators/email_spec/email_spec_generator.rb +0 -0
- data/{spec/rails_root/features/step_definitions → examples/rails_root/vendor/plugins/email_spec/generators/email_spec/templates}/email_steps.rb +1 -1
- data/examples/rails_root/vendor/plugins/rspec-rails +1 -0
- data/generators/email_spec/templates/email_steps.rb +1 -1
- data/lib/email_spec.rb +1 -1
- data/lib/email_spec/helpers.rb +3 -0
- data/lib/email_spec/matchers.rb +29 -8
- data/spec/email_spec/matchers_spec.rb +105 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +4 -0
- metadata +114 -106
- data/spec/email_spec_helpers_spec.rb +0 -28
data/History.txt
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
(In Git)
|
2
|
-
|
2
|
+
=== New features
|
3
3
|
|
4
|
+
== 0.0.7 2008-1-20
|
5
|
+
=== New features
|
6
|
+
* have_subject matcher
|
4
7
|
|
5
8
|
== 0.0.6 2008-12-23
|
6
9
|
=== New features
|
7
|
-
* Improved RSpec
|
10
|
+
* Improved RSpec documentation and refactorings. (Ben Mabey)
|
8
11
|
=== Bugfixes
|
9
12
|
* Removed sample app Rake Tasks to have it play nice with environments that use Cucumber as plugin- not gem. (Ben Mabey, Ivor- on github)
|
10
13
|
|
11
14
|
== 0.0.5 2008-12-18
|
12
|
-
* Initial release - see this post for full history and
|
15
|
+
* Initial release - see this post for full history and contributors: http://www.benmabey.com/2008/12/18/github-rocks/
|
data/README.rdoc
CHANGED
@@ -7,7 +7,7 @@ A collection of RSpec matchers and Cucumber steps to make testing emails go smoo
|
|
7
7
|
|
8
8
|
script/plugin install git://github.com/bmabey/email-spec.git
|
9
9
|
|
10
|
-
=== Gem Setup
|
10
|
+
=== Gem Setup
|
11
11
|
|
12
12
|
gem install bmabey-email_spec
|
13
13
|
|
@@ -101,15 +101,15 @@ For more examples, check out spec/rails_root in the source for a small example a
|
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should contain the user's message in the mail body" do
|
104
|
-
@email.
|
104
|
+
@email.should have_text(/Jojo Binks/)
|
105
105
|
end
|
106
106
|
|
107
107
|
it "should contain a link to the confirmation link" do
|
108
|
-
@email.
|
108
|
+
@email.should have_text(/#{confirm_account_url}/)
|
109
109
|
end
|
110
110
|
|
111
111
|
it "should have the correct subject" do
|
112
|
-
@email.
|
112
|
+
@email.should have_subject(/Account confirmation/)
|
113
113
|
end
|
114
114
|
|
115
115
|
end
|
@@ -124,4 +124,3 @@ For more examples, check out spec/rails_root in the source for a small example a
|
|
124
124
|
Ben Mabey, Aaron Gibralter, Mischa Fierer
|
125
125
|
|
126
126
|
Please see History.txt for upcoming changsets and other contributors.
|
127
|
-
|
data/Rakefile
CHANGED
@@ -5,14 +5,14 @@ spec = Gem::Specification.new do |s|
|
|
5
5
|
s.name = "email_spec"
|
6
6
|
s.version = EmailSpec::VERSION
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
|
-
s.authors = ['Ben
|
8
|
+
s.authors = ['Ben Mabey', 'Aaron Gibralter', 'Mischa Fierer']
|
9
9
|
s.email = "ben@benmabey.com"
|
10
10
|
s.homepage = "http://github.com/bmabey/email-spec/"
|
11
11
|
s.summary = "Easily test email in rspec and cucumber"
|
12
12
|
s.bindir = "bin"
|
13
13
|
s.description = s.summary
|
14
14
|
s.require_path = "lib"
|
15
|
-
s.files = %w(History.txt install.rb MIT-LICENSE.txt README.rdoc Rakefile) + Dir["lib/**/*"] + Dir["generators/**/*"] + Dir["spec/**/*"]
|
15
|
+
s.files = %w(History.txt install.rb MIT-LICENSE.txt README.rdoc Rakefile) + Dir["lib/**/*"] + Dir["generators/**/*"] + Dir["spec/**/*"] + Dir["examples/**/*"]
|
16
16
|
# rdoc
|
17
17
|
s.has_rdoc = true
|
18
18
|
s.extra_rdoc_files = %w(README.rdoc MIT-LICENSE.txt)
|
@@ -44,13 +44,13 @@ end
|
|
44
44
|
|
45
45
|
desc "Run the generator on the tests"
|
46
46
|
task :generate do
|
47
|
-
system "mkdir -p
|
48
|
-
system "cp -R generators
|
49
|
-
system "cd
|
47
|
+
system "mkdir -p examples/rails_root/vendor/plugins/email_spec"
|
48
|
+
system "cp -R generators examples/rails_root/vendor/plugins/email_spec"
|
49
|
+
system "cd examples/rails_root; ./script/generate email_spec"
|
50
50
|
end
|
51
51
|
|
52
52
|
task :features => [:generate] do
|
53
|
-
system("cucumber
|
53
|
+
system("cucumber examples/rails_root/features")
|
54
54
|
end
|
55
55
|
|
56
56
|
task :default => :features
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -53,7 +53,7 @@ Then /^"([^']*?)" should not receive an email$/ do |address|
|
|
53
53
|
end
|
54
54
|
|
55
55
|
Then /^I should see "(.*)" in the subject$/ do |text|
|
56
|
-
current_email.
|
56
|
+
current_email.should have_subject(Regexp.new(text))
|
57
57
|
end
|
58
58
|
|
59
59
|
Then /^I should see "(.*)" in the email$/ do |text|
|
File without changes
|
File without changes
|
@@ -0,0 +1,158 @@
|
|
1
|
+
rspec_gem_dir = nil
|
2
|
+
Dir["#{RAILS_ROOT}/vendor/gems/*"].each do |subdir|
|
3
|
+
rspec_gem_dir = subdir if subdir.gsub("#{RAILS_ROOT}/vendor/gems/","") =~ /^(\w+-)?rspec-(\d+)/ && File.exist?("#{subdir}/lib/spec/rake/spectask.rb")
|
4
|
+
end
|
5
|
+
rspec_plugin_dir = File.expand_path(File.dirname(__FILE__) + '/../../vendor/plugins/rspec')
|
6
|
+
|
7
|
+
if rspec_gem_dir && (test ?d, rspec_plugin_dir)
|
8
|
+
raise "\n#{'*'*50}\nYou have rspec installed in both vendor/gems and vendor/plugins\nPlease pick one and dispose of the other.\n#{'*'*50}\n\n"
|
9
|
+
end
|
10
|
+
|
11
|
+
if rspec_gem_dir
|
12
|
+
$LOAD_PATH.unshift("#{rspec_gem_dir}/lib")
|
13
|
+
elsif File.exist?(rspec_plugin_dir)
|
14
|
+
$LOAD_PATH.unshift("#{rspec_plugin_dir}/lib")
|
15
|
+
end
|
16
|
+
|
17
|
+
begin
|
18
|
+
require 'spec/rake/spectask'
|
19
|
+
Rake.application.instance_variable_get('@tasks').delete('default')
|
20
|
+
|
21
|
+
spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop
|
22
|
+
task :noop do
|
23
|
+
end
|
24
|
+
|
25
|
+
task :default => :spec
|
26
|
+
task :stats => "spec:statsetup"
|
27
|
+
|
28
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
29
|
+
Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t|
|
30
|
+
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
31
|
+
t.spec_files = FileList['spec/**/*/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
namespace :spec do
|
35
|
+
desc "Run all specs in spec directory with RCov (excluding plugin specs)"
|
36
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
37
|
+
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
38
|
+
t.spec_files = FileList['spec/**/*/*_spec.rb']
|
39
|
+
t.rcov = true
|
40
|
+
t.rcov_opts = lambda do
|
41
|
+
IO.readlines("#{RAILS_ROOT}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "Print Specdoc for all specs (excluding plugin specs)"
|
46
|
+
Spec::Rake::SpecTask.new(:doc) do |t|
|
47
|
+
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
48
|
+
t.spec_files = FileList['spec/**/*/*_spec.rb']
|
49
|
+
end
|
50
|
+
|
51
|
+
desc "Print Specdoc for all plugin examples"
|
52
|
+
Spec::Rake::SpecTask.new(:plugin_doc) do |t|
|
53
|
+
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
54
|
+
t.spec_files = FileList['vendor/plugins/**/spec/**/*/*_spec.rb'].exclude('vendor/plugins/rspec/*')
|
55
|
+
end
|
56
|
+
|
57
|
+
[:models, :controllers, :views, :helpers, :lib].each do |sub|
|
58
|
+
desc "Run the code examples in spec/#{sub}"
|
59
|
+
Spec::Rake::SpecTask.new(sub => spec_prereq) do |t|
|
60
|
+
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
61
|
+
t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "Run the code examples in vendor/plugins (except RSpec's own)"
|
66
|
+
Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t|
|
67
|
+
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
68
|
+
t.spec_files = FileList['vendor/plugins/**/spec/**/*/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*")
|
69
|
+
end
|
70
|
+
|
71
|
+
namespace :plugins do
|
72
|
+
desc "Runs the examples for rspec_on_rails"
|
73
|
+
Spec::Rake::SpecTask.new(:rspec_on_rails) do |t|
|
74
|
+
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
75
|
+
t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*/*_spec.rb']
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# Setup specs for stats
|
80
|
+
task :statsetup do
|
81
|
+
require 'code_statistics'
|
82
|
+
::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models')
|
83
|
+
::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views')
|
84
|
+
::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers')
|
85
|
+
::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers')
|
86
|
+
::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib')
|
87
|
+
::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models')
|
88
|
+
::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views')
|
89
|
+
::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers')
|
90
|
+
::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers')
|
91
|
+
::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib')
|
92
|
+
::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
|
93
|
+
end
|
94
|
+
|
95
|
+
namespace :db do
|
96
|
+
namespace :fixtures do
|
97
|
+
desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z."
|
98
|
+
task :load => :environment do
|
99
|
+
ActiveRecord::Base.establish_connection(Rails.env)
|
100
|
+
base_dir = File.join(Rails.root, 'spec', 'fixtures')
|
101
|
+
fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir
|
102
|
+
|
103
|
+
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file|
|
104
|
+
Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*'))
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
namespace :server do
|
111
|
+
daemonized_server_pid = File.expand_path("spec_server.pid", RAILS_ROOT + "/tmp")
|
112
|
+
|
113
|
+
desc "start spec_server."
|
114
|
+
task :start do
|
115
|
+
if File.exist?(daemonized_server_pid)
|
116
|
+
$stderr.puts "spec_server is already running."
|
117
|
+
else
|
118
|
+
$stderr.puts "Starting up spec server."
|
119
|
+
system("ruby", "script/spec_server", "--daemon", "--pid", daemonized_server_pid)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
desc "stop spec_server."
|
124
|
+
task :stop do
|
125
|
+
unless File.exist?(daemonized_server_pid)
|
126
|
+
$stderr.puts "No server running."
|
127
|
+
else
|
128
|
+
$stderr.puts "Shutting down spec_server."
|
129
|
+
system("kill", "-s", "TERM", File.read(daemonized_server_pid).strip) &&
|
130
|
+
File.delete(daemonized_server_pid)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
desc "reload spec_server."
|
135
|
+
task :restart do
|
136
|
+
unless File.exist?(daemonized_server_pid)
|
137
|
+
$stderr.puts "No server running."
|
138
|
+
else
|
139
|
+
$stderr.puts "Reloading down spec_server."
|
140
|
+
system("kill", "-s", "USR2", File.read(daemonized_server_pid).strip)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
rescue MissingSourceFile
|
146
|
+
# if rspec-rails is a configured gem, this will output helpful material and exit ...
|
147
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
|
148
|
+
|
149
|
+
# ... otherwise, do this:
|
150
|
+
raise <<-MSG
|
151
|
+
|
152
|
+
You have rspec rake tasks installed in
|
153
|
+
#{__FILE__},
|
154
|
+
but rspec can not be found in vendor/gems, vendor/plugins or on the system.
|
155
|
+
|
156
|
+
MSG
|
157
|
+
end
|
158
|
+
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -13,17 +13,21 @@ module Spec
|
|
13
13
|
def run(argv, stderr, stdout)
|
14
14
|
$stdout = stdout
|
15
15
|
$stderr = stderr
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
conn.
|
22
|
-
|
16
|
+
|
17
|
+
unless ActiveRecord::Base.respond_to?(:clear_reloadable_connections!)
|
18
|
+
base = ActiveRecord::Base
|
19
|
+
def base.clear_reloadable_connections!
|
20
|
+
active_connections.each do |name, conn|
|
21
|
+
if conn.requires_reloading?
|
22
|
+
conn.disconnect!
|
23
|
+
active_connections.delete(name)
|
24
|
+
end
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
29
|
+
ActiveRecord::Base.clear_reloadable_connections!
|
30
|
+
|
27
31
|
if ActionController.const_defined?(:Dispatcher)
|
28
32
|
dispatcher = ::ActionController::Dispatcher.new($stdout)
|
29
33
|
dispatcher.cleanup_application
|
@@ -35,8 +39,13 @@ module Spec
|
|
35
39
|
if Object.const_defined?(:Fixtures) && Fixtures.respond_to?(:reset_cache)
|
36
40
|
Fixtures.reset_cache
|
37
41
|
end
|
42
|
+
|
43
|
+
if ::ActiveSupport.const_defined?(:Dependencies)
|
44
|
+
::ActiveSupport::Dependencies.mechanism = :load
|
45
|
+
else
|
46
|
+
::Dependencies.mechanism = :load
|
47
|
+
end
|
38
48
|
|
39
|
-
::Dependencies.mechanism = :load
|
40
49
|
require_dependency('application.rb') unless Object.const_defined?(:ApplicationController)
|
41
50
|
load File.dirname(__FILE__) + '/../spec/spec_helper.rb'
|
42
51
|
|
File without changes
|
@@ -8,22 +8,24 @@ describe "Signup Email" do
|
|
8
8
|
before(:all) do
|
9
9
|
@email = UserMailer.create_signup("jojo@yahoo.com", "Jojo Binks")
|
10
10
|
end
|
11
|
+
|
12
|
+
subject { @email }
|
11
13
|
|
12
14
|
it "should be set to be delivered to the email passed in" do
|
13
|
-
|
15
|
+
should deliver_to("jojo@yahoo.com")
|
14
16
|
end
|
15
17
|
|
16
18
|
it "should contain the user's message in the mail body" do
|
17
|
-
@email.
|
19
|
+
@email.should have_text(/Jojo Binks/)
|
18
20
|
end
|
19
21
|
|
22
|
+
it { should have_text(/Jojo Binks/) }
|
23
|
+
|
20
24
|
it "should contain a link to the confirmation link" do
|
21
|
-
@email.
|
25
|
+
@email.should have_text(/#{confirm_account_url}/)
|
22
26
|
end
|
23
27
|
|
24
|
-
it
|
25
|
-
@email.subject.should =~ /Account confirmation/
|
26
|
-
end
|
28
|
+
it { should have_subject(/Account confirmation/) }
|
27
29
|
|
28
30
|
|
29
31
|
end
|
File without changes
|
@@ -5,16 +5,16 @@ require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
|
5
5
|
require 'spec'
|
6
6
|
require 'spec/rails'
|
7
7
|
|
8
|
-
require
|
9
|
-
require
|
8
|
+
require (Rails.root + '/../../lib/email_spec/helpers.rb')
|
9
|
+
require (Rails.root + '/../../lib/email_spec/matchers.rb')
|
10
10
|
|
11
11
|
Spec::Runner.configure do |config|
|
12
12
|
# If you're not using ActiveRecord you should remove these
|
13
13
|
# lines, delete config/database.yml and disable :active_record
|
14
14
|
# in your config/boot.rb
|
15
|
-
config.use_transactional_fixtures = true
|
16
|
-
config.use_instantiated_fixtures = false
|
17
|
-
config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
|
15
|
+
#config.use_transactional_fixtures = true
|
16
|
+
#config.use_instantiated_fixtures = false
|
17
|
+
#config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
|
18
18
|
|
19
19
|
# == Fixtures
|
20
20
|
#
|
@@ -46,5 +46,5 @@ Spec::Runner.configure do |config|
|
|
46
46
|
#
|
47
47
|
# == Notes
|
48
48
|
#
|
49
|
-
# For more information take a look at Spec::
|
49
|
+
# For more information take a look at Spec::Runner::Configuration and Spec::Runner
|
50
50
|
end
|
File without changes
|
@@ -53,7 +53,7 @@ Then /^"([^']*?)" should not receive an email$/ do |address|
|
|
53
53
|
end
|
54
54
|
|
55
55
|
Then /^I should see "(.*)" in the subject$/ do |text|
|
56
|
-
current_email.
|
56
|
+
current_email.should have_subject(Regexp.new(text))
|
57
57
|
end
|
58
58
|
|
59
59
|
Then /^I should see "(.*)" in the email$/ do |text|
|
@@ -0,0 +1 @@
|
|
1
|
+
/Users/bmabey/p/ruby/rspec-dev/example_rails_app/vendor/plugins/rspec-rails
|
@@ -53,7 +53,7 @@ Then /^"([^']*?)" should not receive an email$/ do |address|
|
|
53
53
|
end
|
54
54
|
|
55
55
|
Then /^I should see "(.*)" in the subject$/ do |text|
|
56
|
-
current_email.
|
56
|
+
current_email.should have_subject(Regexp.new(text))
|
57
57
|
end
|
58
58
|
|
59
59
|
Then /^I should see "(.*)" in the email$/ do |text|
|
data/lib/email_spec.rb
CHANGED
data/lib/email_spec/helpers.rb
CHANGED
data/lib/email_spec/matchers.rb
CHANGED
@@ -4,15 +4,18 @@ module EmailSpec
|
|
4
4
|
|
5
5
|
class DeliverTo
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
|
7
|
+
def initialize(expected_email_addresses_or_objects_that_respond_to_email)
|
8
|
+
emails = expected_email_addresses_or_objects_that_respond_to_email.map do |email_or_object|
|
9
|
+
email_or_object.kind_of?(String) ? email_or_object : email_or_object.email
|
10
|
+
end
|
11
|
+
|
12
|
+
@expected_email_addresses = emails.sort
|
9
13
|
end
|
10
14
|
|
11
15
|
def matches?(email)
|
12
16
|
@email = email
|
13
17
|
@actual_recipients = (email.to || []).sort
|
14
|
-
@actual_recipients
|
15
|
-
true
|
18
|
+
@actual_recipients == @expected_email_addresses
|
16
19
|
end
|
17
20
|
|
18
21
|
def failure_message
|
@@ -25,10 +28,28 @@ module EmailSpec
|
|
25
28
|
end
|
26
29
|
|
27
30
|
def deliver_to(*expected_email_addresses_or_objects_that_respond_to_email)
|
28
|
-
|
29
|
-
email_or_object.kind_of?(String) ? email_or_object : email_or_object.email
|
30
|
-
end
|
31
|
-
DeliverTo.new(emails)
|
31
|
+
DeliverTo.new(expected_email_addresses_or_objects_that_respond_to_email)
|
32
32
|
end
|
33
|
+
|
34
|
+
def have_subject(expected)
|
35
|
+
simple_matcher do |given, matcher|
|
36
|
+
given_subject = given.subject
|
37
|
+
|
38
|
+
if expected.is_a?(String)
|
39
|
+
matcher.description = "have subject of #{expected.inspect}"
|
40
|
+
matcher.failure_message = "expected the subject to be #{expected.inspect} but was #{given_subject.inspect}"
|
41
|
+
matcher.negative_failure_message = "expected the subject not to be #{expected.inspect} but was"
|
42
|
+
|
43
|
+
given_subject == expected
|
44
|
+
else
|
45
|
+
matcher.description = "have subject matching #{expected.inspect}"
|
46
|
+
matcher.failure_message = "expected the subject to match #{expected.inspect}, but did not. Actual subject was: #{given_subject.inspect}"
|
47
|
+
matcher.negative_failure_message = "expected the subject not to match #{expected.inspect} but #{given_subject.inspect} does match it."
|
48
|
+
|
49
|
+
!!(given_subject =~ expected)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
33
54
|
end
|
34
55
|
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe EmailSpec::Matchers do
|
5
|
+
|
6
|
+
include EmailSpec::Matchers
|
7
|
+
|
8
|
+
def mock_email(stubs)
|
9
|
+
mock("email", stubs)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#deliver_to" do
|
13
|
+
|
14
|
+
it "should match when the email is set to deliver to the specidied address" do
|
15
|
+
email = mock_email(:to => "jimmy_bean@yahoo.com")
|
16
|
+
|
17
|
+
deliver_to("jimmy_bean@yahoo.com").matches?(email).should be_true
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should match when a list of emails is exact same as all of the email's recipients" do
|
21
|
+
email = mock_email(:to => ["james@yahoo.com", "karen@yahoo.com"])
|
22
|
+
|
23
|
+
deliver_to("karen@yahoo.com", "james@yahoo.com").matches?(email).should be_true
|
24
|
+
deliver_to("karen@yahoo.com").matches?(email).should be_false
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should use the passed in objects :email method if not a string" do
|
28
|
+
email = mock_email(:to => "jimmy_bean@yahoo.com")
|
29
|
+
user = mock("user", :email => "jimmy_bean@yahoo.com")
|
30
|
+
|
31
|
+
deliver_to(user).matches?(email).should be_true
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#have_subject" do
|
37
|
+
|
38
|
+
describe "when regexps are used" do
|
39
|
+
|
40
|
+
it "should match when the subject mathches regexp" do
|
41
|
+
email = mock_email(:subject => ' -- The Subject --')
|
42
|
+
|
43
|
+
have_subject(/The Subject/).matches?(email).should be_true
|
44
|
+
have_subject(/The Subject/).matches?(email).should be_true
|
45
|
+
have_subject(/foo/).matches?(email).should be_false
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should have a helpful description" do
|
49
|
+
matcher = have_subject(/foo/)
|
50
|
+
matcher.matches?(mock_email(:subject => "bar"))
|
51
|
+
|
52
|
+
matcher.description.should == "have subject matching /foo/"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should offer helpful failing messages" do
|
56
|
+
matcher = have_subject(/foo/)
|
57
|
+
matcher.matches?(mock_email(:subject => "bar"))
|
58
|
+
|
59
|
+
matcher.failure_message.should == 'expected the subject to match /foo/, but did not. Actual subject was: "bar"'
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should offer helpful negative failing messages" do
|
63
|
+
matcher = have_subject(/b/)
|
64
|
+
matcher.matches?(mock_email(:subject => "bar"))
|
65
|
+
|
66
|
+
matcher.negative_failure_message.should == 'expected the subject not to match /b/ but "bar" does match it.'
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "when strings are used" do
|
72
|
+
|
73
|
+
it "should match when the subject equals the passed in string exactly" do
|
74
|
+
email = mock_email(:subject => 'foo')
|
75
|
+
|
76
|
+
have_subject("foo").matches?(email).should be_true
|
77
|
+
have_subject(" - foo -").matches?(email).should be_false
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should have a helpful description" do
|
81
|
+
matcher = have_subject("foo")
|
82
|
+
matcher.matches?(mock_email(:subject => "bar"))
|
83
|
+
|
84
|
+
matcher.description.should == 'have subject of "foo"'
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should offer helpful failing messages" do
|
88
|
+
matcher = have_subject("foo")
|
89
|
+
matcher.matches?(mock_email(:subject => "bar"))
|
90
|
+
|
91
|
+
matcher.failure_message.should == 'expected the subject to be "foo" but was "bar"'
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
it "should offer helpful negative failing messages" do
|
96
|
+
matcher = have_subject("bar")
|
97
|
+
matcher.matches?(mock_email(:subject => "bar"))
|
98
|
+
|
99
|
+
matcher.negative_failure_message.should == 'expected the subject not to be "bar" but was'
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bmabey-email_spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Ben
|
7
|
+
- Ben Mabey
|
8
8
|
- Aaron Gibralter
|
9
9
|
- Mischa Fierer
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date:
|
14
|
+
date: 2009-01-20 00:00:00 -08:00
|
15
15
|
default_executable:
|
16
16
|
dependencies: []
|
17
17
|
|
@@ -39,109 +39,117 @@ files:
|
|
39
39
|
- generators/email_spec/email_spec_generator.rb
|
40
40
|
- generators/email_spec/templates
|
41
41
|
- generators/email_spec/templates/email_steps.rb
|
42
|
-
- spec/
|
43
|
-
- spec/
|
44
|
-
- spec/
|
45
|
-
- spec/
|
46
|
-
-
|
47
|
-
-
|
48
|
-
-
|
49
|
-
-
|
50
|
-
-
|
51
|
-
-
|
52
|
-
-
|
53
|
-
-
|
54
|
-
-
|
55
|
-
-
|
56
|
-
-
|
57
|
-
-
|
58
|
-
-
|
59
|
-
-
|
60
|
-
-
|
61
|
-
-
|
62
|
-
-
|
63
|
-
-
|
64
|
-
-
|
65
|
-
-
|
66
|
-
-
|
67
|
-
-
|
68
|
-
-
|
69
|
-
-
|
70
|
-
-
|
71
|
-
-
|
72
|
-
-
|
73
|
-
-
|
74
|
-
-
|
75
|
-
-
|
76
|
-
-
|
77
|
-
-
|
78
|
-
-
|
79
|
-
-
|
80
|
-
-
|
81
|
-
-
|
82
|
-
-
|
83
|
-
-
|
84
|
-
-
|
85
|
-
-
|
86
|
-
-
|
87
|
-
-
|
88
|
-
-
|
89
|
-
-
|
90
|
-
-
|
91
|
-
-
|
92
|
-
-
|
93
|
-
-
|
94
|
-
-
|
95
|
-
-
|
96
|
-
-
|
97
|
-
-
|
98
|
-
-
|
99
|
-
-
|
100
|
-
-
|
101
|
-
-
|
102
|
-
-
|
103
|
-
-
|
104
|
-
-
|
105
|
-
-
|
106
|
-
-
|
107
|
-
-
|
108
|
-
-
|
109
|
-
-
|
110
|
-
-
|
111
|
-
-
|
112
|
-
-
|
113
|
-
-
|
114
|
-
-
|
115
|
-
-
|
116
|
-
-
|
117
|
-
-
|
118
|
-
-
|
119
|
-
-
|
120
|
-
-
|
121
|
-
-
|
122
|
-
-
|
123
|
-
-
|
124
|
-
-
|
125
|
-
-
|
126
|
-
-
|
127
|
-
-
|
128
|
-
-
|
129
|
-
-
|
130
|
-
-
|
131
|
-
-
|
132
|
-
-
|
133
|
-
-
|
134
|
-
-
|
135
|
-
-
|
136
|
-
-
|
137
|
-
-
|
138
|
-
-
|
139
|
-
-
|
140
|
-
-
|
141
|
-
-
|
142
|
-
-
|
143
|
-
-
|
144
|
-
-
|
42
|
+
- spec/email_spec
|
43
|
+
- spec/email_spec/matchers_spec.rb
|
44
|
+
- spec/spec.opts
|
45
|
+
- spec/spec_helper.rb
|
46
|
+
- examples/rails_root
|
47
|
+
- examples/rails_root/app
|
48
|
+
- examples/rails_root/app/controllers
|
49
|
+
- examples/rails_root/app/controllers/application.rb
|
50
|
+
- examples/rails_root/app/controllers/welcome_controller.rb
|
51
|
+
- examples/rails_root/app/helpers
|
52
|
+
- examples/rails_root/app/helpers/application_helper.rb
|
53
|
+
- examples/rails_root/app/helpers/welcome_helper.rb
|
54
|
+
- examples/rails_root/app/models
|
55
|
+
- examples/rails_root/app/models/user_mailer.rb
|
56
|
+
- examples/rails_root/app/views
|
57
|
+
- examples/rails_root/app/views/user_mailer
|
58
|
+
- examples/rails_root/app/views/user_mailer/signup.erb
|
59
|
+
- examples/rails_root/app/views/welcome
|
60
|
+
- examples/rails_root/app/views/welcome/confirm.html.erb
|
61
|
+
- examples/rails_root/app/views/welcome/index.html.erb
|
62
|
+
- examples/rails_root/app/views/welcome/signup.html.erb
|
63
|
+
- examples/rails_root/config
|
64
|
+
- examples/rails_root/config/boot.rb
|
65
|
+
- examples/rails_root/config/database.yml
|
66
|
+
- examples/rails_root/config/environment.rb
|
67
|
+
- examples/rails_root/config/environments
|
68
|
+
- examples/rails_root/config/environments/development.rb
|
69
|
+
- examples/rails_root/config/environments/production.rb
|
70
|
+
- examples/rails_root/config/environments/test.rb
|
71
|
+
- examples/rails_root/config/initializers
|
72
|
+
- examples/rails_root/config/initializers/inflections.rb
|
73
|
+
- examples/rails_root/config/initializers/mime_types.rb
|
74
|
+
- examples/rails_root/config/initializers/new_rails_defaults.rb
|
75
|
+
- examples/rails_root/config/routes.rb
|
76
|
+
- examples/rails_root/db
|
77
|
+
- examples/rails_root/db/development.sqlite3
|
78
|
+
- examples/rails_root/db/schema.rb
|
79
|
+
- examples/rails_root/db/test.sqlite3
|
80
|
+
- examples/rails_root/doc
|
81
|
+
- examples/rails_root/doc/README_FOR_APP
|
82
|
+
- examples/rails_root/features
|
83
|
+
- examples/rails_root/features/errors.feature
|
84
|
+
- examples/rails_root/features/example.feature
|
85
|
+
- examples/rails_root/features/step_definitions
|
86
|
+
- examples/rails_root/features/step_definitions/email_steps.rb
|
87
|
+
- examples/rails_root/features/step_definitions/webrat_steps.rb
|
88
|
+
- examples/rails_root/features/support
|
89
|
+
- examples/rails_root/features/support/env.rb
|
90
|
+
- examples/rails_root/lib
|
91
|
+
- examples/rails_root/lib/tasks
|
92
|
+
- examples/rails_root/lib/tasks/rspec.rake
|
93
|
+
- examples/rails_root/log
|
94
|
+
- examples/rails_root/log/development.log
|
95
|
+
- examples/rails_root/log/test.log
|
96
|
+
- examples/rails_root/public
|
97
|
+
- examples/rails_root/public/404.html
|
98
|
+
- examples/rails_root/public/422.html
|
99
|
+
- examples/rails_root/public/500.html
|
100
|
+
- examples/rails_root/public/dispatch.rb
|
101
|
+
- examples/rails_root/public/favicon.ico
|
102
|
+
- examples/rails_root/public/images
|
103
|
+
- examples/rails_root/public/images/rails.png
|
104
|
+
- examples/rails_root/public/javascripts
|
105
|
+
- examples/rails_root/public/javascripts/application.js
|
106
|
+
- examples/rails_root/public/javascripts/controls.js
|
107
|
+
- examples/rails_root/public/javascripts/dragdrop.js
|
108
|
+
- examples/rails_root/public/javascripts/effects.js
|
109
|
+
- examples/rails_root/public/javascripts/prototype.js
|
110
|
+
- examples/rails_root/public/robots.txt
|
111
|
+
- examples/rails_root/Rakefile
|
112
|
+
- examples/rails_root/script
|
113
|
+
- examples/rails_root/script/about
|
114
|
+
- examples/rails_root/script/autospec
|
115
|
+
- examples/rails_root/script/console
|
116
|
+
- examples/rails_root/script/cucumber
|
117
|
+
- examples/rails_root/script/dbconsole
|
118
|
+
- examples/rails_root/script/destroy
|
119
|
+
- examples/rails_root/script/generate
|
120
|
+
- examples/rails_root/script/performance
|
121
|
+
- examples/rails_root/script/performance/benchmarker
|
122
|
+
- examples/rails_root/script/performance/profiler
|
123
|
+
- examples/rails_root/script/performance/request
|
124
|
+
- examples/rails_root/script/plugin
|
125
|
+
- examples/rails_root/script/process
|
126
|
+
- examples/rails_root/script/process/inspector
|
127
|
+
- examples/rails_root/script/process/reaper
|
128
|
+
- examples/rails_root/script/process/spawner
|
129
|
+
- examples/rails_root/script/runner
|
130
|
+
- examples/rails_root/script/server
|
131
|
+
- examples/rails_root/script/spec
|
132
|
+
- examples/rails_root/script/spec_server
|
133
|
+
- examples/rails_root/spec
|
134
|
+
- examples/rails_root/spec/controllers
|
135
|
+
- examples/rails_root/spec/controllers/welcome_controller_spec.rb
|
136
|
+
- examples/rails_root/spec/models
|
137
|
+
- examples/rails_root/spec/models/user_mailer_spec.rb
|
138
|
+
- examples/rails_root/spec/rcov.opts
|
139
|
+
- examples/rails_root/spec/spec.opts
|
140
|
+
- examples/rails_root/spec/spec_helper.rb
|
141
|
+
- examples/rails_root/stories
|
142
|
+
- examples/rails_root/stories/all.rb
|
143
|
+
- examples/rails_root/stories/helper.rb
|
144
|
+
- examples/rails_root/vendor
|
145
|
+
- examples/rails_root/vendor/plugins
|
146
|
+
- examples/rails_root/vendor/plugins/email_spec
|
147
|
+
- examples/rails_root/vendor/plugins/email_spec/generators
|
148
|
+
- examples/rails_root/vendor/plugins/email_spec/generators/email_spec
|
149
|
+
- examples/rails_root/vendor/plugins/email_spec/generators/email_spec/email_spec_generator.rb
|
150
|
+
- examples/rails_root/vendor/plugins/email_spec/generators/email_spec/templates
|
151
|
+
- examples/rails_root/vendor/plugins/email_spec/generators/email_spec/templates/email_steps.rb
|
152
|
+
- examples/rails_root/vendor/plugins/rspec-rails
|
145
153
|
has_rdoc: true
|
146
154
|
homepage: http://github.com/bmabey/email-spec/
|
147
155
|
post_install_message:
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
#
|
3
|
-
# module ActionMailer
|
4
|
-
# class Base
|
5
|
-
# end
|
6
|
-
# end
|
7
|
-
#
|
8
|
-
#
|
9
|
-
# module EmailSpec
|
10
|
-
# describe Helpers do
|
11
|
-
# before(:all) do
|
12
|
-
# @helper = Object.new
|
13
|
-
# @helper.extend EmailSpec::Helpers
|
14
|
-
# end
|
15
|
-
#
|
16
|
-
# describe "#reset_mailer" do
|
17
|
-
# it "should empty the all email deliveries" do
|
18
|
-
# #given
|
19
|
-
# ActionMailer::Base.stub!(:deliveries).and_return([mock("some email", mock("another email"))])
|
20
|
-
# #when
|
21
|
-
# @helper.reset_mailer
|
22
|
-
# #then
|
23
|
-
# ActionMailer::Base.deliveries.should be_empty
|
24
|
-
# end
|
25
|
-
# end
|
26
|
-
# end
|
27
|
-
# end
|
28
|
-
#
|