defra_ruby_email 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +8 -0
  3. data/README.md +66 -0
  4. data/Rakefile +38 -0
  5. data/app/assets/images/defra_ruby_email/govuk_logotype_email.png +0 -0
  6. data/app/controllers/defra_ruby_email/application_controller.rb +7 -0
  7. data/app/controllers/defra_ruby_email/last_email_controller.rb +9 -0
  8. data/app/mailers/defra_ruby_email/test_mailer.rb +60 -0
  9. data/config/routes.rb +8 -0
  10. data/lib/defra_ruby_email.rb +26 -0
  11. data/lib/defra_ruby_email/configuration.rb +24 -0
  12. data/lib/defra_ruby_email/engine.rb +15 -0
  13. data/lib/defra_ruby_email/last_email_cache.rb +48 -0
  14. data/lib/defra_ruby_email/last_email_observer.rb +13 -0
  15. data/lib/defra_ruby_email/version.rb +5 -0
  16. data/lib/tasks/changelog.rake +8 -0
  17. data/lib/tasks/defra_ruby_email_tasks.rake +8 -0
  18. data/spec/defra_ruby_email_spec.rb +39 -0
  19. data/spec/dummy/README.rdoc +28 -0
  20. data/spec/dummy/Rakefile +6 -0
  21. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  22. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  23. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  24. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  25. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  26. data/spec/dummy/bin/bundle +3 -0
  27. data/spec/dummy/bin/rails +4 -0
  28. data/spec/dummy/bin/rake +4 -0
  29. data/spec/dummy/bin/setup +29 -0
  30. data/spec/dummy/config.ru +4 -0
  31. data/spec/dummy/config/application.rb +29 -0
  32. data/spec/dummy/config/boot.rb +5 -0
  33. data/spec/dummy/config/environment.rb +5 -0
  34. data/spec/dummy/config/environments/development.rb +38 -0
  35. data/spec/dummy/config/environments/production.rb +76 -0
  36. data/spec/dummy/config/environments/test.rb +42 -0
  37. data/spec/dummy/config/initializers/assets.rb +11 -0
  38. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  39. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  40. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  41. data/spec/dummy/config/initializers/inflections.rb +16 -0
  42. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  43. data/spec/dummy/config/initializers/session_store.rb +3 -0
  44. data/spec/dummy/config/initializers/to_time_preserves_timezone.rb +10 -0
  45. data/spec/dummy/config/initializers/wrap_parameters.rb +9 -0
  46. data/spec/dummy/config/locales/en.yml +23 -0
  47. data/spec/dummy/config/routes.rb +4 -0
  48. data/spec/dummy/config/secrets.yml +22 -0
  49. data/spec/dummy/log/test.log +53 -0
  50. data/spec/dummy/public/404.html +67 -0
  51. data/spec/dummy/public/422.html +67 -0
  52. data/spec/dummy/public/500.html +66 -0
  53. data/spec/dummy/public/favicon.ico +0 -0
  54. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/1W/1WwQOSlYPtmYMlk5m-3Qq4NzEWNH7tYCQhfoslnaLHk.cache +1 -0
  55. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/2-/2-japRDu0GHGko1cjVWjELVh5v9nz6Q45a2beIwLUrI.cache +0 -0
  56. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/4G/4Gbu6LmPYLfAZQgL2uv1eZwq7EYA0POiSWs6C_vXckg.cache +2 -0
  57. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/5L/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +2 -0
  58. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/AU/AUfMxF1097iBMMdRbzJKjyzoRLp1W-b_VuQ4p0OxWfw.cache +0 -0
  59. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/B5/B5OLh2y7CLTgfdROC0dphxzI0KC-NWuzUoZ5fHcA6Bg.cache +0 -0
  60. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/L4/L46n6ueXJJsYfqBb0tgyq4pu-Pmwghcq4wxrrvue0iI.cache +0 -0
  61. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/MG/MGzsWSZq4b8vtnPxO8zkfdIwLVmVdcXFO1l9ao9g8D8.cache +0 -0
  62. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/OI/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +2 -0
  63. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Ps/PsDzIFzt3gBnxeXvfMfYXZ2E6DyEFleyRRfR01u34_8.cache +1 -0
  64. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/SN/SN9Q1o1Je1stqGQtozCzZyPlhu1QW0gOSDpTQHrdE40.cache +2 -0
  65. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/SW/SW2WGzrHD6rQ7Iifad3AJjwO-H5MMdk-KgDcDAo2L3w.cache +1 -0
  66. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Tz/TzV-x09rf8_JdpcH7oq7Tx0hTs-7K6EpBgN2cGzTBCw.cache +1 -0
  67. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Uz/Uzp0b_uvqxkh0hY1pfL1MUpkNlf4zy_eYSBnRQQFiC0.cache +1 -0
  68. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/_D/_DYI9CGjZuQS99rHeuP1Zczax1DlXobV7fQAOlFZbW0.cache +1 -0
  69. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/_M/_MsZgIvurUGOXpB0mEZtVC6mrSMcnyTk7p_1psw3G-g.cache +0 -0
  70. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/aj/ajHL7E3SCz-eQbwNQMePJRLVz6OQHk7Xtuvu4SWLiYY.cache +1 -0
  71. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/dC/dCKQMRMWehNHUz2uovXPnFyx0OyNUCVPhPvG9tPe0TM.cache +1 -0
  72. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ex/exO17VY09nxxoT76j7M9SboKOezGF_Wx0vTvGHl-vuU.cache +1 -0
  73. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/fN/fNIVnfQsXHwqWvodZxIU869b9k7z9k8O8Z5I7waSgbo.cache +2 -0
  74. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/gF/gFPphmPziPhcj5awJ-qSf7kvvYQE-mR6fJoj5Plw17I.cache +2 -0
  75. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/gm/gm8TWq2tpBcsn1xscp-vNMVweRDHm10LXftKrZ3WL3E.cache +0 -0
  76. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/hZ/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +2 -0
  77. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/iG/iGr34Svi4uZyFOneReXcDJZvZTJyBzaiZFOm5EcSefM.cache +1 -0
  78. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/pE/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +2 -0
  79. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/pP/pPe-s4lIFwyYOpBJcOCFWCqVHJzKmr-bXTMajg0vA0U.cache +0 -0
  80. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/q3/q3Z4d58Hu6dSbyJh-BeC0P0-vMjbI8cfMsHN73-B3gs.cache +1 -0
  81. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/qo/qoLNp_jcpq5z2b5ijaCSHBZO7m6FKQHFrXVGHZ9ZoZ8.cache +1 -0
  82. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/s4/s4_2m7OtzbFTNr3n5Zn_xY2uGLRIzpG24UgWUwG3yKA.cache +0 -0
  83. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/sQ/sQNMSYgTkDcfTlnbqMpLd6Erufaoxo61qkVPy4YgY3A.cache +1 -0
  84. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/y9/y9pXiDOCIiEqKn-ES0eCNUjJ7cSQFn31eombd1vJzj4.cache +1 -0
  85. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/z9/z9x_Zb62GyFCL1ZoYErl-HHrPL6AqOOgaLaDlJ9KaEo.cache +0 -0
  86. data/spec/examples.txt +8 -0
  87. data/spec/lib/last_email_cache_spec.rb +221 -0
  88. data/spec/rails_helper.rb +46 -0
  89. data/spec/requests/last_email_spec.rb +34 -0
  90. data/spec/spec_helper.rb +83 -0
  91. data/spec/support/helpers/configuration.rb +16 -0
  92. data/spec/support/pry.rb +7 -0
  93. data/spec/support/simplecov.rb +17 -0
  94. metadata +297 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 60ee4255b7585ffeb1bf0627b25297617890bc0a
4
+ data.tar.gz: 979836d5d4392fc967b698a97a83290f69681662
5
+ SHA512:
6
+ metadata.gz: 48f158c118f2c523ede07ac3e6182cf4871cedb45461ec63bc8e72794712b029cc92cad20650e6aea80ba67af23c031517bebbf2e37186668d0e74f00b0084fa
7
+ data.tar.gz: 4030b982847e303196cdea3e55df38ae57843d54ac7e78c8968c83f4f76a5577f2069540e20f797a7a97ae205476e39655a5cc172a5c294f94f49b0b9e05c1ce
data/LICENSE ADDED
@@ -0,0 +1,8 @@
1
+ The Open Government Licence (OGL) Version 3
2
+
3
+ Copyright (c) 2020 Defra
4
+
5
+ This source code is licensed under the Open Government Licence v3.0. To view this
6
+ licence, visit www.nationalarchives.gov.uk/doc/open-government-licence/version/3
7
+ or write to the Information Policy Team, The National Archives, Kew, Richmond,
8
+ Surrey, TW9 4DU.
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # Defra Ruby Email
2
+
3
+ [![Build Status](https://travis-ci.com/DEFRA/defra-ruby-email.svg?branch=master)](https://travis-ci.com/DEFRA/defra-ruby-email)
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/0eb068e0b0ec99debf88/maintainability)](https://codeclimate.com/github/DEFRA/defra-ruby-email/maintainability)
5
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/0eb068e0b0ec99debf88/test_coverage)](https://codeclimate.com/github/DEFRA/defra-ruby-email/test_coverage)
6
+ [![security](https://hakiri.io/github/DEFRA/defra-ruby-email/master.svg)](https://hakiri.io/github/DEFRA/defra-ruby-email/master)
7
+ [![Licence](https://img.shields.io/badge/Licence-OGLv3-blue.svg)](http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3)
8
+
9
+ > Work in progress. This project is not yet complete!
10
+
11
+ A Rails Engine used by the [Ruby services team](https://github.com/DEFRA/ruby-services-team) in their digital services.
12
+
13
+ We use it to allow us to access the content of the last email sent by an app. This information is used by our [acceptance tests](https://github.com/DEFRA/waste-carriers-acceptance-tests) to confirm emails are being sent with the expected content.
14
+
15
+ When mounted in an app, it will add a new route which when called, will return details of the last email as JSON.
16
+
17
+ ## Prerequisites
18
+
19
+ Make sure you already have:
20
+
21
+ - Ruby 2.4.2
22
+ - [Bundler](http://bundler.io/) – for installing Ruby gems
23
+
24
+ ## Installation
25
+
26
+ You don't need to do this if you're just mounting the engine without making any changes.
27
+
28
+ However, if you want to edit the engine, you'll have to install it locally.
29
+
30
+ Clone the repo and drop into the project:
31
+
32
+ ```bash
33
+ git clone https://github.com/DEFRA/defra-ruby-email.git && cd defra-ruby-email
34
+ ```
35
+
36
+ Then install the dependencies with `bundle install`.
37
+
38
+ ## Testing the engine
39
+
40
+ The engine is mounted in a dummy Rails 4 app (in /spec/dummy) so we can properly test its behaviour.
41
+
42
+ The test suite is written in RSpec.
43
+
44
+ To run all the tests, use `bundle exec rspec`.
45
+
46
+ ## Contributing to this project
47
+
48
+ If you have an idea you'd like to contribute please log an issue.
49
+
50
+ All contributions should be submitted via a pull request.
51
+
52
+ ## License
53
+
54
+ THIS INFORMATION IS LICENSED UNDER THE CONDITIONS OF THE OPEN GOVERNMENT LICENCE found at:
55
+
56
+ <http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3>
57
+
58
+ The following attribution statement MUST be cited in your products and applications when using this information.
59
+
60
+ > Contains public sector information licensed under the Open Government license v3
61
+
62
+ ### About the license
63
+
64
+ The Open Government Licence (OGL) was developed by the Controller of Her Majesty's Stationery Office (HMSO) to enable information providers in the public sector to license the use and re-use of their information under a common open licence.
65
+
66
+ It is designed to encourage use and re-use of information freely and flexibly, with only a few conditions.
data/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require "bundler/setup"
5
+ rescue LoadError
6
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
7
+ end
8
+
9
+ require "rdoc/task"
10
+
11
+ RDoc::Task.new(:rdoc) do |rdoc|
12
+ rdoc.rdoc_dir = "rdoc"
13
+ rdoc.title = "DefraRubyEmail"
14
+ rdoc.options << "--line-numbers"
15
+ rdoc.rdoc_files.include("README.md")
16
+ rdoc.rdoc_files.include("lib/**/*.rb")
17
+ end
18
+
19
+ load "rails/tasks/statistics.rake"
20
+
21
+ Dir[File.join(File.dirname(__FILE__), "lib/tasks/**/*.rake")].each { |f| load f }
22
+
23
+ Bundler::GemHelper.install_tasks
24
+
25
+ # This is wrapped to prevent an error when rake is called in environments where
26
+ # rspec may not be available, e.g. production. As such we don't need to handle
27
+ # the error.
28
+ # rubocop:disable Lint/SuppressedException
29
+ begin
30
+ require "rspec/core/rake_task"
31
+
32
+ RSpec::Core::RakeTask.new(:spec)
33
+
34
+ task default: :spec
35
+ rescue LoadError
36
+ # no rspec available
37
+ end
38
+ # rubocop:enable Lint/SuppressedException
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DefraRubyEmail
4
+ class ApplicationController < ActionController::Base
5
+ protect_from_forgery with: :exception
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DefraRubyEmail
4
+ class LastEmailController < ApplicationController
5
+ def show
6
+ render json: LastEmailCache.instance.last_email_json
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DefraRubyEmail
4
+ class TestMailer < ActionMailer::Base
5
+
6
+ FROM_ADDRESS = "defra-ruby-email@example.com"
7
+
8
+ def multipart_email(recipient, add_logo = false)
9
+ add_logo_attachment if add_logo
10
+
11
+ mail(
12
+ to: recipient,
13
+ from: FROM_ADDRESS,
14
+ subject: "Multi-part email"
15
+ ) do |format|
16
+ format.html { render html: "<h1>This is the html version of an email</h1>".html_safe }
17
+ format.text { render plain: "This is the text version of an email" }
18
+ end
19
+ end
20
+
21
+ def html_email(recipient, add_logo = false)
22
+ add_logo_attachment if add_logo
23
+
24
+ mail(
25
+ to: recipient,
26
+ from: FROM_ADDRESS,
27
+ subject: "HTML email"
28
+ ) do |format|
29
+ format.html { render html: "<h1>This is the html version of an email</h1>".html_safe }
30
+ end
31
+ end
32
+
33
+ def text_email(recipient, add_logo = false)
34
+ add_logo_attachment if add_logo
35
+
36
+ mail(
37
+ to: recipient,
38
+ from: FROM_ADDRESS,
39
+ subject: "Text email"
40
+ ) do |format|
41
+ format.text { render plain: "This is the text version of an email" }
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ def add_logo_attachment
48
+ path = "/app/assets/images/defra_ruby_email/govuk_logotype_email.png"
49
+
50
+ full_path = File.join(Rails.root, path)
51
+
52
+ full_path = "#{Gem.loaded_specs['defra_ruby_email'].full_gem_path}#{path}" unless File.exist?(full_path)
53
+
54
+ attachments["govuk_logotype_email.png"] = {
55
+ data: File.read(full_path),
56
+ mime_type: "image/png"
57
+ }
58
+ end
59
+ end
60
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ DefraRubyEmail::Engine.routes.draw do
4
+ get "/last-email",
5
+ to: "last_email#show",
6
+ as: "last_email",
7
+ constraints: ->(_request) { DefraRubyEmail.configuration.enabled? }
8
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "defra_ruby_email/engine"
4
+
5
+ module DefraRubyEmail
6
+ # Enable the ability to configure the gem from its host app, rather than
7
+ # reading directly from env vars. Derived from
8
+ # https://robots.thoughtbot.com/mygem-configure-block
9
+ class << self
10
+ attr_writer :configuration
11
+
12
+ def configuration
13
+ @configuration ||= Configuration.new
14
+ end
15
+
16
+ # Added for testing. Without we cannot test both a config object with and
17
+ # with set values in the same rspec session
18
+ def reset_configuration
19
+ @configuration = nil
20
+ end
21
+ end
22
+
23
+ def self.configure
24
+ yield(configuration)
25
+ end
26
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DefraRubyEmail
4
+ class Configuration
5
+
6
+ def initialize
7
+ @enable = false
8
+ end
9
+
10
+ # Controls whether the mocks are enabled. Only if set to true will the mock
11
+ # pages be accessible
12
+ def enable=(arg)
13
+ # We implement our own setter to handle values being passed in as strings
14
+ # rather than booleans
15
+ parsed = arg.to_s.downcase
16
+
17
+ @enable = parsed == "true"
18
+ end
19
+
20
+ def enabled?
21
+ @enable
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "configuration"
4
+ require_relative "last_email_cache"
5
+ require_relative "last_email_observer"
6
+
7
+ module DefraRubyEmail
8
+ class Engine < ::Rails::Engine
9
+ isolate_namespace DefraRubyEmail
10
+
11
+ config.generators do |g|
12
+ g.test_framework :rspec
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DefraRubyEmail
4
+ class LastEmailCache
5
+ include Singleton
6
+
7
+ EMAIL_ATTRIBUTES = %i[date from to bcc cc reply_to subject].freeze
8
+
9
+ attr_accessor :last_email
10
+
11
+ # This is necessary to properly test the service functionality
12
+ def reset
13
+ @last_email = nil
14
+ end
15
+
16
+ def last_email_json
17
+ return JSON.generate(error: "No emails sent.") unless last_email.present?
18
+
19
+ message_hash = {}
20
+ EMAIL_ATTRIBUTES.each do |attribute|
21
+ message_hash[attribute] = last_email.public_send(attribute)
22
+ end
23
+ message_hash[:body] = email_body
24
+ message_hash[:attachments] = last_email.attachments.map(&:filename)
25
+
26
+ JSON.generate(last_email: message_hash)
27
+ end
28
+
29
+ # If you've set multipart emails then you'll have both a text and a html
30
+ # version (determined by adding the relevant erb views). If you do so then
31
+ # `my_mail.parts.length` will at least equal 2. If you only have one of them
32
+ # e.g. just a text version then parts doesn't get populated.
33
+ #
34
+ # However any attachments will cause ActionMailer to use parts. So for example
35
+ # if we have a text only email with an attached image, then parts will be of
36
+ # length 2; one being the content and the other being the attachment.
37
+ #
38
+ # To cater for all possibilities we have this method to grab the body content
39
+ # https://guides.rubyonrails.org/action_mailer_basics.html#sending-multipart-emails
40
+ # https://stackoverflow.com/a/15818886
41
+ def email_body
42
+ part_to_use = last_email.text_part || last_email.html_part || last_email
43
+
44
+ # return the message body without the header information
45
+ part_to_use.body.decoded
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DefraRubyEmail
4
+ class LastEmailObserver
5
+
6
+ def self.delivered_email(message)
7
+ LastEmailCache.instance.last_email = message
8
+ end
9
+
10
+ end
11
+ end
12
+
13
+ ActionMailer::Base.register_observer(DefraRubyEmail::LastEmailObserver)
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DefraRubyEmail
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "github_changelog_generator/task"
4
+
5
+ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
6
+ config.user = "DEFRA"
7
+ config.project = "defra-ruby-email"
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # namespace :defra_ruby_email do
4
+ # desc "Explaining what the task does"
5
+ # task :test do
6
+ # # Task goes here
7
+ # end
8
+ # end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails_helper"
4
+
5
+ RSpec.describe DefraRubyEmail do
6
+ describe "VERSION" do
7
+ it "is a version string in the correct format" do
8
+ expect(DefraRubyEmail::VERSION).to be_a(String)
9
+ expect(DefraRubyEmail::VERSION).to match(/\d+\.\d+\.\d+/)
10
+ end
11
+ end
12
+
13
+ describe "#configuration" do
14
+ before(:each) { Helpers::Configuration.reset_for_tests }
15
+
16
+ context "when the host app has not provided configuration" do
17
+ let(:enabled) { false }
18
+
19
+ it "returns a DefraRubyEmail::Configuration instance with default values" do
20
+ expect(described_class.configuration).to be_an_instance_of(DefraRubyEmail::Configuration)
21
+
22
+ expect(described_class.configuration.enabled?).to eq(enabled)
23
+ end
24
+ end
25
+
26
+ context "when the host app has provided configuration" do
27
+ let(:enabled) { true }
28
+
29
+ it "returns a DefraRubyEmail::Configuration instance with matching values" do
30
+ described_class.configure do |config|
31
+ config.enable = enabled
32
+ end
33
+
34
+ expect(described_class.configuration).to be_an_instance_of(DefraRubyEmail::Configuration)
35
+ expect(described_class.configuration.enabled?).to eq(enabled)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.