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.
Files changed (180) hide show
  1. data/History.txt +199 -0
  2. data/MIT-LICENSE.txt +19 -0
  3. data/README.rdoc +137 -0
  4. data/Rakefile +64 -0
  5. data/examples/rails3_root/Gemfile +24 -0
  6. data/examples/rails3_root/README +5 -0
  7. data/examples/rails3_root/Rakefile +11 -0
  8. data/examples/rails3_root/app/controllers/application_controller.rb +3 -0
  9. data/examples/rails3_root/app/controllers/welcome_controller.rb +16 -0
  10. data/examples/rails3_root/app/helpers/application_helper.rb +2 -0
  11. data/examples/rails3_root/app/mailers/user_mailer.rb +39 -0
  12. data/examples/rails3_root/app/models/user.rb +2 -0
  13. data/examples/rails3_root/app/views/user_mailer/attachments.html.erb +6 -0
  14. data/examples/rails3_root/app/views/user_mailer/newsletter.html.erb +8 -0
  15. data/examples/rails3_root/app/views/user_mailer/signup.html.erb +3 -0
  16. data/examples/rails3_root/app/views/welcome/attachments.html.erb +0 -0
  17. data/examples/rails3_root/app/views/welcome/confirm.html.erb +1 -0
  18. data/examples/rails3_root/app/views/welcome/index.html.erb +8 -0
  19. data/examples/rails3_root/app/views/welcome/newsletter.html.erb +0 -0
  20. data/examples/rails3_root/app/views/welcome/signup.html.erb +1 -0
  21. data/examples/rails3_root/attachments/document.pdf +0 -0
  22. data/examples/rails3_root/attachments/image.png +0 -0
  23. data/examples/rails3_root/config.ru +4 -0
  24. data/examples/rails3_root/config/application.rb +43 -0
  25. data/examples/rails3_root/config/boot.rb +14 -0
  26. data/examples/rails3_root/config/cucumber.yml +7 -0
  27. data/examples/rails3_root/config/database.yml +25 -0
  28. data/examples/rails3_root/config/environment.rb +6 -0
  29. data/examples/rails3_root/config/environments/development.rb +19 -0
  30. data/examples/rails3_root/config/environments/production.rb +42 -0
  31. data/examples/rails3_root/config/environments/test.rb +29 -0
  32. data/examples/rails3_root/config/initializers/backtrace_silencers.rb +7 -0
  33. data/examples/rails3_root/config/initializers/cookie_verification_secret.rb +7 -0
  34. data/examples/rails3_root/config/initializers/inflections.rb +10 -0
  35. data/examples/rails3_root/config/initializers/mime_types.rb +5 -0
  36. data/examples/rails3_root/config/initializers/rspec_generator.rb +6 -0
  37. data/examples/rails3_root/config/initializers/session_store.rb +10 -0
  38. data/examples/rails3_root/config/locales/en.yml +5 -0
  39. data/examples/rails3_root/config/routes.rb +7 -0
  40. data/examples/rails3_root/db/migrate/20090125013728_create_users.rb +11 -0
  41. data/examples/rails3_root/db/migrate/20090908054656_create_delayed_jobs.rb +20 -0
  42. data/examples/rails3_root/db/schema.rb +32 -0
  43. data/examples/rails3_root/db/seeds.rb +7 -0
  44. data/examples/rails3_root/doc/README_FOR_APP +2 -0
  45. data/examples/rails3_root/features/attachments.feature +27 -0
  46. data/examples/rails3_root/features/delayed_job.feature +13 -0
  47. data/examples/rails3_root/features/errors.feature +32 -0
  48. data/examples/rails3_root/features/example.feature +62 -0
  49. data/examples/rails3_root/features/step_definitions/user_steps.rb +26 -0
  50. data/examples/rails3_root/features/step_definitions/web_steps.rb +202 -0
  51. data/examples/rails3_root/features/support/env.rb +59 -0
  52. data/examples/rails3_root/features/support/env_ext.rb +2 -0
  53. data/examples/rails3_root/features/support/paths.rb +33 -0
  54. data/examples/rails3_root/lib/tasks/cucumber.rake +47 -0
  55. data/examples/rails3_root/lib/tasks/rspec.rake +69 -0
  56. data/examples/rails3_root/public/404.html +26 -0
  57. data/examples/rails3_root/public/422.html +26 -0
  58. data/examples/rails3_root/public/500.html +26 -0
  59. data/examples/rails3_root/public/favicon.ico +0 -0
  60. data/examples/rails3_root/public/images/rails.png +0 -0
  61. data/examples/rails3_root/public/javascripts/application.js +2 -0
  62. data/examples/rails3_root/public/javascripts/controls.js +965 -0
  63. data/examples/rails3_root/public/javascripts/dragdrop.js +974 -0
  64. data/examples/rails3_root/public/javascripts/effects.js +1123 -0
  65. data/examples/rails3_root/public/javascripts/prototype.js +4874 -0
  66. data/examples/rails3_root/public/javascripts/rails.js +109 -0
  67. data/examples/rails3_root/public/robots.txt +5 -0
  68. data/examples/rails3_root/script/cucumber +10 -0
  69. data/examples/rails3_root/script/rails +9 -0
  70. data/examples/rails3_root/spec/controllers/welcome_controller_spec.rb +18 -0
  71. data/examples/rails3_root/spec/models/user_mailer_spec.rb +47 -0
  72. data/examples/rails3_root/spec/spec.opts +2 -0
  73. data/examples/rails3_root/spec/spec_helper.rb +19 -0
  74. data/examples/rails_root/Rakefile +13 -0
  75. data/examples/rails_root/app/controllers/application_controller.rb +15 -0
  76. data/examples/rails_root/app/controllers/welcome_controller.rb +16 -0
  77. data/examples/rails_root/app/helpers/application_helper.rb +3 -0
  78. data/examples/rails_root/app/helpers/welcome_helper.rb +2 -0
  79. data/examples/rails_root/app/models/user.rb +2 -0
  80. data/examples/rails_root/app/models/user_mailer.rb +39 -0
  81. data/examples/rails_root/app/views/user_mailer/attachments.erb +6 -0
  82. data/examples/rails_root/app/views/user_mailer/newsletter.erb +8 -0
  83. data/examples/rails_root/app/views/user_mailer/signup.erb +3 -0
  84. data/examples/rails_root/app/views/welcome/attachments.html.erb +0 -0
  85. data/examples/rails_root/app/views/welcome/confirm.html.erb +1 -0
  86. data/examples/rails_root/app/views/welcome/index.html.erb +8 -0
  87. data/examples/rails_root/app/views/welcome/newsletter.html.erb +0 -0
  88. data/examples/rails_root/app/views/welcome/signup.html.erb +1 -0
  89. data/examples/rails_root/attachments/document.pdf +0 -0
  90. data/examples/rails_root/attachments/image.png +0 -0
  91. data/examples/rails_root/config/boot.rb +110 -0
  92. data/examples/rails_root/config/cucumber.yml +7 -0
  93. data/examples/rails_root/config/database.yml +25 -0
  94. data/examples/rails_root/config/environment.rb +28 -0
  95. data/examples/rails_root/config/environments/cucumber.rb +29 -0
  96. data/examples/rails_root/config/environments/development.rb +17 -0
  97. data/examples/rails_root/config/environments/production.rb +28 -0
  98. data/examples/rails_root/config/environments/test.rb +28 -0
  99. data/examples/rails_root/config/initializers/inflections.rb +10 -0
  100. data/examples/rails_root/config/initializers/mime_types.rb +5 -0
  101. data/examples/rails_root/config/initializers/new_rails_defaults.rb +17 -0
  102. data/examples/rails_root/config/routes.rb +45 -0
  103. data/examples/rails_root/db/migrate/20090125013728_create_users.rb +11 -0
  104. data/examples/rails_root/db/migrate/20090908054656_create_delayed_jobs.rb +20 -0
  105. data/examples/rails_root/db/schema.rb +32 -0
  106. data/examples/rails_root/doc/README_FOR_APP +5 -0
  107. data/examples/rails_root/features/attachments.feature +27 -0
  108. data/examples/rails_root/features/delayed_job.feature +13 -0
  109. data/examples/rails_root/features/errors.feature +32 -0
  110. data/examples/rails_root/features/example.feature +62 -0
  111. data/examples/rails_root/features/step_definitions/user_steps.rb +26 -0
  112. data/examples/rails_root/features/step_definitions/web_steps.rb +273 -0
  113. data/examples/rails_root/features/support/env.rb +58 -0
  114. data/examples/rails_root/features/support/env_ext.rb +6 -0
  115. data/examples/rails_root/features/support/paths.rb +33 -0
  116. data/examples/rails_root/lib/tasks/cucumber.rake +47 -0
  117. data/examples/rails_root/public/404.html +30 -0
  118. data/examples/rails_root/public/422.html +30 -0
  119. data/examples/rails_root/public/500.html +33 -0
  120. data/examples/rails_root/public/dispatch.rb +10 -0
  121. data/examples/rails_root/public/favicon.ico +0 -0
  122. data/examples/rails_root/public/images/rails.png +0 -0
  123. data/examples/rails_root/public/javascripts/application.js +2 -0
  124. data/examples/rails_root/public/javascripts/controls.js +963 -0
  125. data/examples/rails_root/public/javascripts/dragdrop.js +973 -0
  126. data/examples/rails_root/public/javascripts/effects.js +1128 -0
  127. data/examples/rails_root/public/javascripts/prototype.js +4320 -0
  128. data/examples/rails_root/public/robots.txt +5 -0
  129. data/examples/rails_root/script/about +4 -0
  130. data/examples/rails_root/script/autospec +5 -0
  131. data/examples/rails_root/script/console +3 -0
  132. data/examples/rails_root/script/cucumber +10 -0
  133. data/examples/rails_root/script/dbconsole +3 -0
  134. data/examples/rails_root/script/delayed_job +5 -0
  135. data/examples/rails_root/script/destroy +3 -0
  136. data/examples/rails_root/script/generate +3 -0
  137. data/examples/rails_root/script/performance/benchmarker +3 -0
  138. data/examples/rails_root/script/performance/profiler +3 -0
  139. data/examples/rails_root/script/performance/request +3 -0
  140. data/examples/rails_root/script/plugin +3 -0
  141. data/examples/rails_root/script/process/inspector +3 -0
  142. data/examples/rails_root/script/process/reaper +3 -0
  143. data/examples/rails_root/script/process/spawner +3 -0
  144. data/examples/rails_root/script/runner +3 -0
  145. data/examples/rails_root/script/server +3 -0
  146. data/examples/rails_root/script/spec +5 -0
  147. data/examples/rails_root/script/spec_server +125 -0
  148. data/examples/rails_root/spec/controllers/welcome_controller_spec.rb +15 -0
  149. data/examples/rails_root/spec/model_factory.rb +6 -0
  150. data/examples/rails_root/spec/models/user_mailer_spec.rb +58 -0
  151. data/examples/rails_root/spec/models/user_spec.rb +5 -0
  152. data/examples/rails_root/spec/rcov.opts +2 -0
  153. data/examples/rails_root/spec/spec.opts +4 -0
  154. data/examples/rails_root/spec/spec_helper.rb +51 -0
  155. data/examples/sinatra/app.rb +33 -0
  156. data/examples/sinatra/features/errors.feature +32 -0
  157. data/examples/sinatra/features/example.feature +62 -0
  158. data/examples/sinatra/features/step_definitions/user_steps.rb +26 -0
  159. data/examples/sinatra/features/step_definitions/web_steps.rb +273 -0
  160. data/examples/sinatra/features/support/env.rb +39 -0
  161. data/examples/sinatra/features/support/paths.rb +24 -0
  162. data/install.rb +0 -0
  163. data/lib/email-spec.rb +1 -0
  164. data/lib/email_spec.rb +15 -0
  165. data/lib/email_spec/address_converter.rb +29 -0
  166. data/lib/email_spec/background_processes.rb +45 -0
  167. data/lib/email_spec/cucumber.rb +26 -0
  168. data/lib/email_spec/deliveries.rb +87 -0
  169. data/lib/email_spec/email_viewer.rb +87 -0
  170. data/lib/email_spec/helpers.rb +164 -0
  171. data/lib/email_spec/matchers.rb +225 -0
  172. data/lib/generators/email_spec/steps/USAGE +5 -0
  173. data/lib/generators/email_spec/steps/steps_generator.rb +14 -0
  174. data/lib/generators/email_spec/steps/templates/email_steps.rb +194 -0
  175. data/rails_generators/email_spec/email_spec_generator.rb +17 -0
  176. data/rails_generators/email_spec/templates/email_steps.rb +182 -0
  177. data/spec/email_spec/helpers_spec.rb +21 -0
  178. data/spec/email_spec/matchers_spec.rb +430 -0
  179. data/spec/spec_helper.rb +16 -0
  180. metadata +407 -0
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-Agent: *
5
+ # Disallow: /
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
4
+ require 'commands/about'
@@ -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,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/console'
@@ -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,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/dbconsole'
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
4
+ require 'delayed/command'
5
+ Delayed::Command.new(ARGV).daemonize
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/destroy'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/generate'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../config/boot'
3
+ require 'commands/performance/benchmarker'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../config/boot'
3
+ require 'commands/performance/profiler'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../config/boot'
3
+ require 'commands/performance/request'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/plugin'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../config/boot'
3
+ require 'commands/process/inspector'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../config/boot'
3
+ require 'commands/process/reaper'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../config/boot'
3
+ require 'commands/process/spawner'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/runner'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/server'
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../vendor/plugins/rspec/lib"))
3
+ require 'rubygems'
4
+ require 'spec'
5
+ exit ::Spec::Runner::CommandLine.run(::Spec::Runner::OptionParser.parse(ARGV, STDERR, STDOUT))
@@ -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,6 @@
1
+ require 'fixjour'
2
+
3
+ Fixjour do
4
+ define_builder(User, :name => "Jojo Binks", :email => "jojo@thebinks.com")
5
+ end
6
+
@@ -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,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe User do
4
+
5
+ end
@@ -0,0 +1,2 @@
1
+ --exclude "spec/*,gems/*"
2
+ --rails
@@ -0,0 +1,4 @@
1
+ --colour
2
+ --format s
3
+ --loadby mtime
4
+ --reverse
@@ -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