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
|
|
|
|
|
|
|
SimpleCov.start do
|
2020-07-27 23:46:40 +03:00
|
|
|
formatter SimpleCov::Formatter::Console
|
2020-06-22 16:31:07 +03:00
|
|
|
end
|
|
|
|
|
2020-07-28 00:02:08 +03:00
|
|
|
if ENV["RAILS_VERSION"] != "master"
|
2020-07-27 23:56:29 +03:00
|
|
|
SimpleCov.minimum_coverage 100
|
|
|
|
end
|
2020-06-22 16:31:07 +03:00
|
|
|
|
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
|