rapid-app 0.1
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/.gitignore +6 -0
- data/.rspec +2 -0
- data/Gemfile +11 -0
- data/Rakefile +4 -0
- data/lib/rapid/app/settings.rb +259 -0
- data/lib/rapid/app/skeleton.rb +213 -0
- data/lib/rapid/app/version.rb +5 -0
- data/lib/rapid/app.rb +13 -0
- data/lib/rapid-app.rb +5 -0
- data/rapid-app.gemspec +33 -0
- data/spec/rapid/app/skeleton_spec.rb +50 -0
- data/spec/rapid/app_spec.rb +12 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/support/more_string_matchers.rb +21 -0
- data/spec/support/rapid.rb +1 -0
- data/spec/templates/app/controllers/application_controller_spec.rb +32 -0
- data/spec/templates/app/helpers/application_helper_spec.rb +32 -0
- data/spec/templates/app/mailers/test_mailer_spec.rb +22 -0
- data/spec/templates/app/views/test_mailer/test_email.text.erb_spec.rb +36 -0
- data/spec/templates/config/application_spec.rb +168 -0
- data/spec/templates/config/boot_spec.rb +17 -0
- data/spec/templates/config/cucumber.yml_spec.rb +22 -0
- data/spec/templates/config/deploy/production_spec.rb +155 -0
- data/spec/templates/config/deploy_spec.rb +156 -0
- data/spec/templates/config/environment_spec.rb +22 -0
- data/spec/templates/config/environments/development_spec.rb +50 -0
- data/spec/templates/config/environments/production_spec.rb +50 -0
- data/spec/templates/config/environments/test_spec.rb +50 -0
- data/spec/templates/config/initializers/airbrake_spec.rb +70 -0
- data/spec/templates/config/initializers/backtrace_silencers_spec.rb +17 -0
- data/spec/templates/config/initializers/email_spec.rb +106 -0
- data/spec/templates/config/initializers/mime_types_spec.rb +17 -0
- data/spec/templates/config/initializers/secret_token_spec.rb +36 -0
- data/spec/templates/config/initializers/session_store_spec.rb +36 -0
- data/spec/templates/config/initializers/wrap_parameters_spec.rb +17 -0
- data/spec/templates/config/roodi.yml_spec.rb +92 -0
- data/spec/templates/config/routes_spec.rb +36 -0
- data/spec/templates/config/schedule_spec.rb +22 -0
- data/spec/templates/config.ru_spec.rb +22 -0
- data/spec/templates/db/migrate/create_jobs_spec.rb +17 -0
- data/spec/templates/features/step_definitions/email_steps_spec.rb +17 -0
- data/spec/templates/features/step_definitions/web_steps/browsing_steps_spec.rb +17 -0
- data/spec/templates/features/step_definitions/web_steps/debug_steps_spec.rb +17 -0
- data/spec/templates/features/step_definitions/web_steps/form_steps_spec.rb +17 -0
- data/spec/templates/features/step_definitions/web_steps/step_scoper_spec.rb +17 -0
- data/spec/templates/features/support/email_spec.rb +17 -0
- data/spec/templates/features/support/env_spec.rb +56 -0
- data/spec/templates/features/support/paths_spec.rb +22 -0
- data/spec/templates/features/support/selectors_spec.rb +22 -0
- data/spec/templates/features/support/with_scope_spec.rb +17 -0
- data/spec/templates/lib/tasks/cucumber.rake_spec.rb +17 -0
- data/spec/templates/lib/tasks/test.rake_spec.rb +147 -0
- data/spec/templates/lib/tasks/test_mailer.rake_spec.rb +17 -0
- data/spec/templates/rspec_spec.rb +17 -0
- data/spec/templates/script/delayed_job_spec.rb +17 -0
- data/spec/templates/script/rails_spec.rb +17 -0
- data/spec/templates/spec/factories_spec.rb +27 -0
- data/spec/templates/spec/spec_helper_spec.rb +56 -0
- data/spec/templates/test/test_helper_spec.rb +17 -0
- data/templates/app/controllers/application_controller.rb +3 -0
- data/templates/app/helpers/application_helper.rb +2 -0
- data/templates/app/mailers/test_mailer.rb +7 -0
- data/templates/app/views/test_mailer/test_email.text.erb +4 -0
- data/templates/config/application.rb +32 -0
- data/templates/config/boot.rb +6 -0
- data/templates/config/cucumber.yml +8 -0
- data/templates/config/deploy/production.rb +37 -0
- data/templates/config/deploy.rb +43 -0
- data/templates/config/environment.rb +5 -0
- data/templates/config/environments/development.rb +35 -0
- data/templates/config/environments/production.rb +64 -0
- data/templates/config/environments/test.rb +46 -0
- data/templates/config/initializers/airbrake.rb +9 -0
- data/templates/config/initializers/backtrace_silencers.rb +7 -0
- data/templates/config/initializers/email.rb +10 -0
- data/templates/config/initializers/mime_types.rb +5 -0
- data/templates/config/initializers/secret_token.rb +7 -0
- data/templates/config/initializers/session_store.rb +8 -0
- data/templates/config/initializers/wrap_parameters.rb +14 -0
- data/templates/config/roodi.yml +13 -0
- data/templates/config/routes.rb +3 -0
- data/templates/config/schedule.rb +1 -0
- data/templates/config.ru +4 -0
- data/templates/db/migrate/create_jobs.rb +22 -0
- data/templates/features/step_definitions/email_steps.rb +194 -0
- data/templates/features/step_definitions/web_steps/browsing_steps.rb +82 -0
- data/templates/features/step_definitions/web_steps/debug_steps.rb +3 -0
- data/templates/features/step_definitions/web_steps/form_steps.rb +210 -0
- data/templates/features/step_definitions/web_steps/step_scoper.rb +9 -0
- data/templates/features/support/email.rb +2 -0
- data/templates/features/support/env.rb +55 -0
- data/templates/features/support/paths.rb +27 -0
- data/templates/features/support/selectors.rb +24 -0
- data/templates/features/support/with_scope.rb +6 -0
- data/templates/lib/tasks/cucumber.rake +65 -0
- data/templates/lib/tasks/test.rake +49 -0
- data/templates/lib/tasks/test_mailer.rake +10 -0
- data/templates/rspec +2 -0
- data/templates/script/delayed_job +5 -0
- data/templates/script/rails +6 -0
- data/templates/spec/factories.rb +1 -0
- data/templates/spec/spec_helper.rb +47 -0
- data/templates/test/test_helper.rb +13 -0
- metadata +316 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require 'capistrano/ext/multistage'
|
|
2
|
+
require "bundler/capistrano"
|
|
3
|
+
|
|
4
|
+
<% if deploy.rvm? %>
|
|
5
|
+
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
|
|
6
|
+
require "rvm/capistrano"
|
|
7
|
+
|
|
8
|
+
<% end %>
|
|
9
|
+
<% if scheduler? %>
|
|
10
|
+
require "whenever/capistrano"
|
|
11
|
+
|
|
12
|
+
<% end %>
|
|
13
|
+
set :stages, <%= deploy.stages %>
|
|
14
|
+
set :default_stage, "production"
|
|
15
|
+
set :use_sudo, false
|
|
16
|
+
|
|
17
|
+
set :application, "<%= name %>"
|
|
18
|
+
set :repository, "<%= deploy.repository.url %>"
|
|
19
|
+
|
|
20
|
+
set :scm, :git
|
|
21
|
+
set :scm_verbose, true
|
|
22
|
+
set :deploy_via, :remote_cache
|
|
23
|
+
set :copy_exclude, [".git/"]
|
|
24
|
+
|
|
25
|
+
set :rake, "bundle exec rake"
|
|
26
|
+
|
|
27
|
+
after "deploy:update_code", "deploy:cleanup"
|
|
28
|
+
<% if deploy.symlink? %>
|
|
29
|
+
after "bundle:install", "deploy:symlink_shared"
|
|
30
|
+
|
|
31
|
+
namespace :deploy do
|
|
32
|
+
|
|
33
|
+
task :symlink_shared, :roles => :app do
|
|
34
|
+
<% if database.active_record? %>
|
|
35
|
+
run "ln -s #{shared_path}/database.yml #{release_path}/config/database.yml"
|
|
36
|
+
<% end %>
|
|
37
|
+
<% if upload.private? %>
|
|
38
|
+
run "ln -s #{shared_path}/private #{release_path}/private"
|
|
39
|
+
<% end %>
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
<% end %>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<%= module_name %>::Application.configure do
|
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
|
3
|
+
|
|
4
|
+
# In the development environment your application's code is reloaded on
|
|
5
|
+
# every request. This slows down response time but is perfect for development
|
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
|
7
|
+
config.cache_classes = false
|
|
8
|
+
|
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
|
10
|
+
config.whiny_nils = true
|
|
11
|
+
|
|
12
|
+
# Show full error reports and disable caching
|
|
13
|
+
config.consider_all_requests_local = true
|
|
14
|
+
config.action_controller.perform_caching = false
|
|
15
|
+
|
|
16
|
+
# Don't care if the mailer can't send
|
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
|
18
|
+
config.action_mailer.delivery_method = :test
|
|
19
|
+
|
|
20
|
+
# Print deprecation notices to the Rails logger
|
|
21
|
+
config.active_support.deprecation = :log
|
|
22
|
+
|
|
23
|
+
# Only use best-standards-support built into browsers
|
|
24
|
+
config.action_dispatch.best_standards_support = :builtin
|
|
25
|
+
|
|
26
|
+
# Do not compress assets
|
|
27
|
+
config.assets.compress = false
|
|
28
|
+
|
|
29
|
+
# Expands the lines which load the assets
|
|
30
|
+
config.assets.debug = true
|
|
31
|
+
<% if development.domain? %>
|
|
32
|
+
|
|
33
|
+
config.action_mailer.default_url_options = { :host => "<%= development.domain %>"<% if development.port? %>, :port => <%= development.port %><% end %> }
|
|
34
|
+
<% end %>
|
|
35
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<%= module_name %>::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 Rails.root.join("public/assets")
|
|
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
|
+
# Use a different logger for distributed setups
|
|
37
|
+
# config.logger = SyslogLogger.new
|
|
38
|
+
|
|
39
|
+
# Use a different cache store in production
|
|
40
|
+
# config.cache_store = :mem_cache_store
|
|
41
|
+
|
|
42
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
|
43
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
|
44
|
+
|
|
45
|
+
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
|
46
|
+
# config.assets.precompile += %w( search.js )
|
|
47
|
+
|
|
48
|
+
# Disable delivery errors, bad email addresses will be ignored
|
|
49
|
+
# config.action_mailer.raise_delivery_errors = false
|
|
50
|
+
|
|
51
|
+
# Enable threaded mode
|
|
52
|
+
# config.threadsafe!
|
|
53
|
+
|
|
54
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
|
55
|
+
# the I18n.default_locale when a translation can not be found)
|
|
56
|
+
config.i18n.fallbacks = true
|
|
57
|
+
|
|
58
|
+
# Send deprecation notices to registered listeners
|
|
59
|
+
config.active_support.deprecation = :notify
|
|
60
|
+
<% if production.domain? %>
|
|
61
|
+
|
|
62
|
+
config.action_mailer.default_url_options = { :host => "<%= production.domain %>"<% if production.port? %>, :port => <%= production.port %><% end %> }
|
|
63
|
+
<% end %>
|
|
64
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<%= module_name %>::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
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
|
33
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
|
34
|
+
# like if you have constraints or database-specific column types
|
|
35
|
+
# config.active_record.schema_format = :sql
|
|
36
|
+
|
|
37
|
+
# Print deprecation notices to the stderr
|
|
38
|
+
config.active_support.deprecation = :stderr
|
|
39
|
+
|
|
40
|
+
# Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets
|
|
41
|
+
config.assets.allow_debugging = true
|
|
42
|
+
<% if test.domain? %>
|
|
43
|
+
|
|
44
|
+
config.action_mailer.default_url_options = { :host => "<%= test.domain %>"<% if test.port? %>, :port => <%= test.port %><% end %> }
|
|
45
|
+
<% end %>
|
|
46
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Airbrake.configure do |config|
|
|
2
|
+
config.api_key = "<%= exceptions.airbrake.api_key %>"
|
|
3
|
+
<% if exceptions.airbrake.host? %>
|
|
4
|
+
config.host = "<%= exceptions.airbrake.host %>"
|
|
5
|
+
<% end %>
|
|
6
|
+
<% if exceptions.airbrake.secure == false %>
|
|
7
|
+
config.secure = false
|
|
8
|
+
<% end %>
|
|
9
|
+
end
|
|
@@ -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,10 @@
|
|
|
1
|
+
ActionMailer::Base.smtp_settings = {
|
|
2
|
+
:address => "<%= email.smtp.address %>",
|
|
3
|
+
:port => <%= email.smtp.port %>,
|
|
4
|
+
:authentication => :<%= email.smtp.authentication %>,
|
|
5
|
+
:enable_starttls_auto => <%= email.smtp.tls %>,
|
|
6
|
+
|
|
7
|
+
:domain => "<%= email.smtp.domain %>",
|
|
8
|
+
:user_name => "<%= email.smtp.username %>",
|
|
9
|
+
:password => "<%= email.smtp.password %>"
|
|
10
|
+
}
|
|
@@ -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
|
+
<%= module_name %>::Application.config.secret_token = '<%= secret_token %>'
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
<%= module_name %>::Application.config.session_store :cookie_store, :key => '<%= session_cookie_name %>'
|
|
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
|
+
# <%= module_name %>::Application.config.session_store :active_record_store
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
|
|
11
|
+
# Disable root element in JSON by default.
|
|
12
|
+
ActiveSupport.on_load(:active_record) do
|
|
13
|
+
self.include_root_in_json = false
|
|
14
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
AssignmentInConditionalCheck: { }
|
|
2
|
+
CaseMissingElseCheck: { }
|
|
3
|
+
ClassLineCountCheck: { line_count: <%= test.roodi.klass.lines.max %> }
|
|
4
|
+
ClassNameCheck: { pattern: !ruby/regexp /^[A-Z][a-zA-Z0-9]*$/ }
|
|
5
|
+
CyclomaticComplexityBlockCheck: { complexity: <%= test.roodi.block.complexity %> }
|
|
6
|
+
CyclomaticComplexityMethodCheck: { complexity: <%= test.roodi.method.complexity %> }
|
|
7
|
+
EmptyRescueBodyCheck: { }
|
|
8
|
+
ForLoopCheck: { }
|
|
9
|
+
MethodLineCountCheck: { line_count: <%= test.roodi.method.lines.max %> }
|
|
10
|
+
MethodNameCheck: { pattern: !ruby/regexp /^[_a-z<>=\[\]|+-\/\*`]+[_a-z0-9_<>=~@\[\]]*[=!\?]?$/ }
|
|
11
|
+
ModuleLineCountCheck: { line_count: <%= test.roodi.module.lines.max %> }
|
|
12
|
+
ModuleNameCheck: { pattern: !ruby/regexp /^[A-Z][a-zA-Z0-9]*$/ }
|
|
13
|
+
ParameterNumberCheck: { parameter_count: <%= test.roodi.parameters.max %> }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= scheduler.body %>
|
data/templates/config.ru
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class CreateDelayedJobs < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :delayed_jobs, :force => true do |table|
|
|
4
|
+
table.integer :priority, :default => 0 # Allows some jobs to jump to the front of the queue
|
|
5
|
+
table.integer :attempts, :default => 0 # Provides for retries, but still fail eventually.
|
|
6
|
+
table.text :handler # YAML-encoded string of the object that will do work
|
|
7
|
+
table.text :last_error # reason for last failure (See Note below)
|
|
8
|
+
table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
|
|
9
|
+
table.datetime :locked_at # Set when a client is working on this object
|
|
10
|
+
table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
|
|
11
|
+
table.string :locked_by # Who is working on this object (if locked)
|
|
12
|
+
table.string :queue # The name of the queue this job is in
|
|
13
|
+
table.timestamps
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
add_index :delayed_jobs, [:priority, :run_at], :name => 'delayed_jobs_priority'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.down
|
|
20
|
+
drop_table :delayed_jobs
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# Commonly used email steps
|
|
2
|
+
#
|
|
3
|
+
# To add your own steps make a custom_email_steps.rb
|
|
4
|
+
# The provided methods are:
|
|
5
|
+
#
|
|
6
|
+
# last_email_address
|
|
7
|
+
# reset_mailer
|
|
8
|
+
# open_last_email
|
|
9
|
+
# visit_in_email
|
|
10
|
+
# unread_emails_for
|
|
11
|
+
# mailbox_for
|
|
12
|
+
# current_email
|
|
13
|
+
# open_email
|
|
14
|
+
# read_emails_for
|
|
15
|
+
# find_email
|
|
16
|
+
#
|
|
17
|
+
# General form for email scenarios are:
|
|
18
|
+
# - clear the email queue (done automatically by email_spec)
|
|
19
|
+
# - execute steps that sends an email
|
|
20
|
+
# - check the user received an/no/[0-9] emails
|
|
21
|
+
# - open the email
|
|
22
|
+
# - inspect the email contents
|
|
23
|
+
# - interact with the email (e.g. click links)
|
|
24
|
+
#
|
|
25
|
+
# The Cucumber steps below are setup in this order.
|
|
26
|
+
|
|
27
|
+
module EmailHelpers
|
|
28
|
+
def current_email_address
|
|
29
|
+
# Replace with your a way to find your current email. e.g @current_user.email
|
|
30
|
+
# last_email_address will return the last email address used by email spec to find an email.
|
|
31
|
+
# Note that last_email_address will be reset after each Scenario.
|
|
32
|
+
last_email_address || "example@example.com"
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
World(EmailHelpers)
|
|
37
|
+
|
|
38
|
+
#
|
|
39
|
+
# Reset the e-mail queue within a scenario.
|
|
40
|
+
# This is done automatically before each scenario.
|
|
41
|
+
#
|
|
42
|
+
|
|
43
|
+
Given /^(?:a clear email queue|no emails have been sent)$/ do
|
|
44
|
+
reset_mailer
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
#
|
|
48
|
+
# Check how many emails have been sent/received
|
|
49
|
+
#
|
|
50
|
+
|
|
51
|
+
Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails?$/ do |address, amount|
|
|
52
|
+
unread_emails_for(address).size.should == parse_email_count(amount)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
Then /^(?:I|they|"([^"]*?)") should have (an|no|\d+) emails?$/ do |address, amount|
|
|
56
|
+
mailbox_for(address).size.should == parse_email_count(amount)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails? with subject "([^"]*?)"$/ do |address, amount, subject|
|
|
60
|
+
unread_emails_for(address).select { |m| m.subject =~ Regexp.new(subject) }.size.should == parse_email_count(amount)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
Then /^(?:I|they|"([^"]*?)") should receive an email with the following body:$/ do |address, expected_body|
|
|
64
|
+
open_email(address, :with_text => expected_body)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
#
|
|
68
|
+
# Accessing emails
|
|
69
|
+
#
|
|
70
|
+
|
|
71
|
+
# Opens the most recently received email
|
|
72
|
+
When /^(?:I|they|"([^"]*?)") opens? the email$/ do |address|
|
|
73
|
+
open_email(address)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
When /^(?:I|they|"([^"]*?)") opens? the email with subject "([^"]*?)"$/ do |address, subject|
|
|
77
|
+
open_email(address, :with_subject => subject)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
When /^(?:I|they|"([^"]*?)") opens? the email with text "([^"]*?)"$/ do |address, text|
|
|
81
|
+
open_email(address, :with_text => text)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
#
|
|
85
|
+
# Inspect the Email Contents
|
|
86
|
+
#
|
|
87
|
+
|
|
88
|
+
Then /^(?:I|they) should see "([^"]*?)" in the email subject$/ do |text|
|
|
89
|
+
current_email.should have_subject(text)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
Then /^(?:I|they) should see \/([^"]*?)\/ in the email subject$/ do |text|
|
|
93
|
+
current_email.should have_subject(Regexp.new(text))
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
Then /^(?:I|they) should see "([^"]*?)" in the email body$/ do |text|
|
|
97
|
+
current_email.default_part_body.to_s.should include(text)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
Then /^(?:I|they) should see \/([^"]*?)\/ in the email body$/ do |text|
|
|
101
|
+
current_email.default_part_body.to_s.should =~ Regexp.new(text)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
Then /^(?:I|they) should see the email delivered from "([^"]*?)"$/ do |text|
|
|
105
|
+
current_email.from.should include(text)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
Then /^(?:I|they) should see "([^\"]*)" in the email "([^"]*?)" header$/ do |text, name|
|
|
109
|
+
current_email.should have_header(name, text)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
Then /^(?:I|they) should see \/([^\"]*)\/ in the email "([^"]*?)" header$/ do |text, name|
|
|
113
|
+
current_email.should have_header(name, Regexp.new(text))
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
Then /^I should see it is a multi\-part email$/ do
|
|
117
|
+
current_email.should be_multipart
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
Then /^(?:I|they) should see "([^"]*?)" in the email html part body$/ do |text|
|
|
121
|
+
current_email.html_part.body.to_s.should include(text)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
Then /^(?:I|they) should see "([^"]*?)" in the email text part body$/ do |text|
|
|
125
|
+
current_email.text_part.body.to_s.should include(text)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
#
|
|
129
|
+
# Inspect the Email Attachments
|
|
130
|
+
#
|
|
131
|
+
|
|
132
|
+
Then /^(?:I|they) should see (an|no|\d+) attachments? with the email$/ do |amount|
|
|
133
|
+
current_email_attachments.size.should == parse_email_count(amount)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
Then /^there should be (an|no|\d+) attachments? named "([^"]*?)"$/ do |amount, filename|
|
|
137
|
+
current_email_attachments.select { |a| a.filename == filename }.size.should == parse_email_count(amount)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
Then /^attachment (\d+) should be named "([^"]*?)"$/ do |index, filename|
|
|
141
|
+
current_email_attachments[(index.to_i - 1)].filename.should == filename
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
Then /^there should be (an|no|\d+) attachments? of type "([^"]*?)"$/ do |amount, content_type|
|
|
145
|
+
current_email_attachments.select { |a| a.content_type.include?(content_type) }.size.should == parse_email_count(amount)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
Then /^attachment (\d+) should be of type "([^"]*?)"$/ do |index, content_type|
|
|
149
|
+
current_email_attachments[(index.to_i - 1)].content_type.should include(content_type)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
Then /^all attachments should not be blank$/ do
|
|
153
|
+
current_email_attachments.each do |attachment|
|
|
154
|
+
attachment.read.size.should_not == 0
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
Then /^show me a list of email attachments$/ do
|
|
159
|
+
EmailSpec::EmailViewer::save_and_open_email_attachments_list(current_email)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
#
|
|
163
|
+
# Interact with Email Contents
|
|
164
|
+
#
|
|
165
|
+
|
|
166
|
+
When /^(?:I|they) follow "([^"]*?)" in the email$/ do |link|
|
|
167
|
+
visit_in_email(link)
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
When /^(?:I|they) click the first link in the email$/ do
|
|
171
|
+
click_first_link_in_email
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
#
|
|
175
|
+
# Debugging
|
|
176
|
+
# These only work with Rails and OSx ATM since EmailViewer uses RAILS_ROOT and OSx's 'open' command.
|
|
177
|
+
# Patches accepted. ;)
|
|
178
|
+
#
|
|
179
|
+
|
|
180
|
+
Then /^save and open current email$/ do
|
|
181
|
+
EmailSpec::EmailViewer::save_and_open_email(current_email)
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
Then /^save and open all text emails$/ do
|
|
185
|
+
EmailSpec::EmailViewer::save_and_open_all_text_emails
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
Then /^save and open all html emails$/ do
|
|
189
|
+
EmailSpec::EmailViewer::save_and_open_all_html_emails
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
Then /^save and open all raw emails$/ do
|
|
193
|
+
EmailSpec::EmailViewer::save_and_open_all_raw_emails
|
|
194
|
+
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Given /^(?:|I )am on (.+)$/ do |page_name|
|
|
2
|
+
visit path_to(page_name)
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
When /^(?:|I )go to (.+)$/ do |page_name|
|
|
6
|
+
visit path_to(page_name)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
When /^(?:|I )follow "([^"]*)"$/ do |link|
|
|
10
|
+
click_link(link)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
Then /^I should be redirected to (.+)$/ do |page|
|
|
14
|
+
puts 'TODO: make this done'
|
|
15
|
+
Then "I should be on #{page}"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
Then /^(?:|I )should see "([^"]*)"$/ do |text|
|
|
19
|
+
if page.respond_to? :should
|
|
20
|
+
page.should have_content(text)
|
|
21
|
+
else
|
|
22
|
+
assert page.has_content?(text)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
Then /^(?:|I )should not see "([^"]*)"$/ do |text|
|
|
27
|
+
if page.respond_to? :should
|
|
28
|
+
page.should have_no_content(text)
|
|
29
|
+
else
|
|
30
|
+
assert page.has_no_content?(text)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
Then /^(?:|I )should see \/([^\/]*)\/([imxo])?$/ do |regexp,flags|
|
|
35
|
+
regexp_opts = [regexp,flags].compact
|
|
36
|
+
regexp = Regexp.new(*regexp_opts)
|
|
37
|
+
|
|
38
|
+
if page.respond_to? :should
|
|
39
|
+
page.should have_xpath('//*', :text => regexp)
|
|
40
|
+
else
|
|
41
|
+
assert page.has_xpath?('//*', :text => regexp)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
Then /^(?:|I )should not see \/([^\/]*)\/([imxo])?$/ do |regexp,flags|
|
|
46
|
+
regexp_opts = [regexp,flags].compact
|
|
47
|
+
regexp = Regexp.new(*regexp_opts)
|
|
48
|
+
|
|
49
|
+
if page.respond_to? :should
|
|
50
|
+
page.should have_no_xpath('//*', :text => regexp)
|
|
51
|
+
else
|
|
52
|
+
assert page.has_no_xpath?('//*', :text => regexp)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
|
57
|
+
current_path = URI.parse(current_url).path
|
|
58
|
+
if current_path.respond_to? :should
|
|
59
|
+
current_path.should == path_to(page_name)
|
|
60
|
+
else
|
|
61
|
+
assert_equal path_to(page_name), current_path
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
Then /^I should see (\d+) elements? kind of (.+)$/ do |count, locator|
|
|
66
|
+
actual_count = all(selector_for(locator)).count
|
|
67
|
+
count = count.to_i
|
|
68
|
+
|
|
69
|
+
if actual_count.respond_to?(:should)
|
|
70
|
+
actual_count.should eq(count)
|
|
71
|
+
else
|
|
72
|
+
assert_equal count, actual_count
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
Then /^I should not see elements? kind of (.+)$/ do |locator|
|
|
77
|
+
if defined?(RSpec)
|
|
78
|
+
page.should_not have_css(selector_for(locator))
|
|
79
|
+
else
|
|
80
|
+
assert page.has_no_css?(selector_for(locator))
|
|
81
|
+
end
|
|
82
|
+
end
|