exception-ketchup 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/.rvmrc +1 -0
  4. data/Gemfile +21 -0
  5. data/Gemfile.lock +134 -0
  6. data/LICENSE.txt +20 -0
  7. data/README.md +102 -0
  8. data/README.rdoc +102 -0
  9. data/Rakefile +49 -0
  10. data/VERSION +1 -0
  11. data/exception-ketchup.gemspec +122 -0
  12. data/lib/exception-ketchup.rb +118 -0
  13. data/lib/rails/controller.rb +111 -0
  14. data/lib/rails/error.rb +26 -0
  15. data/lib/rails/mailer.rb +25 -0
  16. data/lib/util/handler.rb +36 -0
  17. data/spec/dummy/README.rdoc +261 -0
  18. data/spec/dummy/Rakefile +7 -0
  19. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  20. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  21. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  22. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  23. data/spec/dummy/app/mailers/.gitkeep +0 -0
  24. data/spec/dummy/app/models/.gitkeep +0 -0
  25. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  26. data/spec/dummy/app/views/notifications/exception.html.erb +6 -0
  27. data/spec/dummy/config/application.rb +65 -0
  28. data/spec/dummy/config/boot.rb +10 -0
  29. data/spec/dummy/config/environment.rb +5 -0
  30. data/spec/dummy/config/environments/development.rb +31 -0
  31. data/spec/dummy/config/environments/production.rb +64 -0
  32. data/spec/dummy/config/environments/test.rb +35 -0
  33. data/spec/dummy/config/i18n-js.yml +22 -0
  34. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  35. data/spec/dummy/config/initializers/inflections.rb +15 -0
  36. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  37. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  38. data/spec/dummy/config/initializers/session_store.rb +8 -0
  39. data/spec/dummy/config/initializers/wrap_parameters.rb +10 -0
  40. data/spec/dummy/config/locales/en.yml +5 -0
  41. data/spec/dummy/config/mongoid.yml +80 -0
  42. data/spec/dummy/config/routes.rb +2 -0
  43. data/spec/dummy/config.ru +4 -0
  44. data/spec/dummy/lib/assets/.gitkeep +0 -0
  45. data/spec/dummy/public/404.html +26 -0
  46. data/spec/dummy/public/422.html +26 -0
  47. data/spec/dummy/public/500.html +25 -0
  48. data/spec/dummy/public/favicon.ico +0 -0
  49. data/spec/dummy/script/rails +6 -0
  50. data/spec/lib/controller_spec.rb +113 -0
  51. data/spec/lib/error_spec.rb +29 -0
  52. data/spec/lib/exception-ketchup_spec.rb +44 -0
  53. data/spec/lib/mailer_spec.rb +46 -0
  54. data/spec/spec_helper.rb +30 -0
  55. metadata +284 -0
@@ -0,0 +1,64 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # Code is not reloaded between requests
5
+ config.cache_classes = true
6
+
7
+ # Full error reports are disabled and caching is turned on
8
+ config.consider_all_requests_local = false
9
+ config.action_controller.perform_caching = true
10
+
11
+ # Disable Rails's static asset server (Apache or nginx will already do this)
12
+ config.serve_static_assets = false
13
+
14
+ # Compress JavaScripts and CSS
15
+ config.assets.compress = true
16
+
17
+ # Don't fallback to assets pipeline if a precompiled asset is missed
18
+ config.assets.compile = false
19
+
20
+ # Generate digests for assets URLs
21
+ config.assets.digest = true
22
+
23
+ # Defaults to nil and saved in location specified by config.assets.prefix
24
+ # config.assets.manifest = YOUR_PATH
25
+
26
+ # Specifies the header that your server uses for sending files
27
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
28
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
29
+
30
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31
+ # config.force_ssl = true
32
+
33
+ # See everything in the log (default is :info)
34
+ # config.log_level = :debug
35
+
36
+ # Prepend all log lines with the following tags
37
+ # config.log_tags = [ :subdomain, :uuid ]
38
+
39
+ # Use a different logger for distributed setups
40
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
41
+
42
+ # Use a different cache store in production
43
+ # config.cache_store = :mem_cache_store
44
+
45
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server
46
+ # config.action_controller.asset_host = "http://assets.example.com"
47
+
48
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
49
+ # config.assets.precompile += %w( search.js )
50
+
51
+ # Disable delivery errors, bad email addresses will be ignored
52
+ # config.action_mailer.raise_delivery_errors = false
53
+
54
+ # Enable threaded mode
55
+ # config.threadsafe!
56
+
57
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
58
+ # the I18n.default_locale when a translation can not be found)
59
+ config.i18n.fallbacks = true
60
+
61
+ # Send deprecation notices to registered listeners
62
+ config.active_support.deprecation = :notify
63
+
64
+ end
@@ -0,0 +1,35 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Configure static asset server for tests with Cache-Control for performance
11
+ config.serve_static_assets = true
12
+ config.static_cache_control = "public, max-age=3600"
13
+
14
+ # Log error messages when you accidentally call methods on nil
15
+ config.whiny_nils = true
16
+
17
+ # Show full error reports and disable caching
18
+ config.consider_all_requests_local = true
19
+ config.action_controller.perform_caching = false
20
+
21
+ # Raise exceptions instead of rendering exception templates
22
+ config.action_dispatch.show_exceptions = false
23
+
24
+ # Disable request forgery protection in test environment
25
+ config.action_controller.allow_forgery_protection = false
26
+
27
+ # Tell Action Mailer not to deliver emails to the real world.
28
+ # The :test delivery method accumulates sent emails in the
29
+ # ActionMailer::Base.deliveries array.
30
+ config.action_mailer.delivery_method = :test
31
+
32
+
33
+ # Print deprecation notices to the stderr
34
+ config.active_support.deprecation = :stderr
35
+ end
@@ -0,0 +1,22 @@
1
+ # Split context in several files.
2
+ # By default only one file with all translations is exported and
3
+ # no configuration is required. Your settings for asset pipeline
4
+ # are automatically recognized.
5
+ #
6
+ # If you want to split translations into several files or specify
7
+ # locale contexts that will be exported, just use this file to do
8
+ # so.
9
+ #
10
+ # If you're going to use the Rails 3.1 asset pipeline, change
11
+ # the following configuration to something like this:
12
+ #
13
+ # translations:
14
+ # - file: "app/assets/javascripts/i18n/translations.js"
15
+ #
16
+ # If you're running an old version, you can use something
17
+ # like this:
18
+ #
19
+ # translations:
20
+ # - file: "public/javascripts/translations.js"
21
+ # only: "*"
22
+ #
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,15 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
11
+ #
12
+ # These inflection rules are supported but not enabled by default:
13
+ # ActiveSupport::Inflector.inflections do |inflect|
14
+ # inflect.acronym 'RESTful'
15
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ Dummy::Application.config.secret_token = '68faf9f19b750d5ba1172eb6ffec6fa9746e9eb64bc9a74f2aea4a49dca8fdd61fd12a31444b5e86c005814fbbaabed00fbbc558a495ca16a6f974441a63ac63'
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rails generate session_migration")
8
+ # Dummy::Application.config.session_store :active_record_store
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json]
9
+ end
10
+
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,80 @@
1
+ development:
2
+ # Configure available database sessions. (required)
3
+ sessions:
4
+ # Defines the default session. (required)
5
+ default:
6
+ # Defines the name of the default database that Mongoid can connect to.
7
+ # (required).
8
+ database: dummy_development
9
+ # Provides the hosts the default session can connect to. Must be an array
10
+ # of host:port pairs. (required)
11
+ hosts:
12
+ - localhost:27017
13
+ options:
14
+ # Change whether the session persists in safe mode by default.
15
+ # (default: false)
16
+ # safe: false
17
+
18
+ # Change the default consistency model to :eventual or :strong.
19
+ # :eventual will send reads to secondaries, :strong sends everything
20
+ # to master. (default: :eventual)
21
+ # consistency: :eventual
22
+
23
+ # How many times Moped should attempt to retry an operation after
24
+ # failure. (default: 30)
25
+ # max_retries: 30
26
+
27
+ # The time in seconds that Moped should wait before retrying an
28
+ # operation on failure. (default: 1)
29
+ # retry_interval: 1
30
+ # Configure Mongoid specific options. (optional)
31
+ options:
32
+ # Configuration for whether or not to allow access to fields that do
33
+ # not have a field definition on the model. (default: true)
34
+ # allow_dynamic_fields: true
35
+
36
+ # Enable the identity map, needed for eager loading. (default: false)
37
+ # identity_map_enabled: false
38
+
39
+ # Includes the root model name in json serialization. (default: false)
40
+ # include_root_in_json: false
41
+
42
+ # Include the _type field in serializaion. (default: false)
43
+ # include_type_for_serialization: false
44
+
45
+ # Preload all models in development, needed when models use
46
+ # inheritance. (default: false)
47
+ # preload_models: false
48
+
49
+ # Protect id and type from mass assignment. (default: true)
50
+ # protect_sensitive_fields: true
51
+
52
+ # Raise an error when performing a #find and the document is not found.
53
+ # (default: true)
54
+ # raise_not_found_error: true
55
+
56
+ # Raise an error when defining a scope with the same name as an
57
+ # existing method. (default: false)
58
+ # scope_overwrite_exception: false
59
+
60
+ # Skip the database version check, used when connecting to a db without
61
+ # admin access. (default: false)
62
+ # skip_version_check: false
63
+
64
+ # User Active Support's time zone in conversions. (default: true)
65
+ # use_activesupport_time_zone: true
66
+
67
+ # Ensure all times are UTC in the app side. (default: false)
68
+ # use_utc: false
69
+ test:
70
+ sessions:
71
+ default:
72
+ database: dummy_test
73
+ hosts:
74
+ - localhost:27017
75
+ options:
76
+ consistency: :strong
77
+ # In the test environment we lower the retries and retry interval to
78
+ # low amounts for fast failures.
79
+ max_retries: 1
80
+ retry_interval: 0
@@ -0,0 +1,2 @@
1
+ Rails.application.routes.draw do
2
+ end
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Dummy::Application
File without changes
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,113 @@
1
+ require 'spec_helper'
2
+
3
+ FakeTestController = Class.new(ApplicationController) do
4
+
5
+ respond_to :json
6
+
7
+ ketchup_exceptions do |c|
8
+ c.rescue_errors = [
9
+ { :error => Mongoid::Errors::DocumentNotFound, :with => :document_not_found } ,
10
+ { :error => ArgumentError, :with => :document_not_found}
11
+ ]
12
+ end
13
+
14
+ def operation_failed(error)
15
+ respond_with({:error => "Operation could not be operated."})
16
+ end
17
+
18
+ def document_not_found(error)
19
+ respond_with({:error => "Operation could not be operated."})
20
+ end
21
+
22
+ def respond_with_error(error)
23
+ document_not_found(error)
24
+ end
25
+
26
+ def show
27
+ @author = Author.find(params[:id])
28
+ respond_with @author
29
+ end
30
+
31
+ end
32
+
33
+ describe "exception handling within controller", :type => :controller do
34
+ let(:recipients){ %W(ds@test.com da@test.com) }
35
+
36
+ before do
37
+ Ketchup::Exception.setup do |config|
38
+ config.subject = "Test Error"
39
+ config.recipients = recipients
40
+ config.sender = "foo@example.com"
41
+ config.template_path = "notifications"
42
+ config.environment = :test
43
+ end
44
+
45
+ Author = Class.new do
46
+ include Mongoid::Document
47
+
48
+ store_in :authors
49
+ end
50
+
51
+ end
52
+
53
+ describe FakeTestController do
54
+
55
+ before do
56
+ @controller = FakeTestController.new
57
+ end
58
+
59
+ it "handles with custom method" do
60
+ Author.should_receive(:find).and_raise(Mongoid::Errors::DocumentNotFound)
61
+ expect do
62
+ get :show, :id => "50e3f7e6f1a8f299cb000001" , :format => "json"
63
+ end.to change(ActionMailer::Base.deliveries, :size).by(1)
64
+ result = ActiveSupport::JSON.decode(response.body)
65
+ result.should have_key("error")
66
+ end
67
+
68
+ context "mailing is disabled" do
69
+ before do
70
+ Ketchup::Exception.setup do |config|
71
+ config.subject = "Test Error"
72
+ config.recipients = recipients
73
+ config.sender = "foo@example.com"
74
+ config.template_path = "notifications"
75
+ config.deliver_mail = false
76
+ config.environment = :test
77
+ end
78
+
79
+ end
80
+
81
+ it "did not send mails" do
82
+ Author.should_receive(:find).any_number_of_times.and_raise(Mongoid::Errors::DocumentNotFound)
83
+ expect do
84
+ get :show, :id => "50e3f7e6f1a8f299cb000001" , :format => "json"
85
+ end.to_not change(ActionMailer::Base.deliveries, :size).by(1)
86
+ expect do
87
+ get :show, :id => "50e3f7e6f1a8f299cb000001" , :format => "json"
88
+ end.to change(Ketchup::Exception::Error, :count).by(1)
89
+ end
90
+ end
91
+
92
+ context "persist to database if disabled" do
93
+
94
+ before do
95
+ Ketchup::Exception.setup do |config|
96
+ config.subject = "Test Error"
97
+ config.recipients = recipients
98
+ config.sender = "foo@example.com"
99
+ config.template_path = "notifications"
100
+ config.persist = false
101
+ config.environment = :test
102
+ end
103
+ end
104
+
105
+ it "did not save to db" do
106
+ Author.should_receive(:find).any_number_of_times.and_raise(Mongoid::Errors::DocumentNotFound)
107
+ expect do
108
+ get :show, :id => "50e3f7e6f1a8f299cb000001" , :format => "json"
109
+ end.to_not change(Ketchup::Exception::Error, :count).by(1)
110
+ end
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ketchup::Exception::Error do
4
+
5
+ it{should respond_to(:kind)}
6
+ it{should respond_to(:backtrace)}
7
+ it{should respond_to(:happend_at)}
8
+ it{should respond_to(:message)}
9
+
10
+ context "#kind" do
11
+
12
+ let(:exception){ StandardError.new("something happened") }
13
+ let(:error){ Ketchup::Exception::Error.new }
14
+
15
+ before do
16
+ error.kind = exception.class.name
17
+ error.backtrace = exception.backtrace
18
+ error.message = exception.message
19
+ error.happend_at = Time.now
20
+ error.save
21
+ end
22
+
23
+ subject{Ketchup::Exception::Error.last}
24
+
25
+ its(:kind){should eq "StandardError"}
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ketchup::Exception do
4
+
5
+ it { should respond_to(:setup) }
6
+ it { should respond_to(:environment) }
7
+ it { should respond_to(:subject) }
8
+ it { should respond_to(:template_path) }
9
+ it { should respond_to(:deliver_mail) }
10
+ it { should respond_to(:persist) }
11
+ it { should respond_to(:recipients) }
12
+ it { should respond_to(:template_path) }
13
+ it { should respond_to(:template_path) }
14
+ it { should respond_to(:exception_collection) }
15
+
16
+ context "default configuration" do
17
+
18
+ context "for environment" do
19
+
20
+ it "is production" do
21
+ subject.environment.should eq :production
22
+ end
23
+
24
+ end
25
+
26
+ context "for mailing" do
27
+
28
+ it "is enabled" do
29
+ subject.deliver_mail.should be true
30
+ end
31
+
32
+ end
33
+
34
+ context "to store errors" do
35
+
36
+ it "is errors collection" do
37
+ subject.exception_collection.should == :errors
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -0,0 +1,46 @@
1
+ require "spec_helper"
2
+
3
+ describe Ketchup::Exception::Mailer do
4
+ let(:recipients){ %W(ds@test.com da@test.com) }
5
+
6
+ before do
7
+ Ketchup::Exception.setup do |config|
8
+ config.subject = "Test Error"
9
+ config.recipients = recipients
10
+ config.sender = "foo@example.com"
11
+ config.template_path = "notifications"
12
+ end
13
+ end
14
+
15
+ describe 'notifications' do
16
+ let(:error) do
17
+ double("error", :message => "Tiny test error",
18
+ :backtrace => ["error at line 10", "wrong arguments: 1 for 0"])
19
+
20
+ end
21
+ let(:host){ "http://example.com"}
22
+ let(:mail){ Ketchup::Exception::Mailer.notification_email(error,host) }
23
+
24
+ it "renders the subject" do
25
+ mail.subject.should eq "Test Error"
26
+ end
27
+
28
+ it "renders the receiver mail" do
29
+ mail.to.should == recipients
30
+ end
31
+
32
+ it "renders the senders email" do
33
+ mail.from.should == [Ketchup::Exception.sender]
34
+ end
35
+
36
+ it "assigns @message" do
37
+ mail.body.encoded.should match(error.message)
38
+ end
39
+
40
+ it "assigns @host" do
41
+ mail.body.encoded.should match(host)
42
+ end
43
+
44
+ end
45
+
46
+ end
@@ -0,0 +1,30 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+
4
+ # Configure Rails Envinronment
5
+ ENV["RAILS_ENV"] = "test"
6
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
7
+
8
+ require 'rspec/rails'
9
+ require 'mongoid-rspec'
10
+ require 'database_cleaner'
11
+
12
+ ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
13
+
14
+ # Requires supporting ruby files with custom matchers and macros, etc,
15
+ # in spec/support/ and its subdirectories.
16
+ Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
17
+
18
+ RSpec.configure do |config|
19
+
20
+ config.before(:suite) do
21
+ DatabaseCleaner.strategy = :truncation
22
+ DatabaseCleaner.orm = "mongoid"
23
+ end
24
+
25
+ config.before do
26
+ #Mongoid.load!("#{ENGINE_RAILS_ROOT}/config/mongoid.yml", :test)
27
+ DatabaseCleaner.clean
28
+ end
29
+
30
+ end