view_component/test/test_helper.rb

29 строки
588 B
Ruby
Исходник Обычный вид История

2019-08-16 20:09:33 +03:00
# frozen_string_literal: true
require "bundler/setup"
require "pp"
require "pathname"
require "minitest/autorun"
# Configure Rails Envinronment
ENV["RAILS_ENV"] = "test"
require File.expand_path("../config/environment.rb", __FILE__)
require "rails/test_help"
def trim_result(content)
content = content.to_s.lines.collect(&:strip).join("\n").strip
doc = Nokogiri::HTML.fragment(content)
doc.xpath("//text()").each do |node|
if node.content.match?(/\S/)
node.content = node.content.gsub(/\s+/, " ").strip
else
node.remove
end
end
doc.to_s.strip
end