Class: FactoryBotFactory::Converters::HashConverter
- Inherits:
-
Object
- Object
- FactoryBotFactory::Converters::HashConverter
- Defined in:
- lib/factory_bot_factory/converters/hash_converter.rb
Constant Summary collapse
- EMPTY_PAIR_REGEX =
/(?<content>"(?:[^\\"]|\\.)+")|(?<open>\{)\s+(?<close>\})|(?<open>\[)\s+(?<close>\])/m
Class Method Summary collapse
Class Method Details
.call(key, value, options = {}) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/factory_bot_factory/converters/hash_converter.rb', line 6 def self.call(key, value, = {}) value = value.to_h if value.is_a?(OpenStruct) value = JSON .pretty_generate(value) .gsub(EMPTY_PAIR_REGEX, '\k<open>\k<content>\k<close>') .split("\n") end |