1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activesupport/test
Godfrey Chan debe7aedda Properly dump primitive-like AS::SafeBuffer strings as YAML
`coder.represent_scalar` means something along the lines of "Here is a quoted
string, you can just add it to the output", which is not the case here. It only
works for simple strings that can appear unquoted in YAML, but causes problems
for e.g. primitive-like strings ("1", "true").

`coder.represent_object` on the other hand, means that "This is the Ruby-object
representation for this thing suitable for use in YAML dumping", which is what
we want here.

Before:

   YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml  # => "Hello"
   YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml   # => true
   YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml  # => false
   YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml      # => 1
   YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml    # => 1.1

 After:

   YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml  # => "Hello"
   YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml   # => "true"
   YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml  # => "false"
   YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml      # => "1"
   YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml    # => "1.1"

If we ever want Ruby to behave more like PHP or JavaScript though, this is an
excellent trick to use ;)
2015-02-11 17:08:13 -08:00
..
autoloading_fixtures
core_ext Revert 88d08f2ec9 2015-02-11 17:32:18 -02:00
dependencies
deprecation
file_fixtures
fixtures
json
notifications
testing
xml_mini
abstract_unit.rb
autoload_test.rb
benchmarkable_test.rb
broadcast_logger_test.rb
caching_test.rb
callback_inheritance_test.rb
callbacks_test.rb
class_cache_test.rb
clean_backtrace_test.rb
clean_logger_test.rb
concern_test.rb
configurable_test.rb
constantize_test_cases.rb
dependencies_test.rb
dependencies_test_helpers.rb
deprecation_test.rb
descendants_tracker_test_cases.rb
descendants_tracker_with_autoloading_test.rb
descendants_tracker_without_autoloading_test.rb
file_update_checker_test.rb
gzip_test.rb
hash_with_indifferent_access_test.rb
i18n_test.rb
inflector_test.rb
inflector_test_cases.rb
key_generator_test.rb
lazy_load_hooks_test.rb
load_paths_test.rb
log_subscriber_test.rb
logger_test.rb
message_encryptor_test.rb
message_verifier_test.rb
multibyte_chars_test.rb
multibyte_conformance_test.rb
multibyte_proxy_test.rb
multibyte_test_helpers.rb
multibyte_unicode_database_test.rb
notifications_test.rb
number_helper_i18n_test.rb
number_helper_test.rb
option_merger_test.rb
ordered_hash_test.rb
ordered_options_test.rb
rescuable_test.rb
safe_buffer_test.rb Properly dump primitive-like AS::SafeBuffer strings as YAML 2015-02-11 17:08:13 -08:00
security_utils_test.rb
string_inquirer_test.rb
subscriber_test.rb
tagged_logging_test.rb
test_case_test.rb
time_travel_test.rb
time_zone_test.rb
time_zone_test_helpers.rb
transliterate_test.rb
xml_mini_test.rb Fixes wording of test description 2015-02-11 14:07:56 -05:00