roadie-rails 1.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.travis.yml +15 -0
- data/Changelog.md +9 -0
- data/Gemfile +17 -0
- data/Guardfile +16 -0
- data/LICENSE.txt +22 -0
- data/README.md +317 -0
- data/Rakefile +14 -0
- data/Upgrading.md +70 -0
- data/lib/roadie-rails.rb +1 -0
- data/lib/roadie/rails.rb +21 -0
- data/lib/roadie/rails/asset_pipeline_provider.rb +24 -0
- data/lib/roadie/rails/automatic.rb +16 -0
- data/lib/roadie/rails/document_builder.rb +18 -0
- data/lib/roadie/rails/inline_on_delivery.rb +17 -0
- data/lib/roadie/rails/mail_inliner.rb +26 -0
- data/lib/roadie/rails/mailer.rb +14 -0
- data/lib/roadie/rails/options.rb +101 -0
- data/lib/roadie/rails/railtie.rb +22 -0
- data/lib/roadie/rails/version.rb +5 -0
- data/roadie-rails.gemspec +29 -0
- data/setup.sh +62 -0
- data/spec/integration_spec.rb +119 -0
- data/spec/lib/roadie/rails/asset_pipeline_provider_spec.rb +47 -0
- data/spec/lib/roadie/rails/automatic_spec.rb +44 -0
- data/spec/lib/roadie/rails/document_builder_spec.rb +20 -0
- data/spec/lib/roadie/rails/mail_inliner_spec.rb +57 -0
- data/spec/lib/roadie/rails/mailer_spec.rb +57 -0
- data/spec/lib/roadie/rails/options_spec.rb +136 -0
- data/spec/lib/roadie/rails/railtie_spec.rb +48 -0
- data/spec/railsapps/README.md +69 -0
- data/spec/railsapps/rails_30/.gitignore +2 -0
- data/spec/railsapps/rails_30/Gemfile +7 -0
- data/spec/railsapps/rails_30/app/mailers/auto_mailer.rb +17 -0
- data/spec/railsapps/rails_30/app/mailers/mailer.rb +17 -0
- data/spec/railsapps/rails_30/app/views/auto_mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_30/app/views/auto_mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_30/app/views/mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_30/app/views/mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_30/config/application.rb +19 -0
- data/spec/railsapps/rails_30/config/boot.rb +6 -0
- data/spec/railsapps/rails_30/config/environment.rb +5 -0
- data/spec/railsapps/rails_30/config/environments/development.rb +10 -0
- data/spec/railsapps/rails_30/config/initializers/secret_token.rb +1 -0
- data/spec/railsapps/rails_30/config/initializers/session_store.rb +1 -0
- data/spec/railsapps/rails_30/config/routes.rb +2 -0
- data/spec/railsapps/rails_30/public/images/rails.png +0 -0
- data/spec/railsapps/rails_30/public/stylesheets/email.css +2 -0
- data/spec/railsapps/rails_30/script/rails +6 -0
- data/spec/railsapps/rails_31/.gitignore +2 -0
- data/spec/railsapps/rails_31/Gemfile +11 -0
- data/spec/railsapps/rails_31/app/assets/images/rails.png +0 -0
- data/spec/railsapps/rails_31/app/assets/stylesheets/email.css.scss +2 -0
- data/spec/railsapps/rails_31/app/mailers/auto_mailer.rb +17 -0
- data/spec/railsapps/rails_31/app/mailers/mailer.rb +17 -0
- data/spec/railsapps/rails_31/app/views/auto_mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_31/app/views/auto_mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_31/app/views/mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_31/app/views/mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_31/config/application.rb +22 -0
- data/spec/railsapps/rails_31/config/boot.rb +6 -0
- data/spec/railsapps/rails_31/config/environment.rb +5 -0
- data/spec/railsapps/rails_31/config/environments/development.rb +11 -0
- data/spec/railsapps/rails_31/config/initializers/secret_token.rb +1 -0
- data/spec/railsapps/rails_31/config/initializers/session_store.rb +1 -0
- data/spec/railsapps/rails_31/config/initializers/wrap_parameters.rb +4 -0
- data/spec/railsapps/rails_31/config/routes.rb +2 -0
- data/spec/railsapps/rails_31/script/rails +6 -0
- data/spec/railsapps/rails_32/.gitignore +2 -0
- data/spec/railsapps/rails_32/Gemfile +11 -0
- data/spec/railsapps/rails_32/app/assets/images/rails.png +0 -0
- data/spec/railsapps/rails_32/app/assets/stylesheets/email.css.scss +2 -0
- data/spec/railsapps/rails_32/app/mailers/auto_mailer.rb +17 -0
- data/spec/railsapps/rails_32/app/mailers/mailer.rb +17 -0
- data/spec/railsapps/rails_32/app/views/auto_mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_32/app/views/auto_mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_32/app/views/mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_32/app/views/mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_32/config/application.rb +22 -0
- data/spec/railsapps/rails_32/config/boot.rb +6 -0
- data/spec/railsapps/rails_32/config/environment.rb +5 -0
- data/spec/railsapps/rails_32/config/environments/development.rb +11 -0
- data/spec/railsapps/rails_32/config/initializers/secret_token.rb +1 -0
- data/spec/railsapps/rails_32/config/initializers/session_store.rb +1 -0
- data/spec/railsapps/rails_32/config/initializers/wrap_parameters.rb +4 -0
- data/spec/railsapps/rails_32/config/routes.rb +2 -0
- data/spec/railsapps/rails_32/script/rails +6 -0
- data/spec/railsapps/rails_40/Gemfile +9 -0
- data/spec/railsapps/rails_40/app/assets/images/rails.png +0 -0
- data/spec/railsapps/rails_40/app/assets/stylesheets/email.css.scss +2 -0
- data/spec/railsapps/rails_40/app/mailers/auto_mailer.rb +17 -0
- data/spec/railsapps/rails_40/app/mailers/mailer.rb +17 -0
- data/spec/railsapps/rails_40/app/views/auto_mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_40/app/views/auto_mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_40/app/views/mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_40/app/views/mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_40/bin/rails +4 -0
- data/spec/railsapps/rails_40/config/application.rb +18 -0
- data/spec/railsapps/rails_40/config/boot.rb +4 -0
- data/spec/railsapps/rails_40/config/environment.rb +5 -0
- data/spec/railsapps/rails_40/config/environments/development.rb +9 -0
- data/spec/railsapps/rails_40/config/initializers/secret_token.rb +1 -0
- data/spec/railsapps/rails_40/config/initializers/session_store.rb +1 -0
- data/spec/railsapps/rails_40/config/routes.rb +2 -0
- data/spec/railsapps/rails_40_no_pipeline/Gemfile +9 -0
- data/spec/railsapps/rails_40_no_pipeline/app/mailers/auto_mailer.rb +17 -0
- data/spec/railsapps/rails_40_no_pipeline/app/mailers/mailer.rb +17 -0
- data/spec/railsapps/rails_40_no_pipeline/app/views/auto_mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_40_no_pipeline/app/views/auto_mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_40_no_pipeline/app/views/mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_40_no_pipeline/app/views/mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_40_no_pipeline/bin/rails +4 -0
- data/spec/railsapps/rails_40_no_pipeline/config/application.rb +19 -0
- data/spec/railsapps/rails_40_no_pipeline/config/boot.rb +4 -0
- data/spec/railsapps/rails_40_no_pipeline/config/environment.rb +5 -0
- data/spec/railsapps/rails_40_no_pipeline/config/environments/development.rb +9 -0
- data/spec/railsapps/rails_40_no_pipeline/config/initializers/secret_token.rb +1 -0
- data/spec/railsapps/rails_40_no_pipeline/config/initializers/session_store.rb +1 -0
- data/spec/railsapps/rails_40_no_pipeline/config/routes.rb +2 -0
- data/spec/railsapps/rails_40_no_pipeline/log/dee +0 -0
- data/spec/railsapps/rails_40_no_pipeline/public/images/rails.png +0 -0
- data/spec/railsapps/rails_40_no_pipeline/public/stylesheets/email.css +2 -0
- data/spec/railsapps/rails_40_precompiled/Gemfile +9 -0
- data/spec/railsapps/rails_40_precompiled/Rakefile +6 -0
- data/spec/railsapps/rails_40_precompiled/app/assets/images/rails.png +0 -0
- data/spec/railsapps/rails_40_precompiled/app/assets/stylesheets/email.css.scss +2 -0
- data/spec/railsapps/rails_40_precompiled/app/mailers/mailer.rb +17 -0
- data/spec/railsapps/rails_40_precompiled/app/views/mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_40_precompiled/app/views/mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_40_precompiled/bin/rails +4 -0
- data/spec/railsapps/rails_40_precompiled/config/application.rb +18 -0
- data/spec/railsapps/rails_40_precompiled/config/boot.rb +4 -0
- data/spec/railsapps/rails_40_precompiled/config/environment.rb +5 -0
- data/spec/railsapps/rails_40_precompiled/config/environments/development.rb +14 -0
- data/spec/railsapps/rails_40_precompiled/config/initializers/secret_token.rb +1 -0
- data/spec/railsapps/rails_40_precompiled/config/initializers/session_store.rb +1 -0
- data/spec/railsapps/rails_40_precompiled/config/routes.rb +2 -0
- data/spec/railsapps/rails_40_precompiled/public/assets/email-fad0c62b8f82e2835c1d0bdc19894257.css +5 -0
- data/spec/railsapps/rails_40_precompiled/public/assets/email-fad0c62b8f82e2835c1d0bdc19894257.css.gz +0 -0
- data/spec/railsapps/rails_40_precompiled/public/assets/manifest-8a3d16aeb2a40fe5057dd998c3edab10.json +1 -0
- data/spec/railsapps/rails_40_precompiled/public/assets/rails-231a680f23887d9dd70710ea5efd3c62.png +0 -0
- data/spec/railsapps/rails_41/.gitignore +16 -0
- data/spec/railsapps/rails_41/Gemfile +8 -0
- data/spec/railsapps/rails_41/app/assets/images/rails.png +0 -0
- data/spec/railsapps/rails_41/app/assets/stylesheets/email.css.scss +2 -0
- data/spec/railsapps/rails_41/app/mailers/auto_mailer.rb +17 -0
- data/spec/railsapps/rails_41/app/mailers/mailer.rb +17 -0
- data/spec/railsapps/rails_41/app/views/auto_mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_41/app/views/auto_mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_41/app/views/mailer/normal_email.html.erb +11 -0
- data/spec/railsapps/rails_41/app/views/mailer/normal_email.text +1 -0
- data/spec/railsapps/rails_41/bin/rails +4 -0
- data/spec/railsapps/rails_41/config.ru +4 -0
- data/spec/railsapps/rails_41/config/application.rb +13 -0
- data/spec/railsapps/rails_41/config/boot.rb +4 -0
- data/spec/railsapps/rails_41/config/environment.rb +5 -0
- data/spec/railsapps/rails_41/config/environments/development.rb +9 -0
- data/spec/railsapps/rails_41/config/initializers/secret_token.rb +1 -0
- data/spec/railsapps/rails_41/config/initializers/session_store.rb +1 -0
- data/spec/railsapps/rails_41/config/routes.rb +2 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/support/have_selector_matcher.rb +3 -0
- data/spec/support/have_styling_matcher.rb +63 -0
- data/spec/support/rails_app.rb +70 -0
- metadata +443 -0
Binary file
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Mailer < ActionMailer::Base
|
2
|
+
include Roadie::Rails::Mailer
|
3
|
+
|
4
|
+
default from: 'john@example.com'
|
5
|
+
|
6
|
+
def normal_email
|
7
|
+
roadie_mail(to: 'example@example.org', subject: "Notification for you") do |format|
|
8
|
+
format.html
|
9
|
+
format.text
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def roadie_options
|
15
|
+
super.combine(url_options: {protocol: "https"})
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Normal email
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
# Pick the frameworks you want:
|
4
|
+
# require "active_record/railtie"
|
5
|
+
require "action_controller/railtie"
|
6
|
+
require "action_mailer/railtie"
|
7
|
+
require "sprockets/railtie"
|
8
|
+
# require "rails/test_unit/railtie"
|
9
|
+
|
10
|
+
# Require the gems listed in Gemfile, including any gems
|
11
|
+
# you've limited to :test, :development, or :production.
|
12
|
+
Bundler.require(:default, Rails.env)
|
13
|
+
|
14
|
+
module Rails40
|
15
|
+
class Application < Rails::Application
|
16
|
+
config.roadie.url_options = {host: 'example.app.org'}
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Rails40::Application.configure do
|
2
|
+
config.cache_classes = false
|
3
|
+
config.eager_load = false
|
4
|
+
config.consider_all_requests_local = true
|
5
|
+
config.action_controller.perform_caching = false
|
6
|
+
config.action_mailer.raise_delivery_errors = false
|
7
|
+
config.active_support.deprecation = :log
|
8
|
+
|
9
|
+
config.assets.debug = false
|
10
|
+
config.assets.compile = false
|
11
|
+
config.assets.digest = true
|
12
|
+
config.assets.precompile += %w[email.css other.css]
|
13
|
+
config.assets.initialize_on_precompile = false
|
14
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Rails40::Application.config.secret_key_base = '62c740bbc79cd7fa4dfabc7365c0f7ec98204cfae45a41d2e1423d6084bb762e9310acf46fc7e4cc6215a90c7aeef4107b9f1c7e3b68623fd11af43b716ccf5e'
|
@@ -0,0 +1 @@
|
|
1
|
+
Rails40::Application.config.session_store :cookie_store, key: '_rails_40_session'
|
data/spec/railsapps/rails_40_precompiled/public/assets/email-fad0c62b8f82e2835c1d0bdc19894257.css.gz
ADDED
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
{"files":{"rails-231a680f23887d9dd70710ea5efd3c62.png":{"logical_path":"rails.png","mtime":"2013-08-05T10:07:29+02:00","size":6646,"digest":"231a680f23887d9dd70710ea5efd3c62"},"email-fad0c62b8f82e2835c1d0bdc19894257.css":{"logical_path":"email.css","mtime":"2013-11-20T08:39:33+01:00","size":119,"digest":"fad0c62b8f82e2835c1d0bdc19894257"}},"assets":{"rails.png":"rails-231a680f23887d9dd70710ea5efd3c62.png","email.css":"email-fad0c62b8f82e2835c1d0bdc19894257.css"}}
|
data/spec/railsapps/rails_40_precompiled/public/assets/rails-231a680f23887d9dd70710ea5efd3c62.png
ADDED
Binary file
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile '~/.gitignore_global'
|
6
|
+
|
7
|
+
# Ignore bundler config.
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore the default SQLite database.
|
11
|
+
/db/*.sqlite3
|
12
|
+
/db/*.sqlite3-journal
|
13
|
+
|
14
|
+
# Ignore all logfiles and tempfiles.
|
15
|
+
/log/*.log
|
16
|
+
/tmp
|
@@ -0,0 +1,8 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
gem 'rails', '4.0.0'
|
3
|
+
gem 'sass-rails', '~> 4.0.0'
|
4
|
+
|
5
|
+
gem 'roadie-rails', :path => '../../..'
|
6
|
+
|
7
|
+
# Use git version of `roadie` until a full release have been made
|
8
|
+
gem 'roadie', git: 'git://github.com/Mange/roadie.git', branch: 'master'
|
Binary file
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class AutoMailer < ActionMailer::Base
|
2
|
+
include Roadie::Rails::Automatic
|
3
|
+
|
4
|
+
default from: 'john@example.com'
|
5
|
+
|
6
|
+
def normal_email
|
7
|
+
mail(to: 'example@example.org', subject: "Notification for you") do |format|
|
8
|
+
format.html
|
9
|
+
format.text
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def roadie_options
|
15
|
+
super.combine(url_options: {protocol: "https"})
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Mailer < ActionMailer::Base
|
2
|
+
include Roadie::Rails::Mailer
|
3
|
+
|
4
|
+
default from: 'john@example.com'
|
5
|
+
|
6
|
+
def normal_email
|
7
|
+
roadie_mail(to: 'example@example.org', subject: "Notification for you") do |format|
|
8
|
+
format.html
|
9
|
+
format.text
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def roadie_options
|
15
|
+
super.combine(url_options: {protocol: "https"})
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Normal email
|
@@ -0,0 +1 @@
|
|
1
|
+
Normal email
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require "action_controller/railtie"
|
4
|
+
require "action_mailer/railtie"
|
5
|
+
require "sprockets/railtie"
|
6
|
+
|
7
|
+
Bundler.require(:default, Rails.env)
|
8
|
+
|
9
|
+
module Rails41
|
10
|
+
class Application < Rails::Application
|
11
|
+
config.roadie.url_options = {host: 'example.app.org'}
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Rails41::Application.configure do
|
2
|
+
config.cache_classes = false
|
3
|
+
config.eager_load = false
|
4
|
+
config.consider_all_requests_local = true
|
5
|
+
config.action_controller.perform_caching = false
|
6
|
+
config.action_mailer.raise_delivery_errors = false
|
7
|
+
config.active_support.deprecation = :log
|
8
|
+
config.assets.debug = true
|
9
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Rails41::Application.config.secret_key_base = '4fc45a45fecece06ff370f3271d9c2f29cdd0b029bde255d77318418e5066681d42c706f5e504b9298f2b5ccbd2c013c39d474e6521ef4c4f056b1368ce22c8f'
|
@@ -0,0 +1 @@
|
|
1
|
+
Rails41::Application.config.session_store :cookie_store, key: '_rails_41_session'
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "rspec/collection_matchers"
|
2
|
+
|
3
|
+
if ENV['CI']
|
4
|
+
require 'coveralls'
|
5
|
+
Coveralls.wear!
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'roadie-rails'
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.run_all_when_everything_filtered = true
|
12
|
+
end
|
13
|
+
|
14
|
+
Dir['./spec/support/**/*.rb'].each { |file| require file }
|
@@ -0,0 +1,63 @@
|
|
1
|
+
RSpec::Matchers.define :have_styling do |rules|
|
2
|
+
normalized_rules = StylingExpectation.new(rules)
|
3
|
+
|
4
|
+
chain(:at_selector) { |selector| @selector = selector }
|
5
|
+
|
6
|
+
match { |document|
|
7
|
+
@selector ||= 'body > *:first'
|
8
|
+
normalized_rules == styles_at_selector(document)
|
9
|
+
}
|
10
|
+
|
11
|
+
description {
|
12
|
+
"have styles #{normalized_rules.inspect} at selector #{@selector.inspect}"
|
13
|
+
}
|
14
|
+
|
15
|
+
failure_message { |document|
|
16
|
+
"expected styles at #{@selector.inspect} to be:\n#{normalized_rules}\nbut was:\n#{styles_at_selector(document)}"
|
17
|
+
}
|
18
|
+
|
19
|
+
failure_message_when_negated {
|
20
|
+
"expected styles at #{@selector.inspect} to not be:\n#{normalized_rules}"
|
21
|
+
}
|
22
|
+
|
23
|
+
def styles_at_selector(document)
|
24
|
+
expect(document).to have_selector(@selector)
|
25
|
+
style = document.at_css(@selector)['style']
|
26
|
+
StylingExpectation.new(style || "")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class StylingExpectation
|
31
|
+
def initialize(styling)
|
32
|
+
case styling
|
33
|
+
when String then @rules = parse_rules(styling)
|
34
|
+
when Array then @rules = styling
|
35
|
+
when Hash then @rules = styling.to_a
|
36
|
+
else fail "I don't understand #{styling.inspect}!"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def ==(other)
|
41
|
+
rules == other.rules
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_s() rules.to_s end
|
45
|
+
|
46
|
+
protected
|
47
|
+
attr_reader :rules
|
48
|
+
|
49
|
+
private
|
50
|
+
def parse_rules(css)
|
51
|
+
css.split(';').map { |property| parse_property(property) }
|
52
|
+
end
|
53
|
+
|
54
|
+
def parse_property(property)
|
55
|
+
rule, value = property.split(':', 2).map(&:strip)
|
56
|
+
[rule, normalize_quotes(value)]
|
57
|
+
end
|
58
|
+
|
59
|
+
# JRuby's Nokogiri encodes quotes
|
60
|
+
def normalize_quotes(string)
|
61
|
+
string.gsub '%22', '"'
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
class RailsApp
|
2
|
+
def initialize(name, path, options = {})
|
3
|
+
@name = name
|
4
|
+
@path = File.expand_path("../../railsapps/#{path}", __FILE__)
|
5
|
+
@runner = options.fetch(:runner)
|
6
|
+
@using_asset_pipeline = options.fetch(:asset_pipeline)
|
7
|
+
reset
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_s() @name end
|
11
|
+
def using_asset_pipeline?() @using_asset_pipeline end
|
12
|
+
|
13
|
+
def read_email(mail_name)
|
14
|
+
result = run("puts Mailer.#{mail_name}.to_s")
|
15
|
+
raise "No email returned. Did the rails application crash?" if result.strip.empty?
|
16
|
+
Mail.read_from_string(result)
|
17
|
+
end
|
18
|
+
|
19
|
+
def read_delivered_email(mail_name)
|
20
|
+
result = run("mail = AutoMailer.#{mail_name}; mail.delivery_method(:test); mail.deliver; puts mail.to_s")
|
21
|
+
raise "No email returned. Did the rails application crash?" if result.strip.empty?
|
22
|
+
Mail.read_from_string(result)
|
23
|
+
end
|
24
|
+
|
25
|
+
def read_providers
|
26
|
+
result = run(<<-RUBY).strip
|
27
|
+
providers = Rails.application.config.roadie.asset_providers
|
28
|
+
puts providers.map { |p| p.class.name }.join(',')
|
29
|
+
RUBY
|
30
|
+
raise "No output present. Did the application crash?" if result.empty?
|
31
|
+
result.split(",")
|
32
|
+
end
|
33
|
+
|
34
|
+
def reset
|
35
|
+
@extra_code = ""
|
36
|
+
end
|
37
|
+
|
38
|
+
def before_mail(code)
|
39
|
+
@extra_code << "\n" << code << "\n"
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
def run(code)
|
44
|
+
Tempfile.open('code') do |file|
|
45
|
+
file << @extra_code unless @extra_code.empty?
|
46
|
+
file << code
|
47
|
+
file.close
|
48
|
+
run_file_in_app_context file.path
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def run_file_in_app_context(file_path)
|
53
|
+
# Unset environment variables set by Bundler to get a clean slate
|
54
|
+
IO.popen(<<-SH).read
|
55
|
+
unset BUNDLE_GEMFILE;
|
56
|
+
unset RUBYOPT;
|
57
|
+
export RAILS_ENV=development
|
58
|
+
cd #{@path.shellescape} && #{runner_script} #{file_path.shellescape}
|
59
|
+
SH
|
60
|
+
end
|
61
|
+
|
62
|
+
def runner_script
|
63
|
+
case @runner
|
64
|
+
when :script then "script/rails runner"
|
65
|
+
when :bin then "bin/rails runner"
|
66
|
+
else raise "Unknown runner type: #{@runner}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|