2019-08-16 20:09:33 +03:00
|
|
|
# frozen_string_literal: true
|
2020-06-22 16:31:07 +03:00
|
|
|
require "simplecov"
|
2020-07-27 23:46:40 +03:00
|
|
|
require "simplecov-console"
|
2020-06-22 16:31:07 +03:00
|
|
|
|
2020-09-22 01:56:14 +03:00
|
|
|
if ENV["MEASURE_COVERAGE"]
|
2020-09-22 01:54:36 +03:00
|
|
|
SimpleCov.start do
|
|
|
|
command_name "rails#{ENV["RAILS_VERSION"]}-ruby#{ENV["RUBY_VERSION"]}" if ENV["RUBY_VERSION"]
|
2020-08-22 01:23:38 +03:00
|
|
|
|
2020-09-22 01:54:36 +03:00
|
|
|
formatter SimpleCov::Formatter::Console
|
|
|
|
end
|
2020-06-22 16:31:07 +03:00
|
|
|
end
|
|
|
|
|
2019-08-16 20:09:33 +03:00
|
|
|
require "bundler/setup"
|
|
|
|
require "pp"
|
|
|
|
require "pathname"
|
|
|
|
require "minitest/autorun"
|
|
|
|
|
2020-07-02 09:39:25 +03:00
|
|
|
# Configure Rails Envinronment
|
|
|
|
ENV["RAILS_ENV"] = "test"
|
|
|
|
|
|
|
|
require File.expand_path("../config/environment.rb", __FILE__)
|
2019-08-16 20:09:33 +03:00
|
|
|
require "rails/test_help"
|
|
|
|
|
2020-05-06 07:17:44 +03:00
|
|
|
def with_preview_route(new_value)
|
|
|
|
old_value = Rails.application.config.view_component.preview_route
|
|
|
|
Rails.application.config.view_component.preview_route = new_value
|
|
|
|
app.reloader.reload!
|
|
|
|
yield
|
|
|
|
Rails.application.config.view_component.preview_route = old_value
|
|
|
|
app.reloader.reload!
|
2019-12-09 19:07:12 +03:00
|
|
|
end
|
2020-06-11 06:32:00 +03:00
|
|
|
|
|
|
|
def modify_file(file, content)
|
|
|
|
filename = Rails.root.join(file)
|
|
|
|
old_content = File.read(filename)
|
|
|
|
begin
|
|
|
|
File.open(filename, "wb+") { |f| f.write(content) }
|
|
|
|
yield
|
|
|
|
ensure
|
|
|
|
File.open(filename, "wb+") { |f| f.write(old_content) }
|
|
|
|
end
|
|
|
|
end
|
2020-04-18 06:05:53 +03:00
|
|
|
|
|
|
|
def with_default_preview_layout(layout)
|
|
|
|
old_value = ViewComponent::Base.default_preview_layout
|
|
|
|
ViewComponent::Base.default_preview_layout = layout
|
|
|
|
yield
|
|
|
|
ViewComponent::Base.default_preview_layout = old_value
|
|
|
|
end
|
2020-08-01 18:14:57 +03:00
|
|
|
|
|
|
|
def with_render_monkey_patch_config(enabled)
|
|
|
|
old_default = ViewComponent::Base.render_monkey_patch_enabled
|
|
|
|
ViewComponent::Base.render_monkey_patch_enabled = enabled
|
|
|
|
yield
|
|
|
|
ensure
|
|
|
|
ViewComponent::Base.render_monkey_patch_enabled = old_default
|
|
|
|
end
|