├── .gitignore
├── .travis.yml
├── Gemfile
├── README.md
├── Rakefile
├── lib
├── sprockets_better_errors.rb
└── sprockets_better_errors
│ ├── sprockets_rails_helper.rb
│ ├── sprockets_railtie.rb
│ └── version.rb
├── sprockets_better_errors.gemspec
└── test
├── dummy
├── Rakefile
├── app
│ ├── assets
│ │ ├── images
│ │ │ └── .keep
│ │ ├── javascripts
│ │ │ ├── application.js
│ │ │ ├── no_erb_tag_error.js
│ │ │ ├── no_errors.js
│ │ │ ├── no_reference_error.js.erb
│ │ │ ├── not_precompiled.js
│ │ │ └── welcome.js.coffee
│ │ └── stylesheets
│ │ │ └── application.css
│ ├── controllers
│ │ ├── application_controller.rb
│ │ └── foo_controller.rb
│ ├── helpers
│ │ └── application_helper.rb
│ └── views
│ │ ├── foo
│ │ ├── index.html
│ │ ├── no_erb_tag_error.html.erb
│ │ ├── no_errors.html.erb
│ │ ├── no_reference_error.html.erb
│ │ └── precompile_error.html.erb
│ │ └── layouts
│ │ └── application.html.erb
├── config.ru
├── config
│ ├── application.rb
│ ├── boot.rb
│ ├── database.yml
│ ├── environment.rb
│ ├── environments
│ │ ├── development.rb
│ │ ├── production.rb
│ │ └── test.rb
│ ├── initializers
│ │ ├── backtrace_silencers.rb
│ │ ├── inflections.rb
│ │ ├── mime_types.rb
│ │ ├── secret_token.rb
│ │ └── session_store.rb
│ ├── locales
│ │ └── en.yml
│ └── routes.rb
├── public
│ ├── 404.html
│ ├── 422.html
│ ├── 500.html
│ ├── cinco.png
│ ├── favicon.ico
│ └── index.html
├── script
│ └── rails
└── tmp
│ └── capybara
│ ├── capybara-201311081652534466693170.html
│ ├── capybara-201311081654135123748192.html
│ ├── capybara-201311081656053021254170.html
│ ├── capybara-201311081656457051701013.html
│ ├── capybara-201311081659485877638897.html
│ ├── capybara-201311081700172970244208.html
│ ├── capybara-201311081700599079106420.html
│ ├── capybara-201311081701386395720887.html
│ ├── capybara-201311081710273253101711.html
│ ├── capybara-20131108171106624789610.html
│ ├── capybara-201311081712048792320330.html
│ ├── capybara-201311081712211232801645.html
│ ├── capybara-201311081713141534596918.html
│ ├── capybara-201311081713239549389443.html
│ ├── capybara-201311081713578623637052.html
│ ├── capybara-20131108171444164374684.html
│ ├── capybara-201311081715138372476507.html
│ ├── capybara-201311091505244823849905.html
│ ├── capybara-201311091530174187311595.html
│ ├── capybara-201311091608397964104129.html
│ ├── capybara-20131109160958397538938.html
│ └── capybara-201311091626051738950286.html
├── integration
└── precompile_raise_test.rb
├── route_inspector_test.rb
├── support
└── integration_case.rb
└── test_helper.rb
/.gitignore:
--------------------------------------------------------------------------------
1 | *.log
2 | *.gem
3 | Gemfile.lock
4 | tmp/
5 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: ruby
2 | rvm:
3 | - 1.9.3
4 | - 2.0.0
5 | - ruby-head
6 | - jruby-19mode
7 |
8 | env:
9 | - "RAILS_VERSION=3.2.0"
10 | - "RAILS_VERSION=4.0.1"
11 | - "RAILS_VERSION=master"
12 |
13 | matrix:
14 | allow_failures:
15 | - env: "RAILS_VERSION=master"
16 | - rvm: ruby-head
17 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source "https://rubygems.org"
2 |
3 | rails_version = ENV["RAILS_VERSION"] || "default"
4 |
5 |
6 | rails = case rails_version
7 | when "master"
8 | {github: "rails/rails"}
9 | when "default"
10 | ">= 4.0"
11 | else
12 | "~> #{rails_version}"
13 | end
14 |
15 | gem "rails", rails
16 |
17 | if rails_version.match(/^3\.2/)
18 | gem 'sprockets', '2.2.2.backport2'
19 | gem 'sprockets-rails', '2.0.0.backport1'
20 | end
21 |
22 | gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
23 | gem "activerecord-jdbcsqlite3-adapter", '>= 1.3.0.beta', :platform => :jruby
24 |
25 | gemspec
26 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Sprockets Better Errors [](https://travis-ci.org/schneems/sprockets_better_errors)
2 |
3 | ## What
4 |
5 | Errors, more of them, and better. For sprockets, specifically sprockets-rails < 2.1. The goal of this library is to make it painfully obvious when you've done something wrong with the rails asset pipeline. Like what?
6 |
7 | Let's say you're referencing an asset in your view
8 |
9 | ```erb
10 | <%= stylesheet_link_tag "search" %>
11 | ```
12 |
13 | This works in development but you'll find if you're precompiling your assets that it won't work in production. Why? By default sprockets is configured only to precompile `application.css`. Wouldn't it have been great if you could have been warned in development before you pushed to production and your site broke?
14 |
15 | ```
16 | Asset filtered out and will not be served: add `config.assets.precompile += %w( search.css )` to `config/application.rb` and restart your server
17 | ```
18 |
19 | That would be AMAZING! Well this gem adds these types of helpful errors!
20 |
21 | ## Compatibility
22 |
23 | Rails > 3.2.0 and < 4.0.6. See gemspec for details.
24 |
25 | If you're using Rails 3.2 you will need to [enable the Rails 4 asset pipeline in Rails 3](https://discussion.heroku.com/t/using-the-rails-4-asset-pipeline-in-rails-3-apps-for-faster-deploys/205).
26 |
27 | ## Install
28 |
29 | In your `Gemfile` add:
30 |
31 | ```
32 | gem 'sprockets_better_errors'
33 | ```
34 |
35 | Then run:
36 |
37 | ```
38 | $ bundle install
39 | ```
40 |
41 | And add this line to your `config/environments/development.rb`:
42 |
43 | ```
44 | config.assets.raise_production_errors = true
45 | ```
46 |
47 | Now develop with some sprockets super powers!
48 |
49 |
50 | ## The Errors
51 |
52 | We try to catch all mistakes but we're not perfect. Here's a list of the things we watch out for
53 |
54 | ### Raise On Dev asset not in Precompile List
55 |
56 | This is one of the most common asset errors I see at Heroku. We covered this error in the "Why" section above. Incase you're skipping around here's the run down:
57 |
58 | Let's say you're referencing an asset in your view
59 |
60 | ```erb
61 | <%= stylesheet_link_tag "search.css" %>
62 | ```
63 |
64 | This works in development but you'll find if you're precompiling your assets that it won't work in production. Why? By default sprockets is configured only to precompile `application.css`. Wouldn't it have been great if you could have been warned in development before you pushed to production and your site broke?
65 |
66 | ```
67 | Asset filtered out and will not be served: add `config.assets.precompile += %w( search.css )` to `config/application.rb` and restart your server
68 | ```
69 |
70 | Add this gem and you get that error.
71 |
72 | ### Raise When Dependencies Improperly Used
73 |
74 | This one may be a bit of an edge case for most people, but the difficulty in debugging (hours, days, weeks) is well worth the check.
75 |
76 | If a dependency is used in an ERB asset that references another asset, it will not be updated when the reference asset is updated. The fix is to use `//= depend_on` or its cousin `//= depend_on_asset` however this is easy to forget. See rails/sprockets-rails#95 for more information.
77 |
78 | Currently Rails/Sprockets hides this problem, and only surfaces it when the app is deployed with precompilation to production multiple times. We know that you will have this problem if you are referencing assets from within other assets and not declaring them as dependencies. This PR checks if you've declared a given file as a dependency before including it via `asset_path`. If not a helpful error is raised:
79 |
80 | ```
81 | Asset depends on 'bootstrap.js' to generate properly but has not declared the dependency
82 | Please add: `//= depend_on_asset "bootstrap.js"` to '/Users/schneems/Documents/projects/codetriage/app/assets/javascripts/application.js.erb'
83 | ```
84 |
85 | Implementation is quite simple and limited to `helper.rb`, additional code is all around tests.
86 |
87 |
88 | ## Upstream
89 |
90 | Why not add this code upstream? I already tried, there are several PR awaiting merge. If you found this Gem useful maybe give them a `:+1:`.
91 |
92 | - [Raise On Dev asset not in Precompile list](https://github.com/rails/sprockets-rails/pull/84)
93 | - [Raise on improper dependency use](https://github.com/rails/sprockets-rails/pull/96)
94 | - Bonus, not mine: [Raise if ERB ](https://github.com/sstephenson/sprockets/pull/426)
95 |
96 |
97 | ## Tests
98 |
99 | Here's a one liner to running tests
100 |
101 | ```
102 | $ export RAILS_VERSION=4.0.0; bundle update; bundle exec rake test
103 | ```
104 |
105 | ## License
106 |
107 | MIT
108 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | # encoding: UTF-8
2 | require 'rubygems'
3 | require 'bundler'
4 |
5 | begin
6 | Bundler.setup(:default, :development, :test)
7 | rescue Bundler::BundlerError => e
8 | $stderr.puts e.message
9 | $stderr.puts "Run `bundle install` to install missing gems"
10 | exit e.status_code
11 | end
12 |
13 | require 'rake'
14 | require 'rdoc/task'
15 |
16 | require 'rake/testtask'
17 |
18 | Rake::TestTask.new(:test) do |t|
19 | t.libs << 'lib'
20 | t.libs << 'test'
21 | t.pattern = 'test/**/*_test.rb'
22 | t.verbose = false
23 | end
24 |
25 | task :default => :test
26 |
27 |
--------------------------------------------------------------------------------
/lib/sprockets_better_errors.rb:
--------------------------------------------------------------------------------
1 | module SprocketsBetterErrors
2 | end
3 |
4 | require 'sprockets_better_errors/sprockets_rails_helper'
5 | require 'sprockets_better_errors/sprockets_railtie'
6 |
--------------------------------------------------------------------------------
/lib/sprockets_better_errors/sprockets_rails_helper.rb:
--------------------------------------------------------------------------------
1 | module Sprockets::Rails::Helper
2 |
3 | # == BEGIN Hacks for checking if dependencies are listed correctly
4 | class DependencyError < StandardError
5 | def initialize(path, dep)
6 | msg = "Asset depends on '#{dep}' to generate properly but has not declared the dependency\n"
7 | msg << "Please add: `//= depend_on_asset \"#{dep}\"` to '#{path}'"
8 | super msg
9 | end
10 | end
11 |
12 |
13 | def check_dependencies!(dep)
14 | return unless Sprockets::Rails::Helper.raise_asset_errors
15 | return unless @_dependency_assets
16 | return if @_dependency_assets.detect { |asset| asset.include?(dep) }
17 | raise DependencyError.new(self.pathname, dep)
18 | end
19 |
20 | alias :orig_compute_asset_path :compute_asset_path
21 | def compute_asset_path(path, options = {})
22 | check_dependencies!(path)
23 | orig_compute_asset_path(path, options)
24 | end
25 |
26 | # == BEGIN Hacks for checking if asset is in precompile list
27 |
28 | # support for Ruby 1.9.3 Rails 3.x
29 | @_config = ActiveSupport::InheritableOptions.new({}) unless defined?(ActiveSupport::Configurable::Configuration)
30 | include ActiveSupport::Configurable
31 | config_accessor :precompile, :assets, :raise_asset_errors
32 |
33 | class AssetFilteredError < StandardError
34 | def initialize(source)
35 | msg = "Asset filtered out and will not be served: " <<
36 | "add `config.assets.precompile += %w( #{source} )` " <<
37 | "to `config/application.rb` and restart your server"
38 | super(msg)
39 | end
40 | end
41 |
42 |
43 | alias :orig_asset_path :asset_path
44 | def asset_path(source, options = {})
45 | check_errors_for(source)
46 | path_to_asset(source, options)
47 | end
48 |
49 | alias :orig_javascript_include_tag :javascript_include_tag
50 | def javascript_include_tag(*args)
51 | sources = args.dup
52 | sources.extract_options!
53 | sources.map do |source|
54 | check_errors_for(source)
55 | end
56 | orig_javascript_include_tag(*args)
57 | end
58 |
59 | alias :orig_stylesheet_link_tag :stylesheet_link_tag
60 | def stylesheet_link_tag(*args)
61 | sources = args.dup
62 | sources.extract_options!
63 | sources.map do |source|
64 | check_errors_for(source)
65 | end
66 | orig_stylesheet_link_tag(*args)
67 | end
68 |
69 | protected
70 | # Raise errors when source does not exist or is not in the precomiled list
71 | def check_errors_for(source)
72 | return source unless Sprockets::Rails::Helper.raise_asset_errors
73 | return source if ["all", "defaults"].include?(source.to_s)
74 | return "" if source.blank?
75 | return source if source =~ URI_REGEXP
76 |
77 | asset = lookup_asset_for_path(source)
78 | return if asset.blank?
79 | raise AssetFilteredError.new(source) if asset_needs_precompile?(source, asset.pathname.to_s)
80 | end
81 |
82 | # Returns true when an asset will not available after precompile is run
83 | def asset_needs_precompile?(source, filename)
84 | return true unless Sprockets::Rails::Helper.assets
85 | return false if Sprockets::Rails::Helper.assets.send(:matches_filter, Sprockets::Rails::Helper.precompile || [], source.to_s, filename)
86 | true
87 | end
88 | end
89 |
--------------------------------------------------------------------------------
/lib/sprockets_better_errors/sprockets_railtie.rb:
--------------------------------------------------------------------------------
1 | module Sprockets
2 | class Railtie < ::Rails::Railtie
3 | config.after_initialize do |app|
4 | Sprockets::Rails::Helper.precompile = app.config.assets.precompile
5 | Sprockets::Rails::Helper.assets = app.assets
6 | Sprockets::Rails::Helper.raise_asset_errors = app.config.assets.raise_production_errors
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/lib/sprockets_better_errors/version.rb:
--------------------------------------------------------------------------------
1 | module SprocketsBetterErrors
2 | VERSION = "0.0.5"
3 | end
4 |
--------------------------------------------------------------------------------
/sprockets_better_errors.gemspec:
--------------------------------------------------------------------------------
1 | # -*- encoding: utf-8 -*-
2 | lib = File.expand_path('../lib', __FILE__)
3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4 | require 'sprockets_better_errors/version'
5 |
6 | Gem::Specification.new do |gem|
7 | gem.name = "sprockets_better_errors"
8 | gem.version = SprocketsBetterErrors::VERSION
9 | gem.authors = ["Richard Schneeman"]
10 | gem.email = ["richard.schneeman+rubygems@gmail.com"]
11 | gem.description = %q{ Raise now so you don't pay later }
12 | gem.summary = %q{ Better sprockets errors in development so you'll know if things work before you push to production }
13 | gem.homepage = "https://github.com/schneems/sprockets_better_errors"
14 | gem.license = "MIT"
15 |
16 | gem.files = `git ls-files`.split($/)
17 | gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18 | gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19 | gem.require_paths = ["lib"]
20 |
21 | msg = <<-MSG
22 |
23 | To enable sprockets_better_errors
24 | add this line to your `config/environments/development.rb:
25 | config.assets.raise_production_errors = true
26 |
27 | MSG
28 |
29 | gem.post_install_message = msg
30 |
31 | gem.add_dependency 'sprockets-rails', '>= 1.0.0', '< 2.1'
32 | gem.add_dependency "activesupport", "< 4.1"
33 |
34 | gem.add_development_dependency "capybara", ">= 0.4.0"
35 | gem.add_development_dependency "launchy", "~> 2.1.0"
36 | gem.add_development_dependency "poltergeist"
37 | gem.add_development_dependency "rake"
38 | end
39 |
--------------------------------------------------------------------------------
/test/dummy/Rakefile:
--------------------------------------------------------------------------------
1 | # Add your own tasks in files placed in lib/tasks ending in .rake,
2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3 |
4 | require File.expand_path('../config/application', __FILE__)
5 | require 'rake'
6 |
7 | Dummy::Application.load_tasks
8 |
--------------------------------------------------------------------------------
/test/dummy/app/assets/images/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schneems/sprockets_better_errors/421ddb61c1e8341eb14a4bb2b132f00c00f63b5c/test/dummy/app/assets/images/.keep
--------------------------------------------------------------------------------
/test/dummy/app/assets/javascripts/application.js:
--------------------------------------------------------------------------------
1 | // This is a manifest file that'll be compiled into application.js, which will include all the files
2 | // listed below.
3 | //
4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5 | // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6 | //
7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8 | // compiled file.
9 | //
10 | // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11 | // about supported directives.
12 |
--------------------------------------------------------------------------------
/test/dummy/app/assets/javascripts/no_erb_tag_error.js:
--------------------------------------------------------------------------------
1 | a = <%= 1 + 1 %>;
--------------------------------------------------------------------------------
/test/dummy/app/assets/javascripts/no_errors.js:
--------------------------------------------------------------------------------
1 | //= depend_on_asset "application.css"
2 |
3 | var foo = '<%= asset_path("application.css") %>';
4 |
--------------------------------------------------------------------------------
/test/dummy/app/assets/javascripts/no_reference_error.js.erb:
--------------------------------------------------------------------------------
1 | var foo = '<%= asset_path("application.css") %>';
--------------------------------------------------------------------------------
/test/dummy/app/assets/javascripts/not_precompiled.js:
--------------------------------------------------------------------------------
1 | var a = 1+1;
2 |
--------------------------------------------------------------------------------
/test/dummy/app/assets/javascripts/welcome.js.coffee:
--------------------------------------------------------------------------------
1 | # Place all the behaviors and hooks related to the matching controller here.
2 | # All this logic will automatically be available in application.js.
3 | # You can use CoffeeScript in this file: http://coffeescript.org/
4 |
--------------------------------------------------------------------------------
/test/dummy/app/assets/stylesheets/application.css:
--------------------------------------------------------------------------------
1 | /*
2 | * This is a manifest file that'll be compiled into application.css, which will include all the files
3 | * listed below.
4 | *
5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6 | * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7 | *
8 | * You're free to add application-wide styles to this file and they'll appear at the top of the
9 | * compiled file, but it's generally better to create a new file per style scope.
10 | *
11 | *= require_self
12 | *= require_tree .
13 | */
14 |
--------------------------------------------------------------------------------
/test/dummy/app/controllers/application_controller.rb:
--------------------------------------------------------------------------------
1 | class ApplicationController < ActionController::Base
2 | protect_from_forgery
3 | end
4 |
--------------------------------------------------------------------------------
/test/dummy/app/controllers/foo_controller.rb:
--------------------------------------------------------------------------------
1 | class FooController < ApplicationController
2 | def index
3 | end
4 |
5 | def show
6 | render "foo/#{params[:id]}"
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/test/dummy/app/helpers/application_helper.rb:
--------------------------------------------------------------------------------
1 | module ApplicationHelper
2 | end
3 |
--------------------------------------------------------------------------------
/test/dummy/app/views/foo/index.html:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schneems/sprockets_better_errors/421ddb61c1e8341eb14a4bb2b132f00c00f63b5c/test/dummy/app/views/foo/index.html
--------------------------------------------------------------------------------
/test/dummy/app/views/foo/no_erb_tag_error.html.erb:
--------------------------------------------------------------------------------
1 | <%= asset_path("no_erb_tag_error.js") %>
2 |
--------------------------------------------------------------------------------
/test/dummy/app/views/foo/no_errors.html.erb:
--------------------------------------------------------------------------------
1 | <%= asset_path("no_errors.js") %>
2 | <%= stylesheet_link_tag :application %>
3 | <%= asset_path('cinco.png') %>
--------------------------------------------------------------------------------
/test/dummy/app/views/foo/no_reference_error.html.erb:
--------------------------------------------------------------------------------
1 | <%= asset_path("no_reference_error.js") %>
--------------------------------------------------------------------------------
/test/dummy/app/views/foo/precompile_error.html.erb:
--------------------------------------------------------------------------------
1 | <%= asset_path("not_precompiled.js") %>
2 |
--------------------------------------------------------------------------------
/test/dummy/app/views/layouts/application.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Dummy
5 | <%= stylesheet_link_tag :all %>
6 | <%= javascript_include_tag :defaults %>
7 | <%= csrf_meta_tag %>
8 |
9 |
10 |
11 | <%= yield %>
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/test/dummy/config.ru:
--------------------------------------------------------------------------------
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
5 |
--------------------------------------------------------------------------------
/test/dummy/config/application.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path('../boot', __FILE__)
2 |
3 | require 'rails/all'
4 |
5 | Bundler.require
6 |
7 | require "sprockets_better_errors"
8 |
9 | module Dummy
10 | class Application < Rails::Application
11 | # Settings in config/environments/* take precedence over those specified here.
12 | # Application configuration should go into files in config/initializers
13 | # -- all .rb files in that directory are automatically loaded.
14 |
15 | # Custom directories with classes and modules you want to be autoloadable.
16 | # config.autoload_paths += %W(#{config.root}/extras)
17 |
18 | # Only load the plugins named here, in the order given (default is alphabetical).
19 | # :all can be used as a placeholder for all plugins not explicitly named.
20 | # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
21 |
22 | # Activate observers that should always be running.
23 | # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
24 |
25 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
26 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
27 | # config.time_zone = 'Central Time (US & Canada)'
28 |
29 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
30 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
31 | # config.i18n.default_locale = :de
32 |
33 | # JavaScript files you want as :defaults (application.js is always included).
34 | # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
35 |
36 | config.assets.precompile += %w( no_reference_error.js
37 | no_errors.js
38 | no_erb_tag_error.js )
39 |
40 | # Configure the default encoding used in templates for Ruby 1.9.
41 | config.encoding = "utf-8"
42 |
43 | # Configure sensitive parameters which will be filtered from the log file.
44 | config.filter_parameters += [:password]
45 |
46 | config.assets.enabled = true
47 |
48 | config.assets.raise_production_errors = true
49 | end
50 | end
51 |
--------------------------------------------------------------------------------
/test/dummy/config/boot.rb:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 | gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3 |
4 | if File.exist?(gemfile)
5 | ENV['BUNDLE_GEMFILE'] = gemfile
6 | require 'bundler'
7 | Bundler.setup
8 | end
9 |
10 | $:.unshift File.expand_path('../../../../lib', __FILE__)
--------------------------------------------------------------------------------
/test/dummy/config/database.yml:
--------------------------------------------------------------------------------
1 | # SQLite version 3.x
2 | # gem install sqlite3
3 | development:
4 | adapter: sqlite3
5 | database: ":memory:"
6 | pool: 5
7 | timeout: 5000
8 |
9 | # Warning: The database defined as "test" will be erased and
10 | # re-generated from your development database when you run "rake".
11 | # Do not set this db to the same as development or production.
12 | test:
13 | adapter: sqlite3
14 | database: ":memory:"
15 | pool: 5
16 | timeout: 5000
17 |
18 | production:
19 | adapter: sqlite3
20 | database: ":memory:"
21 | pool: 5
22 | timeout: 5000
23 |
--------------------------------------------------------------------------------
/test/dummy/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the rails application
2 | require File.expand_path('../application', __FILE__)
3 |
4 | # Initialize the rails application
5 | Dummy::Application.initialize!
6 |
--------------------------------------------------------------------------------
/test/dummy/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | Dummy::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 webserver 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 |
19 | # Print deprecation notices to the Rails logger
20 | config.active_support.deprecation = :log
21 |
22 | # Only use best-standards-support built into browsers
23 | config.action_dispatch.best_standards_support = :builtin
24 | end
25 |
26 |
--------------------------------------------------------------------------------
/test/dummy/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | Dummy::Application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb
3 |
4 | # The production environment is meant for finished, "live" apps.
5 | # Code is not reloaded between requests
6 | config.cache_classes = true
7 |
8 | # Full error reports are disabled and caching is turned on
9 | config.consider_all_requests_local = false
10 | config.action_controller.perform_caching = true
11 |
12 | # Specifies the header that your server uses for sending files
13 | config.action_dispatch.x_sendfile_header = "X-Sendfile"
14 |
15 | # For nginx:
16 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
17 |
18 | # If you have no front-end server that supports something like X-Sendfile,
19 | # just comment this out and Rails will serve the files
20 |
21 | # See everything in the log (default is :info)
22 | # config.log_level = :debug
23 |
24 | # Use a different logger for distributed setups
25 | # config.logger = SyslogLogger.new
26 |
27 | # Use a different cache store in production
28 | # config.cache_store = :mem_cache_store
29 |
30 | # Disable Rails's static asset server
31 | # In production, Apache or nginx will already do this
32 | config.serve_static_assets = false
33 | # config.assets.precompile += %w( search.js )
34 |
35 | # Generate digests for assets URLs
36 | config.assets.digest = true
37 |
38 | # Enable serving of images, stylesheets, and javascripts from an asset server
39 | # config.action_controller.asset_host = "http://assets.example.com"
40 |
41 | # Disable delivery errors, bad email addresses will be ignored
42 | # config.action_mailer.raise_delivery_errors = false
43 |
44 | # Enable threaded mode
45 | # config.threadsafe!
46 |
47 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
48 | # the I18n.default_locale when a translation can not be found)
49 | config.i18n.fallbacks = true
50 |
51 | # Send deprecation notices to registered listeners
52 | config.active_support.deprecation = :notify
53 | end
54 |
--------------------------------------------------------------------------------
/test/dummy/config/environments/test.rb:
--------------------------------------------------------------------------------
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 | # Log error messages when you accidentally call methods on nil.
11 | config.whiny_nils = true
12 |
13 | # Show full error reports and disable caching
14 | config.consider_all_requests_local = true
15 | config.action_controller.perform_caching = false
16 |
17 | # Raise exceptions instead of rendering exception templates
18 | config.action_dispatch.show_exceptions = false
19 |
20 | # Disable request forgery protection in test environment
21 | config.action_controller.allow_forgery_protection = false
22 |
23 | # Generate digests for assets URLs
24 | config.assets.digest = true
25 |
26 | # Tell Action Mailer not to deliver emails to the real world.
27 | # The :test delivery method accumulates sent emails in the
28 | # ActionMailer::Base.deliveries array.
29 | config.action_mailer.delivery_method = :test
30 |
31 | # Use SQL instead of Active Record's schema dumper when creating the test database.
32 | # This is necessary if your schema can't be completely dumped by the schema dumper,
33 | # like if you have constraints or database-specific column types
34 | # config.active_record.schema_format = :sql
35 |
36 | # Print deprecation notices to the stderr
37 | config.active_support.deprecation = :stderr
38 | end
39 |
--------------------------------------------------------------------------------
/test/dummy/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
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!
8 |
--------------------------------------------------------------------------------
/test/dummy/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/test/dummy/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
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
6 |
--------------------------------------------------------------------------------
/test/dummy/config/initializers/secret_token.rb:
--------------------------------------------------------------------------------
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 = 'bedc31c5fff702ea808045bbbc5123455f1c00ecd005a1f667a5f04332100a6abf22cfcee2b3d39b8f677c03bb6503cf1c3b65c1287b9e13bd0d20c6431ec6ab'
8 |
--------------------------------------------------------------------------------
/test/dummy/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
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
9 |
--------------------------------------------------------------------------------
/test/dummy/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Sample localization file for English. Add more files in this directory for other locales.
2 | # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3 |
4 | en:
5 | hello: "Hello world"
6 |
--------------------------------------------------------------------------------
/test/dummy/config/routes.rb:
--------------------------------------------------------------------------------
1 | Dummy::Application.routes.draw do
2 | resources :foo
3 | resources :bar
4 | end
5 |
--------------------------------------------------------------------------------
/test/dummy/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The page you were looking for doesn't exist (404)
5 |
17 |
18 |
19 |
20 |
21 |
22 |
The page you were looking for doesn't exist.
23 |
You may have mistyped the address or the page may have moved.