bemer 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/{LICENSE-RU → LICENSE-RU.txt} +0 -0
- data/{LICENSE → LICENSE.txt} +5 -5
- data/README.md +47 -16
- data/docs/BEMHTML.md +5 -0
- data/docs//320/232/320/276/320/275/321/202/320/265/320/272/321/201/321/202-/321/203/320/267/320/273/320/260.md +275 -0
- data/docs//320/232/320/276/320/275/321/204/320/270/320/263/321/203/321/200/320/260/321/206/320/270/321/217.md +158 -0
- data/docs//320/237/321/200/320/265/320/264/320/270/320/272/320/260/321/202/321/213.md +205 -0
- data/docs//320/240/320/265/320/266/320/270/320/274/321/213.md +274 -0
- data/docs//320/241/320/276/320/267/320/264/320/260/320/275/320/270/320/265-/320/270-/320/270/321/201/320/277/320/276/320/273/321/214/320/267/320/276/320/262/320/260/320/275/320/270/320/265-UI-/320/272/320/276/320/274/320/277/320/276/320/275/320/265/320/275/321/202.md +173 -0
- data/docs//320/244/320/260/320/270/314/206/320/273/320/276/320/262/320/260/321/217-/321/201/321/202/321/200/321/203/320/272/321/202/321/203/321/200/320/260.md +167 -0
- data/docs//320/245/320/265/320/273/320/277/320/265/321/200-bem_mix.md +62 -0
- data/docs//320/245/320/265/320/273/320/277/320/265/321/200-bem_mods.md +63 -0
- data/docs//320/245/320/265/320/273/320/277/320/265/321/200-block_tag.md +215 -0
- data/docs//320/245/320/265/320/273/320/277/320/265/321/200-component_asset_path.md +71 -0
- data/docs//320/245/320/265/320/273/320/277/320/265/321/200-component_pack.md +101 -0
- data/docs//320/245/320/265/320/273/320/277/320/265/321/200-component_partial_path.md +28 -0
- data/docs//320/245/320/265/320/273/320/277/320/265/321/200-define_component.md +154 -0
- data/docs//320/245/320/265/320/273/320/277/320/265/321/200-define_templates.md +96 -0
- data/docs//320/245/320/265/320/273/320/277/320/265/321/200-elem_tag.md +38 -0
- data/docs//320/245/320/265/320/273/320/277/320/265/321/200-refine_component.md +114 -0
- data/docs//320/245/320/265/320/273/320/277/320/265/321/200-render_component.md +108 -0
- data/docs//320/250/320/260/320/261/320/273/320/276/320/275/321/213.md +44 -0
- data/lib/bemer.rb +3 -1
- data/lib/bemer/builders.rb +8 -0
- data/lib/bemer/builders/tree.rb +0 -8
- data/lib/bemer/configuration.rb +3 -1
- data/lib/bemer/context_extentions/structure.rb +2 -3
- data/lib/bemer/entity.rb +2 -2
- data/lib/bemer/entity_builder.rb +5 -9
- data/lib/bemer/helpers.rb +10 -0
- data/lib/bemer/mixin_list.rb +1 -1
- data/lib/bemer/modifier_list.rb +2 -2
- data/lib/bemer/path_resolver.rb +23 -0
- data/lib/bemer/pipeline/handler.rb +4 -6
- data/lib/bemer/railtie.rb +22 -9
- data/lib/bemer/renderer.rb +1 -1
- data/lib/bemer/template_list.rb +2 -4
- data/lib/bemer/tree.rb +3 -3
- data/lib/bemer/tree/node.rb +5 -7
- data/lib/bemer/version.rb +1 -1
- data/spec/bemer/railtie_spec.rb +95 -0
- data/spec/dummy/config/application.rb +30 -12
- data/spec/dummy/config/initializers/backtrace_silencers.rb +1 -5
- data/spec/dummy/config/initializers/bemer.rb +1 -3
- data/spec/rails_helper.rb +5 -9
- metadata +87 -129
- data/.gitignore +0 -17
- data/.overcommit.yml +0 -59
- data/.rspec +0 -4
- data/.rubocop.yml +0 -21
- data/.rubocop_todo.yml +0 -11
- data/Gemfile +0 -12
- data/Rakefile +0 -12
- data/bemer.gemspec +0 -43
- data/spec/dummy/Rakefile +0 -8
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +0 -4
- data/spec/dummy/app/jobs/application_job.rb +0 -4
- data/spec/dummy/app/mailers/application_mailer.rb +0 -6
- data/spec/dummy/app/models/application_record.rb +0 -5
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +0 -13
- data/spec/dummy/app/views/layouts/mailer.text.erb +0 -1
- data/spec/dummy/bin/bundle +0 -5
- data/spec/dummy/bin/rails +0 -6
- data/spec/dummy/bin/rake +0 -6
- data/spec/dummy/bin/setup +0 -39
- data/spec/dummy/bin/update +0 -31
- data/spec/dummy/bin/yarn +0 -13
- data/spec/dummy/config/cable.yml +0 -10
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environments/development.rb +0 -51
- data/spec/dummy/config/environments/production.rb +0 -84
- data/spec/dummy/config/environments/test.rb +0 -44
- data/spec/dummy/config/initializers/application_controller_renderer.rb +0 -7
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -7
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -6
- data/spec/dummy/config/initializers/inflections.rb +0 -17
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -16
- data/spec/dummy/config/locales/en.yml +0 -33
- data/spec/dummy/config/puma.rb +0 -58
- data/spec/dummy/config/routes.rb +0 -5
- data/spec/dummy/config/secrets.yml +0 -32
- data/spec/dummy/config/spring.rb +0 -8
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/package.json +0 -5
- data/spec/dummy/public/404.html +0 -67
- data/spec/dummy/public/422.html +0 -67
- data/spec/dummy/public/500.html +0 -66
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
data/lib/bemer/configuration.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'singleton'
|
4
|
+
require 'rails'
|
4
5
|
|
5
6
|
module Bemer
|
6
7
|
class Configuration
|
@@ -17,6 +18,7 @@ module Bemer
|
|
17
18
|
def initialize # rubocop:disable Metrics/MethodLength
|
18
19
|
@asset_paths = []
|
19
20
|
@bem = false
|
21
|
+
# Gem::Version.new('0.4.1') > Gem::Version.new('0.10.1')
|
20
22
|
@can_use_new_matcher = RUBY_VERSION >= '2.4.0'
|
21
23
|
@default_block_tag = :div
|
22
24
|
@default_element_tag = :div
|
@@ -30,7 +32,7 @@ module Bemer
|
|
30
32
|
end
|
31
33
|
|
32
34
|
def path
|
33
|
-
Rails.root.join(@path)
|
35
|
+
Rails.root ? Rails.root.join(@path) : @path
|
34
36
|
end
|
35
37
|
end
|
36
38
|
end
|
data/lib/bemer/entity.rb
CHANGED
@@ -50,8 +50,8 @@ module Bemer
|
|
50
50
|
|
51
51
|
attr_reader :css_classes, :html_attrs, :mixins, :modifiers
|
52
52
|
|
53
|
-
def extract_content(
|
54
|
-
block_given? ?
|
53
|
+
def extract_content(plain_content, &block)
|
54
|
+
block_given? ? block : plain_content
|
55
55
|
end
|
56
56
|
|
57
57
|
def extract_options!(options) # rubocop:disable Metrics/AbcSize
|
data/lib/bemer/entity_builder.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'active_support/core_ext/object/blank'
|
4
|
-
require 'active_support/core_ext/
|
4
|
+
require 'active_support/core_ext/string/filters'
|
5
5
|
|
6
6
|
module Bemer
|
7
7
|
class EntityBuilder < Entity
|
@@ -11,7 +11,7 @@ module Bemer
|
|
11
11
|
|
12
12
|
return attributes unless bem?
|
13
13
|
|
14
|
-
attributes.
|
14
|
+
attributes.merge!(js)
|
15
15
|
end
|
16
16
|
|
17
17
|
def attrs=(new_attrs, save = true)
|
@@ -36,16 +36,12 @@ module Bemer
|
|
36
36
|
bem_cascade_via_option? ? super : true
|
37
37
|
end
|
38
38
|
|
39
|
-
def bem_cascade=(new_bem_cascade, save = true)
|
40
|
-
save ? @bem_cascade = new_bem_cascade : new_bem_cascade
|
41
|
-
end
|
42
|
-
|
43
39
|
def cls
|
44
40
|
return super unless bem?
|
45
41
|
|
46
42
|
js_class = 'i-bem' if @js.present? && bem_class.present?
|
47
43
|
|
48
|
-
[bem_class, mods, mix, super, js_class].
|
44
|
+
[bem_class, mods, mix, super, js_class].join(' ').squish
|
49
45
|
end
|
50
46
|
|
51
47
|
def cls=(new_cls, save = true)
|
@@ -61,9 +57,9 @@ module Bemer
|
|
61
57
|
def js
|
62
58
|
return {} if @js.blank? || bem_class.blank?
|
63
59
|
|
64
|
-
|
60
|
+
js_attrs = @js.instance_of?(TrueClass) ? {} : super
|
65
61
|
|
66
|
-
{ data
|
62
|
+
{ 'data-bem': { name => js_attrs }.to_json }
|
67
63
|
end
|
68
64
|
|
69
65
|
def js=(new_js, save = true)
|
data/lib/bemer/helpers.rb
CHANGED
@@ -10,10 +10,12 @@ module Bemer
|
|
10
10
|
Bemer::Tag.new(block, element, options, &content).render
|
11
11
|
end
|
12
12
|
|
13
|
+
# Использовать mix
|
13
14
|
def bem_mix(*mix)
|
14
15
|
Bemer::MixinList.new(mix).to_s
|
15
16
|
end
|
16
17
|
|
18
|
+
# Использовать mods
|
17
19
|
def bem_mods(*block_and_element, mods)
|
18
20
|
block, element = *block_and_element
|
19
21
|
|
@@ -37,5 +39,13 @@ module Bemer
|
|
37
39
|
def component_pack(&block)
|
38
40
|
Bemer::ComponentPack.new(self).render(&block)
|
39
41
|
end
|
42
|
+
|
43
|
+
def component_asset_path(name)
|
44
|
+
Bemer::PathResolver.new(self).resolve(name)
|
45
|
+
end
|
46
|
+
|
47
|
+
def component_partial_path(name)
|
48
|
+
Bemer::PathResolver.new(self).resolve(name, true)
|
49
|
+
end
|
40
50
|
end
|
41
51
|
end
|
data/lib/bemer/mixin_list.rb
CHANGED
data/lib/bemer/modifier_list.rb
CHANGED
@@ -12,11 +12,11 @@ module Bemer
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def to_a
|
15
|
-
@
|
15
|
+
@to_a ||= to_h.map { |name, value| build_css_class(name, value) }
|
16
16
|
end
|
17
17
|
|
18
18
|
def to_s
|
19
|
-
@
|
19
|
+
@to_s ||= to_a.join(' ')
|
20
20
|
end
|
21
21
|
|
22
22
|
def to_h
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bemer
|
4
|
+
class PathResolver
|
5
|
+
def initialize(view)
|
6
|
+
@view = view
|
7
|
+
end
|
8
|
+
|
9
|
+
def resolve(name, partial = false)
|
10
|
+
virtual_path = view.instance_variable_get(:@virtual_path)
|
11
|
+
directory = [File.dirname(virtual_path)]
|
12
|
+
file_name = name.to_s
|
13
|
+
|
14
|
+
return file_name unless view.lookup_context.exists?(file_name, directory, partial)
|
15
|
+
|
16
|
+
File.join(directory, file_name).to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
protected
|
20
|
+
|
21
|
+
attr_reader :view
|
22
|
+
end
|
23
|
+
end
|
@@ -54,20 +54,18 @@ module Bemer
|
|
54
54
|
|
55
55
|
node.params.merge!(params)
|
56
56
|
|
57
|
-
|
57
|
+
template.nil? ? CommonTemplate.new(mode).apply!(node) : template.apply(node)
|
58
|
+
ensure
|
58
59
|
node.params = old_params
|
59
|
-
|
60
|
-
output
|
61
60
|
end
|
62
61
|
|
63
62
|
def apply_template!(mode, node)
|
64
63
|
node.applied_modes[mode] = true
|
65
64
|
template = find_template(mode, node)
|
66
|
-
output = template ? template.apply!(node) : nil
|
67
65
|
|
66
|
+
template ? template.apply!(node) : nil
|
67
|
+
ensure
|
68
68
|
disable_related_modes!(mode, node)
|
69
|
-
|
70
|
-
output
|
71
69
|
end
|
72
70
|
|
73
71
|
def disable_related_modes!(mode, node)
|
data/lib/bemer/railtie.rb
CHANGED
@@ -1,25 +1,38 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'rails/railtie'
|
4
|
+
require 'rails/version'
|
5
|
+
require 'active_support/lazy_load_hooks'
|
6
|
+
require 'action_controller/railtie'
|
7
|
+
|
3
8
|
module Bemer
|
4
9
|
class Railtie < ::Rails::Railtie
|
10
|
+
class << self
|
11
|
+
def assets_path_initializer
|
12
|
+
case ::Rails::VERSION::MAJOR
|
13
|
+
when 5 then :append_assets_path
|
14
|
+
when 3..4 then :load_config_initializers
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
5
19
|
config.eager_load_namespaces << Bemer if config.respond_to?(:eager_load_namespaces)
|
6
20
|
|
7
21
|
config.after_initialize do
|
8
|
-
|
9
|
-
|
22
|
+
paths = [Bemer.path, *Bemer.paths]
|
23
|
+
|
24
|
+
ActionController::Base.prepend_view_path(paths)
|
25
|
+
|
26
|
+
next unless defined?(ActionMailer::Base)
|
27
|
+
|
28
|
+
ActionMailer::Base.prepend_view_path(paths)
|
10
29
|
end
|
11
30
|
|
12
31
|
initializer 'bemer.helpers' do
|
13
32
|
ActiveSupport.on_load(:action_view) { include Bemer::Helpers }
|
14
33
|
end
|
15
34
|
|
16
|
-
|
17
|
-
case ::Rails::VERSION::MAJOR
|
18
|
-
when 5 then :append_assets_path
|
19
|
-
when 3..4 then :load_config_initializers
|
20
|
-
end
|
21
|
-
|
22
|
-
initializer 'bemer.prepend_asset_paths', group: :all, after: initializer_name do |app|
|
35
|
+
initializer 'bemer.prepend_asset_paths', group: :all, after: assets_path_initializer do |app|
|
23
36
|
next unless defined?(::Sprockets) && Bemer.prepend_asset_paths?
|
24
37
|
|
25
38
|
app.config.assets.paths.unshift(Bemer.path.to_s, *Bemer.asset_paths)
|
data/lib/bemer/renderer.rb
CHANGED
data/lib/bemer/template_list.rb
CHANGED
data/lib/bemer/tree.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'action_view/buffers'
|
4
4
|
require 'active_support/dependencies/autoload'
|
5
5
|
|
6
6
|
module Bemer
|
@@ -28,7 +28,7 @@ module Bemer
|
|
28
28
|
return unless block_given?
|
29
29
|
|
30
30
|
builder = Builders::Tree.new(self)
|
31
|
-
output =
|
31
|
+
output = ::ActionView::OutputBuffer.new
|
32
32
|
|
33
33
|
output << block.binding.receiver.capture(builder, &block)
|
34
34
|
output << render_root_nodes
|
@@ -86,7 +86,7 @@ module Bemer
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def render_root_nodes
|
89
|
-
output =
|
89
|
+
output = ::ActionView::OutputBuffer.new
|
90
90
|
position = 0
|
91
91
|
|
92
92
|
while position < root_nodes.length
|
data/lib/bemer/tree/node.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'action_view/buffers'
|
4
4
|
|
5
5
|
module Bemer
|
6
6
|
class Tree
|
@@ -48,11 +48,9 @@ module Bemer
|
|
48
48
|
old_parent_node = tree.parent_node
|
49
49
|
tree.parent_node = self
|
50
50
|
|
51
|
-
|
52
|
-
|
51
|
+
yield
|
52
|
+
ensure
|
53
53
|
tree.parent_node = old_parent_node
|
54
|
-
|
55
|
-
output
|
56
54
|
end
|
57
55
|
|
58
56
|
def print(level = 0)
|
@@ -74,7 +72,7 @@ module Bemer
|
|
74
72
|
protected
|
75
73
|
|
76
74
|
def capture_content
|
77
|
-
output =
|
75
|
+
output = ::ActionView::OutputBuffer.new
|
78
76
|
plain_text = replace_parent_and_execute { add_child_nodes } if need_add_child_nodes?
|
79
77
|
|
80
78
|
output << entity_builder.content if need_include_builder_content?
|
@@ -94,7 +92,7 @@ module Bemer
|
|
94
92
|
return if children.empty?
|
95
93
|
|
96
94
|
position = 0
|
97
|
-
output =
|
95
|
+
output = ::ActionView::OutputBuffer.new
|
98
96
|
|
99
97
|
replace_parent_and_execute do
|
100
98
|
while position < children.length
|
data/lib/bemer/version.rb
CHANGED
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe Bemer::Railtie do
|
4
|
+
def view_paths_for(klass)
|
5
|
+
klass.view_paths.map { |view_path| view_path.instance_variable_get(:@path) }
|
6
|
+
end
|
7
|
+
|
8
|
+
def find_initializer(name)
|
9
|
+
described_class.initializers.find { |initializer| initializer.name.eql?(name) }
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:assets_path_initializer_name) { ::Rails::VERSION::MAJOR.eql?(5) ? :append_assets_path : :load_config_initializers }
|
13
|
+
|
14
|
+
describe '.assets_path_initializer' do
|
15
|
+
it { expect(described_class.assets_path_initializer).to be(assets_path_initializer_name) }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.eager_load_namespaces' do
|
19
|
+
it { expect(described_class.config.eager_load_namespaces).to include(Bemer) if described_class.config.respond_to?(:eager_load_namespaces) }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'view paths' do
|
23
|
+
let(:view_path) { Rails.root.join('app', 'views').to_s }
|
24
|
+
let(:bemer_view_paths) { [Bemer.path, *Bemer.paths].map(&:to_s) }
|
25
|
+
let(:mailer_view_paths) { view_paths_for(ActionMailer::Base) }
|
26
|
+
let(:controller_view_paths) { view_paths_for(ActionController::Base) }
|
27
|
+
|
28
|
+
it { expect(controller_view_paths).to start_with(*bemer_view_paths, view_path) }
|
29
|
+
it { expect(mailer_view_paths).to start_with(*bemer_view_paths, view_path) }
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '.initializers' do
|
33
|
+
let(:initializer_names) { %w[bemer.helpers bemer.prepend_asset_paths bemer.assets_precompile] }
|
34
|
+
|
35
|
+
it { expect(described_class.initializers.map(&:name)).to match_array(initializer_names) }
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'bemer.helpers initializer' do
|
39
|
+
subject(:initializer) { find_initializer('bemer.helpers') }
|
40
|
+
|
41
|
+
let(:action_view) { ActionView::Base.new }
|
42
|
+
|
43
|
+
helper_methods = %i[
|
44
|
+
block_tag elem_tag bem_mix bem_mods render_component
|
45
|
+
refine_component define_templates define_component
|
46
|
+
component_pack component_asset_path component_partial_path
|
47
|
+
]
|
48
|
+
|
49
|
+
it { expect(initializer.after).to be_nil }
|
50
|
+
it { is_expected.not_to be_belongs_to(:all) }
|
51
|
+
|
52
|
+
helper_methods.each do |helper_method|
|
53
|
+
it { expect(action_view).to be_respond_to(helper_method) }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe 'bemer.prepend_asset_paths initializer' do
|
58
|
+
subject(:initializer) { find_initializer('bemer.prepend_asset_paths') }
|
59
|
+
|
60
|
+
let(:app) { Dummy::Application }
|
61
|
+
|
62
|
+
let(:asset_paths) do
|
63
|
+
assets_root = Rails.root.join('app', 'assets')
|
64
|
+
javascripts_path = assets_root.join('javascripts').to_s
|
65
|
+
stylesheets_path = assets_root.join('stylesheets').to_s
|
66
|
+
|
67
|
+
[Bemer.path.to_s, *Bemer.asset_paths, javascripts_path, stylesheets_path]
|
68
|
+
end
|
69
|
+
|
70
|
+
it { expect(initializer.after).to eql(assets_path_initializer_name) }
|
71
|
+
it { is_expected.to be_belongs_to(:all) }
|
72
|
+
it { expect(app.config.assets.paths).to start_with(*asset_paths) if defined?(::Sprockets) }
|
73
|
+
|
74
|
+
context 'when prepend_asset_paths is set to true' do
|
75
|
+
before { Bemer.config.prepend_asset_paths = true }
|
76
|
+
|
77
|
+
it { expect(initializer.run(app).uniq).to start_with(*asset_paths) if defined?(::Sprockets) }
|
78
|
+
it { expect(initializer.run(app)).to be_nil unless defined?(::Sprockets) }
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'when prepend_asset_paths is set to false' do
|
82
|
+
before { Bemer.config.prepend_asset_paths = false }
|
83
|
+
|
84
|
+
it { expect(initializer.run(app)).to be_nil }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe 'bemer.assets_precompile initializer' do
|
89
|
+
subject(:initializer) { find_initializer('bemer.assets_precompile') }
|
90
|
+
|
91
|
+
it { expect(initializer.after).to be :load_config_initializers }
|
92
|
+
it { is_expected.to be_belongs_to(:all) }
|
93
|
+
it { expect(Rails.application.config.assets.precompile[0].class).to be(Bemer::AssetMatcher) if ::Rails::VERSION::MAJOR < 4 && defined?(::Sprockets) }
|
94
|
+
end
|
95
|
+
end
|
@@ -2,26 +2,44 @@
|
|
2
2
|
|
3
3
|
require_relative 'boot'
|
4
4
|
|
5
|
-
# Pick the frameworks you want:
|
6
|
-
require 'active_record/railtie'
|
7
5
|
require 'action_controller/railtie'
|
8
6
|
require 'action_view/railtie'
|
9
7
|
require 'action_mailer/railtie'
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
#
|
8
|
+
|
9
|
+
begin
|
10
|
+
require 'sprockets/railtie'
|
11
|
+
rescue LoadError # rubocop:disable Lint/HandleExceptions
|
12
|
+
end
|
14
13
|
|
15
14
|
Bundler.require(*Rails.groups)
|
15
|
+
|
16
16
|
require 'bemer'
|
17
17
|
|
18
18
|
module Dummy
|
19
|
-
class Application < Rails::Application
|
20
|
-
|
21
|
-
|
19
|
+
class Application < ::Rails::Application
|
20
|
+
config.cache_classes = true
|
21
|
+
|
22
|
+
# Do not eager load code on boot. This avoids loading your whole application
|
23
|
+
# just for the purpose of running a single test. If you are using a tool that
|
24
|
+
# preloads Rails for running tests, you may have to set it to true.
|
25
|
+
config.eager_load = false
|
26
|
+
|
27
|
+
# Show full error reports and disable caching.
|
28
|
+
config.consider_all_requests_local = true
|
29
|
+
config.action_controller.perform_caching = false
|
30
|
+
|
31
|
+
# Raise exceptions instead of rendering exception templates.
|
32
|
+
config.action_dispatch.show_exceptions = false
|
33
|
+
|
34
|
+
# Disable request forgery protection in test environment.
|
35
|
+
config.action_controller.allow_forgery_protection = false
|
36
|
+
|
37
|
+
# Print deprecation notices to the stderr.
|
38
|
+
config.active_support.deprecation = :stderr
|
22
39
|
|
23
|
-
|
24
|
-
|
25
|
-
|
40
|
+
unless ENV['RAILS_ENABLE_TEST_LOG']
|
41
|
+
config.logger = Logger.new(nil)
|
42
|
+
config.log_level = :fatal
|
43
|
+
end
|
26
44
|
end
|
27
45
|
end
|