path-email_spec 0.6.2
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.
- data/History.txt +199 -0
- data/MIT-LICENSE.txt +19 -0
- data/README.rdoc +137 -0
- data/Rakefile +64 -0
- data/examples/rails3_root/Gemfile +24 -0
- data/examples/rails3_root/README +5 -0
- data/examples/rails3_root/Rakefile +11 -0
- data/examples/rails3_root/app/controllers/application_controller.rb +3 -0
- data/examples/rails3_root/app/controllers/welcome_controller.rb +16 -0
- data/examples/rails3_root/app/helpers/application_helper.rb +2 -0
- data/examples/rails3_root/app/mailers/user_mailer.rb +39 -0
- data/examples/rails3_root/app/models/user.rb +2 -0
- data/examples/rails3_root/app/views/user_mailer/attachments.html.erb +6 -0
- data/examples/rails3_root/app/views/user_mailer/newsletter.html.erb +8 -0
- data/examples/rails3_root/app/views/user_mailer/signup.html.erb +3 -0
- data/examples/rails3_root/app/views/welcome/attachments.html.erb +0 -0
- data/examples/rails3_root/app/views/welcome/confirm.html.erb +1 -0
- data/examples/rails3_root/app/views/welcome/index.html.erb +8 -0
- data/examples/rails3_root/app/views/welcome/newsletter.html.erb +0 -0
- data/examples/rails3_root/app/views/welcome/signup.html.erb +1 -0
- data/examples/rails3_root/attachments/document.pdf +0 -0
- data/examples/rails3_root/attachments/image.png +0 -0
- data/examples/rails3_root/config.ru +4 -0
- data/examples/rails3_root/config/application.rb +43 -0
- data/examples/rails3_root/config/boot.rb +14 -0
- data/examples/rails3_root/config/cucumber.yml +7 -0
- data/examples/rails3_root/config/database.yml +25 -0
- data/examples/rails3_root/config/environment.rb +6 -0
- data/examples/rails3_root/config/environments/development.rb +19 -0
- data/examples/rails3_root/config/environments/production.rb +42 -0
- data/examples/rails3_root/config/environments/test.rb +29 -0
- data/examples/rails3_root/config/initializers/backtrace_silencers.rb +7 -0
- data/examples/rails3_root/config/initializers/cookie_verification_secret.rb +7 -0
- data/examples/rails3_root/config/initializers/inflections.rb +10 -0
- data/examples/rails3_root/config/initializers/mime_types.rb +5 -0
- data/examples/rails3_root/config/initializers/rspec_generator.rb +6 -0
- data/examples/rails3_root/config/initializers/session_store.rb +10 -0
- data/examples/rails3_root/config/locales/en.yml +5 -0
- data/examples/rails3_root/config/routes.rb +7 -0
- data/examples/rails3_root/db/migrate/20090125013728_create_users.rb +11 -0
- data/examples/rails3_root/db/migrate/20090908054656_create_delayed_jobs.rb +20 -0
- data/examples/rails3_root/db/schema.rb +32 -0
- data/examples/rails3_root/db/seeds.rb +7 -0
- data/examples/rails3_root/doc/README_FOR_APP +2 -0
- data/examples/rails3_root/features/attachments.feature +27 -0
- data/examples/rails3_root/features/delayed_job.feature +13 -0
- data/examples/rails3_root/features/errors.feature +32 -0
- data/examples/rails3_root/features/example.feature +62 -0
- data/examples/rails3_root/features/step_definitions/user_steps.rb +26 -0
- data/examples/rails3_root/features/step_definitions/web_steps.rb +202 -0
- data/examples/rails3_root/features/support/env.rb +59 -0
- data/examples/rails3_root/features/support/env_ext.rb +2 -0
- data/examples/rails3_root/features/support/paths.rb +33 -0
- data/examples/rails3_root/lib/tasks/cucumber.rake +47 -0
- data/examples/rails3_root/lib/tasks/rspec.rake +69 -0
- data/examples/rails3_root/public/404.html +26 -0
- data/examples/rails3_root/public/422.html +26 -0
- data/examples/rails3_root/public/500.html +26 -0
- data/examples/rails3_root/public/favicon.ico +0 -0
- data/examples/rails3_root/public/images/rails.png +0 -0
- data/examples/rails3_root/public/javascripts/application.js +2 -0
- data/examples/rails3_root/public/javascripts/controls.js +965 -0
- data/examples/rails3_root/public/javascripts/dragdrop.js +974 -0
- data/examples/rails3_root/public/javascripts/effects.js +1123 -0
- data/examples/rails3_root/public/javascripts/prototype.js +4874 -0
- data/examples/rails3_root/public/javascripts/rails.js +109 -0
- data/examples/rails3_root/public/robots.txt +5 -0
- data/examples/rails3_root/script/cucumber +10 -0
- data/examples/rails3_root/script/rails +9 -0
- data/examples/rails3_root/spec/controllers/welcome_controller_spec.rb +18 -0
- data/examples/rails3_root/spec/models/user_mailer_spec.rb +47 -0
- data/examples/rails3_root/spec/spec.opts +2 -0
- data/examples/rails3_root/spec/spec_helper.rb +19 -0
- data/examples/rails_root/Rakefile +13 -0
- data/examples/rails_root/app/controllers/application_controller.rb +15 -0
- data/examples/rails_root/app/controllers/welcome_controller.rb +16 -0
- data/examples/rails_root/app/helpers/application_helper.rb +3 -0
- data/examples/rails_root/app/helpers/welcome_helper.rb +2 -0
- data/examples/rails_root/app/models/user.rb +2 -0
- data/examples/rails_root/app/models/user_mailer.rb +39 -0
- data/examples/rails_root/app/views/user_mailer/attachments.erb +6 -0
- data/examples/rails_root/app/views/user_mailer/newsletter.erb +8 -0
- data/examples/rails_root/app/views/user_mailer/signup.erb +3 -0
- data/examples/rails_root/app/views/welcome/attachments.html.erb +0 -0
- data/examples/rails_root/app/views/welcome/confirm.html.erb +1 -0
- data/examples/rails_root/app/views/welcome/index.html.erb +8 -0
- data/examples/rails_root/app/views/welcome/newsletter.html.erb +0 -0
- data/examples/rails_root/app/views/welcome/signup.html.erb +1 -0
- data/examples/rails_root/attachments/document.pdf +0 -0
- data/examples/rails_root/attachments/image.png +0 -0
- data/examples/rails_root/config/boot.rb +110 -0
- data/examples/rails_root/config/cucumber.yml +7 -0
- data/examples/rails_root/config/database.yml +25 -0
- data/examples/rails_root/config/environment.rb +28 -0
- data/examples/rails_root/config/environments/cucumber.rb +29 -0
- data/examples/rails_root/config/environments/development.rb +17 -0
- data/examples/rails_root/config/environments/production.rb +28 -0
- data/examples/rails_root/config/environments/test.rb +28 -0
- data/examples/rails_root/config/initializers/inflections.rb +10 -0
- data/examples/rails_root/config/initializers/mime_types.rb +5 -0
- data/examples/rails_root/config/initializers/new_rails_defaults.rb +17 -0
- data/examples/rails_root/config/routes.rb +45 -0
- data/examples/rails_root/db/migrate/20090125013728_create_users.rb +11 -0
- data/examples/rails_root/db/migrate/20090908054656_create_delayed_jobs.rb +20 -0
- data/examples/rails_root/db/schema.rb +32 -0
- data/examples/rails_root/doc/README_FOR_APP +5 -0
- data/examples/rails_root/features/attachments.feature +27 -0
- data/examples/rails_root/features/delayed_job.feature +13 -0
- data/examples/rails_root/features/errors.feature +32 -0
- data/examples/rails_root/features/example.feature +62 -0
- data/examples/rails_root/features/step_definitions/user_steps.rb +26 -0
- data/examples/rails_root/features/step_definitions/web_steps.rb +273 -0
- data/examples/rails_root/features/support/env.rb +58 -0
- data/examples/rails_root/features/support/env_ext.rb +6 -0
- data/examples/rails_root/features/support/paths.rb +33 -0
- data/examples/rails_root/lib/tasks/cucumber.rake +47 -0
- data/examples/rails_root/public/404.html +30 -0
- data/examples/rails_root/public/422.html +30 -0
- data/examples/rails_root/public/500.html +33 -0
- data/examples/rails_root/public/dispatch.rb +10 -0
- data/examples/rails_root/public/favicon.ico +0 -0
- data/examples/rails_root/public/images/rails.png +0 -0
- data/examples/rails_root/public/javascripts/application.js +2 -0
- data/examples/rails_root/public/javascripts/controls.js +963 -0
- data/examples/rails_root/public/javascripts/dragdrop.js +973 -0
- data/examples/rails_root/public/javascripts/effects.js +1128 -0
- data/examples/rails_root/public/javascripts/prototype.js +4320 -0
- data/examples/rails_root/public/robots.txt +5 -0
- data/examples/rails_root/script/about +4 -0
- data/examples/rails_root/script/autospec +5 -0
- data/examples/rails_root/script/console +3 -0
- data/examples/rails_root/script/cucumber +10 -0
- data/examples/rails_root/script/dbconsole +3 -0
- data/examples/rails_root/script/delayed_job +5 -0
- data/examples/rails_root/script/destroy +3 -0
- data/examples/rails_root/script/generate +3 -0
- data/examples/rails_root/script/performance/benchmarker +3 -0
- data/examples/rails_root/script/performance/profiler +3 -0
- data/examples/rails_root/script/performance/request +3 -0
- data/examples/rails_root/script/plugin +3 -0
- data/examples/rails_root/script/process/inspector +3 -0
- data/examples/rails_root/script/process/reaper +3 -0
- data/examples/rails_root/script/process/spawner +3 -0
- data/examples/rails_root/script/runner +3 -0
- data/examples/rails_root/script/server +3 -0
- data/examples/rails_root/script/spec +5 -0
- data/examples/rails_root/script/spec_server +125 -0
- data/examples/rails_root/spec/controllers/welcome_controller_spec.rb +15 -0
- data/examples/rails_root/spec/model_factory.rb +6 -0
- data/examples/rails_root/spec/models/user_mailer_spec.rb +58 -0
- data/examples/rails_root/spec/models/user_spec.rb +5 -0
- data/examples/rails_root/spec/rcov.opts +2 -0
- data/examples/rails_root/spec/spec.opts +4 -0
- data/examples/rails_root/spec/spec_helper.rb +51 -0
- data/examples/sinatra/app.rb +33 -0
- data/examples/sinatra/features/errors.feature +32 -0
- data/examples/sinatra/features/example.feature +62 -0
- data/examples/sinatra/features/step_definitions/user_steps.rb +26 -0
- data/examples/sinatra/features/step_definitions/web_steps.rb +273 -0
- data/examples/sinatra/features/support/env.rb +39 -0
- data/examples/sinatra/features/support/paths.rb +24 -0
- data/install.rb +0 -0
- data/lib/email-spec.rb +1 -0
- data/lib/email_spec.rb +15 -0
- data/lib/email_spec/address_converter.rb +29 -0
- data/lib/email_spec/background_processes.rb +45 -0
- data/lib/email_spec/cucumber.rb +26 -0
- data/lib/email_spec/deliveries.rb +87 -0
- data/lib/email_spec/email_viewer.rb +87 -0
- data/lib/email_spec/helpers.rb +164 -0
- data/lib/email_spec/matchers.rb +225 -0
- data/lib/generators/email_spec/steps/USAGE +5 -0
- data/lib/generators/email_spec/steps/steps_generator.rb +14 -0
- data/lib/generators/email_spec/steps/templates/email_steps.rb +194 -0
- data/rails_generators/email_spec/email_spec_generator.rb +17 -0
- data/rails_generators/email_spec/templates/email_steps.rb +182 -0
- data/spec/email_spec/helpers_spec.rb +21 -0
- data/spec/email_spec/matchers_spec.rb +430 -0
- data/spec/spec_helper.rb +16 -0
- metadata +407 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
ENV['RSPEC'] = 'true' # allows autotest to discover rspec
|
|
3
|
+
ENV['AUTOTEST'] = 'true' # allows autotest to run w/ color on linux
|
|
4
|
+
system((RUBY_PLATFORM =~ /mswin|mingw/ ? 'autotest.bat' : 'autotest'), *ARGV) ||
|
|
5
|
+
$stderr.puts("Unable to find autotest. Please install ZenTest or fix your PATH")
|
|
@@ -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,125 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/plugins/rspec/lib' # For rspec installed as plugin
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'drb/drb'
|
|
5
|
+
require 'rbconfig'
|
|
6
|
+
require 'spec'
|
|
7
|
+
require 'optparse'
|
|
8
|
+
|
|
9
|
+
# This is based on Florian Weber's TDDMate
|
|
10
|
+
module Spec
|
|
11
|
+
module Runner
|
|
12
|
+
class RailsSpecServer
|
|
13
|
+
def run(argv, stderr, stdout)
|
|
14
|
+
$stdout = stdout
|
|
15
|
+
$stderr = stderr
|
|
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
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
ActiveRecord::Base.clear_reloadable_connections!
|
|
30
|
+
|
|
31
|
+
if ActionController.const_defined?(:Dispatcher)
|
|
32
|
+
dispatcher = ::ActionController::Dispatcher.new($stdout)
|
|
33
|
+
dispatcher.cleanup_application
|
|
34
|
+
elsif ::Dispatcher.respond_to?(:reset_application!)
|
|
35
|
+
::Dispatcher.reset_application!
|
|
36
|
+
else
|
|
37
|
+
raise "Application reloading failed"
|
|
38
|
+
end
|
|
39
|
+
if Object.const_defined?(:Fixtures) && Fixtures.respond_to?(:reset_cache)
|
|
40
|
+
Fixtures.reset_cache
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
if ::ActiveSupport.const_defined?(:Dependencies)
|
|
44
|
+
::ActiveSupport::Dependencies.mechanism = :load
|
|
45
|
+
else
|
|
46
|
+
::Dependencies.mechanism = :load
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
require_dependency('application.rb') unless Object.const_defined?(:ApplicationController)
|
|
50
|
+
load File.dirname(__FILE__) + '/../spec/spec_helper.rb'
|
|
51
|
+
|
|
52
|
+
if in_memory_database?
|
|
53
|
+
load "#{RAILS_ROOT}/db/schema.rb" # use db agnostic schema by default
|
|
54
|
+
ActiveRecord::Migrator.up('db/migrate') # use migrations
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
::Spec::Runner::CommandLine.run(
|
|
58
|
+
::Spec::Runner::OptionParser.parse(
|
|
59
|
+
argv,
|
|
60
|
+
$stderr,
|
|
61
|
+
$stdout
|
|
62
|
+
)
|
|
63
|
+
)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def in_memory_database?
|
|
67
|
+
ENV["RAILS_ENV"] == "test" and
|
|
68
|
+
::ActiveRecord::Base.connection.class.to_s == "ActiveRecord::ConnectionAdapters::SQLite3Adapter" and
|
|
69
|
+
::Rails::Configuration.new.database_configuration['test']['database'] == ':memory:'
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
puts "Loading Rails environment"
|
|
75
|
+
|
|
76
|
+
ENV["RAILS_ENV"] = "test"
|
|
77
|
+
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
|
78
|
+
require 'dispatcher'
|
|
79
|
+
|
|
80
|
+
def restart_test_server
|
|
81
|
+
puts "restarting"
|
|
82
|
+
config = ::Config::CONFIG
|
|
83
|
+
ruby = File::join(config['bindir'], config['ruby_install_name']) + config['EXEEXT']
|
|
84
|
+
command_line = [ruby, $0, ARGV].flatten.join(' ')
|
|
85
|
+
exec(command_line)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def daemonize(pid_file = nil)
|
|
89
|
+
return yield if $DEBUG
|
|
90
|
+
pid = Process.fork{
|
|
91
|
+
Process.setsid
|
|
92
|
+
Dir.chdir(RAILS_ROOT)
|
|
93
|
+
trap("SIGINT"){ exit! 0 }
|
|
94
|
+
trap("SIGTERM"){ exit! 0 }
|
|
95
|
+
trap("SIGHUP"){ restart_test_server }
|
|
96
|
+
File.open("/dev/null"){|f|
|
|
97
|
+
STDERR.reopen f
|
|
98
|
+
STDIN.reopen f
|
|
99
|
+
STDOUT.reopen f
|
|
100
|
+
}
|
|
101
|
+
yield
|
|
102
|
+
}
|
|
103
|
+
puts "spec_server launched. (PID: %d)" % pid
|
|
104
|
+
File.open(pid_file,"w"){|f| f.puts pid } if pid_file
|
|
105
|
+
exit! 0
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
options = Hash.new
|
|
109
|
+
opts = OptionParser.new
|
|
110
|
+
opts.on("-d", "--daemon"){|v| options[:daemon] = true }
|
|
111
|
+
opts.on("-p", "--pid PIDFILE"){|v| options[:pid] = v }
|
|
112
|
+
opts.parse!(ARGV)
|
|
113
|
+
|
|
114
|
+
puts "Ready"
|
|
115
|
+
exec_server = lambda {
|
|
116
|
+
trap("USR2") { restart_test_server } if Signal.list.has_key?("USR2")
|
|
117
|
+
DRb.start_service("druby://127.0.0.1:8989", Spec::Runner::RailsSpecServer.new)
|
|
118
|
+
DRb.thread.join
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if options[:daemon]
|
|
122
|
+
daemonize(options[:pid], &exec_server)
|
|
123
|
+
else
|
|
124
|
+
exec_server.call
|
|
125
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
|
|
3
|
+
describe WelcomeController do
|
|
4
|
+
|
|
5
|
+
describe "POST /signup (#signup)" do
|
|
6
|
+
it "should deliver the signup email" do
|
|
7
|
+
# expect
|
|
8
|
+
UserMailer.should_receive(:deliver_signup).with("email@example.com", "Jimmy Bean")
|
|
9
|
+
# when
|
|
10
|
+
post :signup, "Email" => "email@example.com", "Name" => "Jimmy Bean"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
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" do
|
|
8
|
+
include EmailSpec::Helpers
|
|
9
|
+
include EmailSpec::Matchers
|
|
10
|
+
include ActionController::UrlWriter
|
|
11
|
+
default_url_options = {:host => 'example.com'}
|
|
12
|
+
|
|
13
|
+
before(:all) do
|
|
14
|
+
@email = UserMailer.create_signup("jojo@yahoo.com", "Jojo Binks")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
subject { @email }
|
|
18
|
+
|
|
19
|
+
it "should be delivered to the email passed in" do
|
|
20
|
+
should deliver_to("jojo@yahoo.com")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "should contain the user's name in the mail body" do
|
|
24
|
+
@email.should have_body_text(/Jojo Binks/)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should contain a link to the confirmation page" do
|
|
28
|
+
@email.should have_body_text(/#{confirm_account_url(:host => 'example.com')}/)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it { should have_subject(/Account confirmation/) }
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# In this example group more of the documentation is placed in the context trying to allow for more concise specs.
|
|
37
|
+
describe "Signup Email" do
|
|
38
|
+
include EmailSpec::Helpers
|
|
39
|
+
include EmailSpec::Matchers
|
|
40
|
+
include ActionController::UrlWriter
|
|
41
|
+
|
|
42
|
+
before(:all) do
|
|
43
|
+
@email = UserMailer.create_signup("jojo@yahoo.com", "Jojo Binks")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
subject { @email }
|
|
47
|
+
|
|
48
|
+
it { should have_body_text(/#{confirm_account_url(:host => 'example.com')}/) }
|
|
49
|
+
it { should have_subject(/Account confirmation/) }
|
|
50
|
+
|
|
51
|
+
describe "sent with email address of 'jojo@yahoo.com', and users name 'Jojo Binks'" do
|
|
52
|
+
subject { @email }
|
|
53
|
+
it { should deliver_to("jojo@yahoo.com") }
|
|
54
|
+
it { should have_body_text(/Jojo Binks/) }
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
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.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
|
5
|
+
require 'spec'
|
|
6
|
+
require 'spec/rails'
|
|
7
|
+
|
|
8
|
+
require File.expand_path(File.dirname(__FILE__) + "/model_factory.rb")
|
|
9
|
+
require (RAILS_ROOT + '/../../lib/email_spec.rb')
|
|
10
|
+
|
|
11
|
+
Spec::Runner.configure do |config|
|
|
12
|
+
config.include(Fixjour)
|
|
13
|
+
# If you're not using ActiveRecord you should remove these
|
|
14
|
+
# lines, delete config/database.yml and disable :active_record
|
|
15
|
+
# in your config/boot.rb
|
|
16
|
+
#config.use_transactional_fixtures = true
|
|
17
|
+
#config.use_instantiated_fixtures = false
|
|
18
|
+
#config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
|
|
19
|
+
|
|
20
|
+
# == Fixtures
|
|
21
|
+
#
|
|
22
|
+
# You can declare fixtures for each example_group like this:
|
|
23
|
+
# describe "...." do
|
|
24
|
+
# fixtures :table_a, :table_b
|
|
25
|
+
#
|
|
26
|
+
# Alternatively, if you prefer to declare them only once, you can
|
|
27
|
+
# do so right here. Just uncomment the next line and replace the fixture
|
|
28
|
+
# names with your fixtures.
|
|
29
|
+
#
|
|
30
|
+
# config.global_fixtures = :table_a, :table_b
|
|
31
|
+
#
|
|
32
|
+
# If you declare global fixtures, be aware that they will be declared
|
|
33
|
+
# for all of your examples, even those that don't use them.
|
|
34
|
+
#
|
|
35
|
+
# You can also declare which fixtures to use (for example fixtures for test/fixtures):
|
|
36
|
+
#
|
|
37
|
+
# config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
|
|
38
|
+
#
|
|
39
|
+
# == Mock Framework
|
|
40
|
+
#
|
|
41
|
+
# RSpec uses it's own mocking framework by default. If you prefer to
|
|
42
|
+
# use mocha, flexmock or RR, uncomment the appropriate line:
|
|
43
|
+
#
|
|
44
|
+
# config.mock_with :mocha
|
|
45
|
+
# config.mock_with :flexmock
|
|
46
|
+
# config.mock_with :rr
|
|
47
|
+
#
|
|
48
|
+
# == Notes
|
|
49
|
+
#
|
|
50
|
+
# For more information take a look at Spec::Runner::Configuration and Spec::Runner
|
|
51
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'sinatra'
|
|
2
|
+
require 'pony'
|
|
3
|
+
|
|
4
|
+
get '/' do
|
|
5
|
+
<<-EOHTML
|
|
6
|
+
<form method="post" action="/signup">
|
|
7
|
+
<label for="Name">Name</label>
|
|
8
|
+
<input type="text" id="Name" name="user[name]">
|
|
9
|
+
<label for="Email">Email</label>
|
|
10
|
+
<input type="text" id="Email" name="user[email]">
|
|
11
|
+
<input type="submit" value="Sign up">
|
|
12
|
+
</form>
|
|
13
|
+
EOHTML
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
post '/signup' do
|
|
17
|
+
user = params[:user]
|
|
18
|
+
body = <<-EOHTML
|
|
19
|
+
Hello #{user['name']}!
|
|
20
|
+
|
|
21
|
+
<a href="http://www.example.com/confirm">Click here to confirm your account!</a>
|
|
22
|
+
EOHTML
|
|
23
|
+
Pony.mail(:from => 'admin@example.com',
|
|
24
|
+
:to => user['email'],
|
|
25
|
+
:subject => 'Account confirmation',
|
|
26
|
+
:body => body
|
|
27
|
+
)
|
|
28
|
+
'Thanks! Go check your email!'
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
get '/confirm' do
|
|
32
|
+
'Confirm your new account!'
|
|
33
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Feature: Email-spec errors example
|
|
2
|
+
In order to help alleviate email testing in apps
|
|
3
|
+
As a email-spec contributor I a newcomer
|
|
4
|
+
Should be able to easily determine where I have gone wrong
|
|
5
|
+
These scenarios should fail with helpful messages
|
|
6
|
+
|
|
7
|
+
Background:
|
|
8
|
+
Given I am on the homepage
|
|
9
|
+
And no emails have been sent
|
|
10
|
+
When I fill in "Email" with "example@example.com"
|
|
11
|
+
And I press "Sign up"
|
|
12
|
+
|
|
13
|
+
Scenario: I fail to open an email with incorrect subject
|
|
14
|
+
Then I should receive an email
|
|
15
|
+
When "example@example.com" opens the email with subject "no email"
|
|
16
|
+
|
|
17
|
+
Scenario: I fail to open an email with incorrect text
|
|
18
|
+
Then I should receive an email
|
|
19
|
+
When "example@example.com" opens the email with text "no email"
|
|
20
|
+
|
|
21
|
+
Scenario: I fail to receive an email with the expected link
|
|
22
|
+
Then I should receive an email
|
|
23
|
+
When I open the email
|
|
24
|
+
When I follow "link that doesn't exist" in the email
|
|
25
|
+
|
|
26
|
+
Scenario: I attempt to operate on an email that is not opened
|
|
27
|
+
Then I should receive an email
|
|
28
|
+
When I follow "confirm" in the email
|
|
29
|
+
|
|
30
|
+
Scenario: I attempt to check out an unopened email
|
|
31
|
+
Then I should see "confirm" in the email body
|
|
32
|
+
And I should see "Account confirmation" in the email subject
|