Skip to content

Instantly share code, notes, and snippets.

@micwoj92
Created February 26, 2025 20:57
Show Gist options
  • Save micwoj92/ed8b2c983e167f790f4bdfb83508945f to your computer and use it in GitHub Desktop.
Save micwoj92/ed8b2c983e167f790f4bdfb83508945f to your computer and use it in GitHub Desktop.
ruby-hashie-5.0.0-1-x86_64-check.log
/usr/bin/ruby -I/usr/lib/ruby/gems/3.3.0/gems/rspec-support-3.13.1/lib:/usr/lib/ruby/gems/3.3.0/gems/rspec-core-3.13.1/lib /usr/lib/ruby/gems/3.3.0/gems/rspec-core-3.13.1/exe/rspec --pattern spec/\*\*/\*_spec.rb --exclude-pattern spec/integration/\*\*/\*_spec.rb
/build/ruby-hashie/src/hashie-5.0.0/spec/hashie/extensions/symbolize_keys_spec.rb:4: warning: method redefined; discarding old invoke
/build/ruby-hashie/src/hashie-5.0.0/spec/hashie/extensions/stringify_keys_spec.rb:4: warning: previous definition of invoke was here
/build/ruby-hashie/src/hashie-5.0.0/lib/hashie/extensions/dash/property_translation.rb:132: warning: method redefined; discarding old config=
/build/ruby-hashie/src/hashie-5.0.0/lib/hashie/extensions/dash/property_translation.rb:132: warning: previous definition of config= was here
/build/ruby-hashie/src/hashie-5.0.0/lib/hashie/extensions/dash/property_translation.rb:132: warning: method redefined; discarding old first_name=
/build/ruby-hashie/src/hashie-5.0.0/lib/hashie/dash.rb:99: warning: previous definition of first_name= was here
Array
#dig
works with a string index
works with a numeric index
when array is empty
works with a first numeric and next string index
throws an error with first string and next numeric index
Hashie::Clash
is able to set an attribute via method_missing
is able to set multiple attributes
converts multiple arguments into an array
is able to use bang notation to create a new Clash on a key
is able to chain onto the new Clash when using bang notation
is able to jump back up to the parent in the chain with #_end!
merges rather than replaces existing keys
is able to replace all of its own keys with #replace
merges multiple bang notation calls
raises an exception when method is missing
when inherited
bang nodes are instances of a subclass
merged nodes are instances of a subclass
DashTestDefaultProc
to_json behaves correctly with default proc
DashTest
subclasses Hashie::Hash
lists all set properties in inspect
is expected to respond to #first_name
is expected to respond to #first_name=
is expected not to respond to #nonexistent
errors out for a non-existent property
errors out when attempting to set a required property to nil
errors out when message added to not required property
#to_s
is expected to eq "#<DashTest count=0 email=\"[email protected]\" first_name=\"Bob\">"
#count
is expected to be zero
writing to properties
fails writing a required property to nil
fails writing a required property to nil using []=
fails writing to a non-existent property using []=
works for an existing property using []=
works for an existing property using a method call
reading from properties
fails reading from a non-existent property using []
is able to retrieve properties through blocks
is able to retrieve properties through blocks with method calls
reading from deferred properties
evaluates proc after initial read
does not evalute proc after subsequent reads
reading from a deferred property based on context
provides the current hash as context for evaluation
converting from a Mash
without keeping the original keys
does not pick up the property from the stringified key
when keeping the original keys
picks up the property from the original key
#new
fails with non-existent properties
sets properties that it is able to
accepts nil
accepts block to define a global default
fails when required values are missing
does not overwrite default values
#merge
creates a new instance of the Dash
merges the given hash
fails with non-existent properties
errors out when attempting to set a required property to nil
given a block
sets merged key's values to the block's return value
#merge!
modifies the existing instance of the Dash
merges the given hash
fails with non-existent properties
errors out when attempting to set a required property to nil
given a block
sets merged key's values to the block's return value
properties
lists defined properties
checks if a property exists
checks if a property is required
doesnt include property from subclass
lists declared defaults
allows properties that end in bang
#replace
return self
sets all specified keys to their corresponding values
leaves only specified keys and keys with default values
when replacing keys with default values
sets all specified keys to their corresponding values
#update_attributes!(params)
update the attributes
when there is coercion
update the attributes
when required property is update to nil
raise an ArgumentError
when a default property is update to nil
set the property back to the default value
codependent attributes
does not raise an error when only the first property is set
does not raise an error when only the second property is set
does not raise an error when both properties are set
raises an error when neither property is set
exporting nil values
#to_h
does not prune nil values
#to_hash
does not prune nil values
**
prunes nil values because they are not set in the dash
Hashie::Dash inheritance
reports empty properties when nothing defined
inherits properties downwards
doesnt inherit properties upwards
allows overriding a default on an existing property
allows clearing an existing default
allows nil defaults
exporting nil values
#to_h
does not prune nil values
#to_hash
does not prune nil values
**
prunes nil values because they are not set in the dash
SubclassedTest
is expected to respond to #first_name
is expected to respond to #first_name=
is expected to respond to #last_name
is expected to respond to #last_name=
has one additional property
didn't override superclass inheritance logic
#count
is expected to be zero
ConditionallyRequiredTest
does not allow a conditionally required property to be set to nil if required
allows a conditionally required property to be set to nil if not required
allows a conditionally required property to be set if required
MixedPropertiesTest
is expected to respond to #string
is expected to respond to #symbol
property?
fetch
double define
assign
Dynamic Dash Class
define property
with method access
#test
is expected to eq "value"
#test?
is expected to eq true
Hashie::Dash
uses the default when initializing
allows you to set the value to nil with the hash writer
allows you to set the value to nil with the method writer
uses the default when updating with defaults
Hashie::Extensions
autloads constants
is expected to be const defined :MethodAccess
is expected to be const defined :Coercion
is expected to be const defined :DeepMerge
is expected to be const defined :IgnoreUndeclared
is expected to be const defined :IndifferentAccess
is expected to be const defined :MergeInitializer
is expected to be const defined :MethodAccess
is expected to be const defined :MethodQuery
is expected to be const defined :MethodReader
is expected to be const defined :MethodWriter
is expected to be const defined :StringifyKeys
is expected to be const defined :SymbolizeKeys
is expected to be const defined :DeepFetch
is expected to be const defined :DeepFind
is expected to be const defined :PrettyInspect
is expected to be const defined :KeyConversion
is expected to be const defined :MethodAccessWithOverride
Hashie::Extensions::Coercion
#coerce_key
is expected to be respond to :coerce_key
runs through coerce on a specified key
skips unnecessary coercions
supports an array of keys
supports coercion for Array
supports coercion for Set
supports coercion for Set of primitive
supports coercion for Hash
supports coercion for Hash with primitive as value
calls #new if no coerce method is available
coerces when the merge initializer is used
nesting
does not add coercions to superclass
coerces nested objects
coerces nested arrays
coerces nested hashes
when repetitively including the module
does not raise a stack overflow error
coercing core types
coerces from String to Integer via to_i
coerces from Integer to Integer via to_i
coerces from Rational to Integer via to_i
coerces from String to Float via to_f
coerces from Integer to Float via to_f
coerces from Rational to Float via to_f
coerces from String to String via to_s
coerces from Integer to String via to_s
coerces from Rational to String via to_s
coerces from String to String via to_s
coerces from Symbol to String via to_s
coerces from String to Symbol via to_sym
coerces from Symbol to Symbol via to_sym
can coerce String to Rational when possible
can coerce String to Complex when possible
coerces collections with core types
can coerce via a proc
raises errors for non-coercable types
can coerce false
does not coerce nil
when #replace is used
coerces relevant keys
sets correct values
when used with a Mash
coerces with instance initialization
coerces when setting with attribute style
coerces when setting with string index
coerces when setting with symbol index
when used with a Trash
coerces with instance initialization
when used with IndifferentAccess to coerce a Mash
coerces with instance initialization
coerces when setting with string index
coerces when setting with symbol index
when subclassing
inherits key coercions
the superclass does not accumulate coerced attributes from subclasses
when using circular coercion
with a proc on one side
coerces CategoryHash[:products] correctly
coerces ProductHash[:categories] correctly
without a proc on either side
fails with a NameError since the other class is not defined yet
#coerce_value
with strict: true
coerces any value of the exact right class
coerces values from a #replace call
does not coerce superclasses
core types
coerces String to Integer when possible
coerces non-numeric from String to Integer
raises a CoercionError when coercion is not possible
coerces Integer to String
coerces Numeric to String
can coerce via a proc
Hashie::Extensions::Dash::Coercion
does the coercion of properties
Hashie::Extensions::Dash::IndifferentAccess
updates
when included in Trash
gets the expected behaviour
when included in Dash
extends with the patch once
initialized with
string
key
initialized with both prefers last assignment
string, then symbol
symbol then string
Hashie::Extensions::Dash::PredefinedValues
allows value within the predefined list
rejects value outside the predefined list
accepts a range for predefined list
allows property to be nil
rejects non array or range for predefined list
passes property predefined list to subclasses
allows subclass to define predefined list
Hashie::Extensions::DeepFetch
#deep_fetch
extracts a value from a nested hash
extracts a value from a nested array
when one of the keys is not present
when a block is provided
returns the value of the block
when a block is not provided
when the nested object is an array
raises an UndefinedPathError
when the nested object is a hash
raises a UndefinedPathError
when the nested object is missing
raises an UndefinedPathError
when the nested object is nil
raises an UndefinedPathError
Hashie::Extensions::DeepFind
#deep_find
detects a value from a nested hash
detects a value from a nested array
returns nil if it does not find a match
#deep_find_all
detects all values from a nested hash
returns nil if it does not find any matches
when match value is hash itself
detects all values from a nested hash
on a Hash including Hashie::Extensions::IndifferentAccess
#deep_find
indifferently detects a value from a nested hash
indifferently detects a value from a nested array
indifferently returns nil if it does not find a match
#deep_find_all
indifferently detects all values from a nested hash
indifferently returns nil if it does not find any matches
Hashie::Extensions::DeepLocate
.deep_locate
locates enumerables for which the given comparator returns true for at least one element
returns an empty array if nothing was found
if called with a non-callable comparator
creates a key comparator on-th-fly
if extending an existing object
adds #deep_locate
if included in a hash
adds #deep_locate
Hashie::Extensions::DeepMerge
should return initial hash for arguments that are not hash
without &block
deep merges two hashes without modifying them
deep merges another hash in place via bang method
merges new nested hash entries by value, not by reference
with &block
deep merges two hashes
deep merges another hash in place via bang method
from extended object
does not raise error
deep merges two hashes
deep merges another hash in place via bang method
Hashie::Extensions::IgnoreUndeclared
included in Trash
silently ignores undeclared properties on initialization
works with translated properties (with symbol keys)
works with translated properties (with string keys)
requires properties to be declared on assignment
with a default value
uses the default when initializing
allows you to set the value to nil with the hash writer
allows you to set the value to nil with the method writer
uses the default when updating with defaults
combined with DeepMerge
deep merges
Hashie::Extensions::IndifferentAccess
#merge
indifferently merges in a hash
injects the resulting new Hash with IndifferentAccess
#merge!
indifferently merges in a hash
#to_hash
returns a normal hash without indifference
maintains the #default_proc when set
maintains the #default when set
when included in dash
initialize with a symbol
when overriding indifferent methods
#indifferent_writer
/build/ruby-hashie/src/hashie-5.0.0/spec/hashie/extensions/indifferent_access_spec.rb:124: warning: already initialized constant ALIASES
/build/ruby-hashie/src/hashie-5.0.0/spec/hashie/extensions/indifferent_access_spec.rb:124: warning: previous definition of ALIASES was here
#merge
when translating properties and ignoring undeclared
and the hash keys are strings
sets the property
and the hash keys are symbols
sets the property
and there are undeclared keys
sets the property
with merge initializer
it should behave like hash with indifferent access
is able to access via string or symbol
#values_at
indifferently finds values
returns the same instance of the hash that was set
returns the same instance of the array that was set
returns the same instance of the string that was set
returns the same instance of the object that was set
#fetch
works like normal fetch, but indifferent
returns the same instance of the hash that was set
returns the same instance of the array that was set
returns the same instance of the string that was set
returns the same instance of the object that was set
yields with key name if key does not exists
#delete
deletes indifferently
#key?
finds it indifferently
is aliased as include?
is aliased as member?
is aliased as has_key?
#update
allows keys to be indifferent still
recursively injects indifference into sub-hashes
does not change the ancestors of the injected object class
#replace
returns self
removes old keys
creates new keys with indifferent access
#try_convert
with conversion
is a subject
without conversion
is nil
#slice
indifferently slices the hash
#except
indifferently excepts keys from the hash
with array initializer
it should behave like hash with indifferent access
is able to access via string or symbol
#values_at
indifferently finds values
returns the same instance of the hash that was set
returns the same instance of the array that was set
returns the same instance of the string that was set
returns the same instance of the object that was set
#fetch
works like normal fetch, but indifferent
returns the same instance of the hash that was set
returns the same instance of the array that was set
returns the same instance of the string that was set
returns the same instance of the object that was set
yields with key name if key does not exists
#delete
deletes indifferently
#key?
finds it indifferently
is aliased as include?
is aliased as member?
is aliased as has_key?
#update
allows keys to be indifferent still
recursively injects indifference into sub-hashes
does not change the ancestors of the injected object class
#replace
returns self
removes old keys
creates new keys with indifferent access
#try_convert
with conversion
is a subject
without conversion
is nil
#slice
indifferently slices the hash
#except
indifferently excepts keys from the hash
with try convert initializer
it should behave like hash with indifferent access
is able to access via string or symbol
#values_at
indifferently finds values
returns the same instance of the hash that was set
returns the same instance of the array that was set
returns the same instance of the string that was set
returns the same instance of the object that was set
#fetch
works like normal fetch, but indifferent
returns the same instance of the hash that was set
returns the same instance of the array that was set
returns the same instance of the string that was set
returns the same instance of the object that was set
yields with key name if key does not exists
#delete
deletes indifferently
#key?
finds it indifferently
is aliased as include?
is aliased as member?
is aliased as has_key?
#update
allows keys to be indifferent still
recursively injects indifference into sub-hashes
does not change the ancestors of the injected object class
#replace
returns self
removes old keys
creates new keys with indifferent access
#try_convert
with conversion
is a subject
without conversion
is nil
#slice
indifferently slices the hash
#except
indifferently excepts keys from the hash
Hashie::Extensions::KeyConversion
is expected to respond to #stringify_keys
is expected to respond to #stringify_keys!
is expected to respond to #symbolize_keys
is expected to respond to #symbolize_keys!
Hashie::Extensions::Mash::DefineAccessors
when included in Mash subclass
this subclass
behaves like class with dynamically defined accessors
defines reader on demand
defines writer on demand
defines predicate on demand
defines initializing reader on demand
defines underbang reader on demand
when initializing from another hash
does not define any accessors
when accessors are overrided in class
W, [2025-02-26T20:56:30.418142 #960] WARN -- : You are setting a key that conflicts with a built-in method #<Class:0x0000674b272bf780>#foo defined at /build/ruby-hashie/src/hashie-5.0.0/spec/hashie/extensions/mash/define_accessors_spec.rb:61. This can cause unexpected behavior when accessing the key as a property. You can still access the key via the #[] method.
allows to call super
when Mash instance is extended
its singleton class
behaves like class with dynamically defined accessors
defines reader on demand
defines writer on demand
defines predicate on demand
defines initializing reader on demand
defines underbang reader on demand
when initializing from another hash
does not define any accessors
Hashie::Extensions::Mash::KeepOriginalKeys
keeps the keys in the resulting hash identical to the original
indifferently responds to keys
responds to all method accessors like a Mash
keeps the keys that are directly passed without converting them
Hashie::Extensions::Mash::PermissiveRespondTo
allows you to bind to unset getters
works properly with SimpleDelegator
warnings
does not log a collision when setting normal keys
logs a collision with a built-in method
Hashie::Extensions::Mash::SafeAssignment
when included in Mash
when not attempting to override a method
assigns just fine
when attempting to override a method
raises an error
when attempting to override a private method
raises an error
when attempting to initialize with predefined method
raises an error
when setting as a hash key
still raises if conflicts with a method
Hashie::Extensions::Mash::SymbolizeKeys
raises an error when included in a class that is not a Mash
when included in a Mash
symbolizes string keys in the Mash
preserves keys which cannot be symbolized
implicit to_hash on double splat
is converted on method calls
is converted on explicit operator call
Hashie::Extensions::MergeInitializer
initializes with no arguments
initializes with a hash
initializes with a hash and a default
Hashie::Extensions::MethodReader
reads string keys from the method
reads symbol keys from the method
reads nil and false values out properly
raises a NoMethodError for undefined keys
returns false for undefined keys if key with question has been called
returns true for defined keys if key with question has been called
#respond_to?
is true for string keys
is true for symbol keys
is false for non-keys
Hashie::Extensions::MethodWriter
writes from a method call
converts the key using the #convert_key method
raises NoMethodError on non equals-ending methods
#respond_to? correctly
Hashie::Extensions::MethodQuery
is true for non-nil string key values
is true for non-nil symbol key values
is false for false key values
is false for nil key values
raises a NoMethodError for non-set keys
#respond_to? for existing string keys
#respond_to? for existing symbol keys
does not #respond_to? for non-existent keys
Hashie::Extensions::MethodAccess
includes all of the other method mixins
Hashie::Extensions::MethodOverridingWriter
writes from a method call
convertes the key using the #convert_key method
raises NoMethodError on non equals-ending methods
#respond_to_missing? correctly
when writing a Hash method
overrides the original method
aliases the method with two leading underscores
does not re-alias when overriding an already overridden method
Hashie::Extensions::MethodAccessWithOverride
includes all of the other method mixins
Hashie::Extensions::MethodOverridingInitializer
when the key is a string
overrides the original method
aliases the method with two leading underscores
when the key is a symbol
overrides the original method
aliases the method with two leading underscores
Hashie::Extensions::StrictKeyAccess
.new
no defaults at initialization
behaves like StrictKeyAccess with valid key
set
returns value
access
returns value
lookup
returns key
behaves like StrictKeyAccess with invalid key
access
raises an error
lookup
raises an error
behaves like StrictKeyAccess raises KeyError instead of allowing defaults
#default
raises an error
#default=
raises an error
#default_proc
raises an error
#default_proc=
raises an error
with defaults at initialization
behaves like StrictKeyAccess with valid key
set
returns value
access
returns value
lookup
returns key
behaves like StrictKeyAccess with invalid key
access
raises an error
lookup
raises an error
behaves like StrictKeyAccess raises KeyError instead of allowing defaults
#default
raises an error
#default=
raises an error
#default_proc
raises an error
#default_proc=
raises an error
behaves like StrictKeyAccess with invalid key
access
raises an error
lookup
raises an error
behaves like StrictKeyAccess raises KeyError instead of allowing defaults
#default
raises an error
#default=
raises an error
#default_proc
raises an error
#default_proc=
raises an error
.[]
behaves like StrictKeyAccess with valid key
set
returns value
access
returns value
lookup
returns key
behaves like StrictKeyAccess with invalid key
access
raises an error
lookup
raises an error
behaves like StrictKeyAccess raises KeyError instead of allowing defaults
#default
raises an error
#default=
raises an error
#default_proc
raises an error
#default_proc=
raises an error
Hashie::Extensions::StringifyKeys
#stringify_keys!
converts keys to strings
converts nested instances of the same class
converts nested hashes
converts nested arrays
returns itself
class methods
.stringify_keys
converts keys to strings
does not alter the original
.stringify_keys!
converts keys to strings
converts nested instances of the same class
converts nested hashes
converts nested arrays
singleton methods
.stringify_keys
does not raise error
produces expected stringified hash
.stringify_keys!
does not raise error
produces expected stringified hash
Hashie
.stringify_keys
converts keys to strings
does not alter the original
.stringify_keys!
converts keys to strings
converts nested instances of the same class
converts nested hashes
converts nested arrays
Hashie::Extensions::SymbolizeKeys
#symbolize_keys!
converts keys to symbols
converts nested instances of the same class
converts nested hashes
performs deep conversion within nested arrays
returns itself
#symbolize_keys
converts keys to symbols
does not alter the original
class methods
.symbolize_keys
converts keys to symbols
does not alter the original
.symbolize_keys!
converts keys to symbols
converts nested instances of the same class
converts nested hashes
performs deep conversion within nested arrays
singleton methods
.symbolize_keys
does not raise error
produces expected symbolized hash
.symbolize_keys!
does not raise error
produces expected symbolized hash
Hashie
.symbolize_keys
converts keys to symbols
does not alter the original
.symbolize_keys!
converts keys to symbols
converts nested instances of the same class
converts nested hashes
performs deep conversion within nested arrays
Hash
is convertible to a Hashie::Mash
#stringify_keys! turns all keys into strings
#stringify_keys! turns all keys into strings recursively
#stringify_keys returns a hash with stringified keys
#to_hash returns a hash with same keys
#to_hash with stringify_keys set to true returns a hash with stringified_keys
#to_hash with symbolize_keys set to true returns a hash with symbolized keys
#to_hash should not blow up when #to_hash doesn't accept arguments
when the value is an object that respond_to to_hash
#to_hash returns a hash with same keys
#to_hash with stringify_keys set to true returns a hash with stringified_keys
#to_hash with symbolize_keys set to true returns a hash with symbolized keys
Hashie::Mash
inherits from Hash
sets hash values through method= calls
retrieves set values through method calls
retrieves set values through blocks
retrieves set values through blocks with method calls
tests for already set values when passed a ? method
returns false on a ? method if a value has been set to nil or false
makes all [] and []= into strings for consistency
has a to_s that is identical to its inspect
returns nil instead of raising an error for attribute-esque method calls
returns the default value if set like Hash
gracefully handles being accessed with arguments
maintains indifferent access when nested
returns a Hashie::Mash when passed a bang method to a non-existenct key
returns the existing value when passed a bang method for an existing key
returns a Hashie::Mash when passed an under bang method to a non-existenct key
returns the existing value when passed an under bang method for an existing key
#initializing_reader returns a Hashie::Mash when passed a non-existent key
allows for multi-level assignment through bang methods
allows for multi-level under bang testing
does not call super if id is not a key
returns the value if id is a key
does not call super if type is not a key
returns the value if type is a key
logs a warning when overriding built-in methods (FAILED - 1)
can set keys more than once and does not warn when doing so
does not write to the logger when warnings are disabled
does not write to the logger when setting most affixed keys
warns when setting a key that looks like a setter
cannot disable logging on the base Mash
carries over the disable for warnings on grandchild classes
writes to logger when a key is overridden that is not ignored
does not write to logger when a key is overridden that is ignored
carries over the ignored warnings list for warnings on grandchild classes
converts hash assignments into Hashie::Mashes
does not convert the type of Hashie::Mashes childs to Hashie::Mash
does not change the class of Mashes when converted
respects the class when passed a bang method for a non-existent key
respects the class when passed an under bang method for a non-existent key
respects the class when converting the value
respects another subclass when converting the value
multiple disable_warnings calls
calling disable_warnings multiple times with parameters
appends each new parameter to the ignore list
calling disable_warnings without keys after calling with keys
uses the last call to determine the ignore list
calling disable_parameters with keys after calling without keys
only ignores logging for ignored methods
updating
#deep_update
recursively Hashie::Mash Hashie::Mashes and hashes together
converts values only once
makes #update deep by default
clones before a #deep_merge
default #merge is deep
accepts a block
copies values for non-duplicate keys when a block is supplied
does not raise an exception when default_proc raises an error
shallow update
shallowly Hashie::Mash Hashie::Mashes and hashes together
clones before a #regular_merge
default #merge is shallow
#replace
returns self
sets all specified keys to their corresponding values
leaves only specified keys
delete
deletes with String key
deletes with Symbol key
#respond_to?
responds to a normal method
responds to a set key
responds to a set key with a suffix
is able to access the suffixed key as a method
responds to an unknown key with a suffix
is able to access an unknown suffixed key as a method
does not respond to an unknown key without a suffix
#initialize
converts an existing hash to a Hashie::Mash
converts hashes recursively into Hashie::Mashes
converts hashes in arrays into Hashie::Mashes
converts an existing Hashie::Mash into a Hashie::Mash
accepts a default block
allows propagation of a default block
allows assignment of an empty array in a default block
allows assignment of a non-empty array in a default block
allows assignment of an empty hash in a default block
allows assignment of a non-empty hash in a default block
converts Hashie::Mashes within Arrays back to Hashes
only stringifies keys which can be converted to symbols
preserves keys which cannot be converted to symbols
#fetch
when key exists
returns the value
returns the value even if the value is falsy
when key has other than original but acceptable type
returns the value
when key does not exist
raises KeyError
with default value given
returns default value
returns default value even if it is falsy
with block given
returns default value
#to_hash
returns a standard Hash
includes all keys
converts keys to symbols when symbolize_keys option is true
leaves keys as strings when symbolize_keys option is false
symbolizes keys recursively
#stringify_keys
turns all keys into strings recursively
#values_at
when the original type is given
returns the values
when a different, but acceptable type is given
returns the values
when a key is given that is not in the Mash
returns nil for that value
.load(filename, options = {})
if the file exists
is expected to be a kind of Hashie::Mash
return a Mash from a file
freeze the attribtues
if the fils does not exists
raise an ArgumentError
if the file is passed as Pathname
return a Mash from a file
results are cached
cache the loaded yml file
when the file has aliases in it
can use the aliases and does not raise an error
can override the value of aliases (FAILED - 2)
when the file has symbols
can override the value of permitted_classes
uses defaults for permitted_classes
can override the value of permitted_symbols
raises an error on insufficient permitted_symbols
#to_module(mash_method_name)
defines a settings method on the klass class that extends the module
when a settings_method_name is set
defines a settings method on the klass class that extends the module
#reverse_merge
unifies strings and symbols
does not overwrite values
when using with subclass
creates an instance of subclass
#invert
returns a Hashie::Mash
returns a mash with the keys and values inverted
when using with subclass
creates an instance of subclass
#reject
returns a Hashie::Mash
rejects keys for which the block returns true
when using with subclass
creates an instance of subclass
#select
returns a Hashie::Mash
selects keys for which the block returns true
when using with subclass
creates an instance of subclass
.quiet
returns a subclass of the calling class
memoizes and returns classes
#dig
accepts both string and symbol as key
when the Mash wraps a Hashie::Array
handles digging into an array
#transform_values
returns a Hashie::Mash
transforms the value
when using with subclass
creates an instance of subclass
#compact
returns a Hashie::Mash
removes keys with nil values
when using with subclass
creates an instance of subclass
#slice
returns a Hashie::Mash
returns a Mash with only the keys passed
when using with subclass
creates an instance of subclass
#transform_keys
returns a Hashie::Mash
returns a Mash with transformed keys
when using with subclass
creates an instance of subclass
ruby 2.6 merging
merges multiple hashes and mashes passeed to #merge
#except
return a Hashie::Mash
excludes keys
Hashie::Extensions::Parsers::YamlErbParser
.perform
a file
is expected to be a kind of Hash
parses YAML after interpolating ERB
Pathname
"#perform" can be done in case of path is a Pathname object.
Hashie::Rash
finds strings
finds regexps
finds other objects
finds numbers from ranges
finds floats from ranges
evaluates proc values
finds using the find method
raises in find unless a key matches
yields in find unless a key matches
gives a default value
responds to hash methods
does not lose keys
Hashie::Trash
raises an error when :from have the same value as property
translating properties
adds the property to the list
creates a method for reading the property
creates a method for writing the property
creates a method for writing the translated property
does not create a method for reading the translated property
maintains translations hash mapping from the original to the translated name
maintains inverse translations hash mapping from the translated to the original name
#permitted_input_keys contain the :from key of properties with translations
standard properties
#permitted_input_keys contain names of properties without translations
writing to properties
does not write to a non-existent property using []=
writes to an existing property using []=
writes to a translated property using []=
reads/writes to an existing property using a method call
writes to an translated property using a method call
writes to a translated property using #replace
writes to a non-translated property using #replace
initializing with a Hash
does not initialize non-existent properties
sets the desired properties
sets the translated properties
with both the translated property and the property
sets the desired properties
translating properties using a proc
translates the value given on initialization with the given lambda
does not translate the value if given with the right property
translates the value given as property with the given lambda
does not translate the value given as right property
translating multiple properties using a proc
translates the first key
translates the second key
maintains translations hash mapping from the original to the translated name
translating multiple properties from the same source hash key
translates the first key with the given lambda
translates the second key with the given lambda and the initial value of the first key
uses with or transform_with interchangeably
translates the value given as property with the given lambda
does not translate the value given as right property
translating properties without from option using a proc
translates the value given as property with the given lambda
transforms the value when given in constructor
when :from option is given
does not override the :from option in the constructor
does not override the :from option when given as property
inheritable transforms
inherit properties transforms
replaces property transform
inheritable translations
inherit properties translations
when subclassing
keeps translation definitions in subclasses
when copying properties from other properties
/build/ruby-hashie/src/hashie-5.0.0/lib/hashie/extensions/dash/property_translation.rb:132: warning: method redefined; discarding old id=
/build/ruby-hashie/src/hashie-5.0.0/lib/hashie/dash.rb:99: warning: previous definition of id= was here
retains the original and also sets the copy
/build/ruby-hashie/src/hashie-5.0.0/lib/hashie/extensions/dash/property_translation.rb:132: warning: method redefined; discarding old id=
/build/ruby-hashie/src/hashie-5.0.0/lib/hashie/dash.rb:99: warning: previous definition of id= was here
grabs the default for the original if it is not set
/build/ruby-hashie/src/hashie-5.0.0/lib/hashie/extensions/dash/property_translation.rb:132: warning: method redefined; discarding old id=
/build/ruby-hashie/src/hashie-5.0.0/lib/hashie/dash.rb:99: warning: previous definition of id= was here
can be a required value
does not set properties that do not exist
is not order-dependent in definition
Hashie::Utils
.method_information
states the module or class that a native method was defined in (FAILED - 3)
states the line a Ruby method was defined at
Hashie
has a version
Hashie
.logger
is available via an accessor
Failures:
1) Hashie::Mash logs a warning when overriding built-in methods
Failure/Error: expect(logger_output).to match('Hashie::Mash#trust')
expected "" to match "Hashie::Mash#trust"
Shared Example Group: "with a logger" called from ./spec/hashie/mash_spec.rb:138
# ./spec/hashie/mash_spec.rb:142:in `block (3 levels) in <top (required)>'
# ./spec/support/logger.rb:21:in `block (2 levels) in <top (required)>'
# ./spec/support/logger.rb:21:in `block (2 levels) in <top (required)>'
2) Hashie::Mash.load(filename, options = {}) when the file has aliases in it can override the value of aliases
Failure/Error:
expect do
Hashie::Mash.load('spec/fixtures/yaml_with_aliases.yml', aliases: false)
end.to raise_error Psych::BadAlias, /base_accounts/
expected Psych::BadAlias with message matching /base_accounts/, got #<Psych::AliasesNotEnabled: Alias parsing was not enabled. To enable it, pass `aliases: true` to `Psych::load` or `Psych::safe_load`.> with backtrace:
# ./lib/hashie/extensions/parsers/yaml_erb_parser.rb:33:in `yaml_safe_load'
# ./lib/hashie/extensions/parsers/yaml_erb_parser.rb:22:in `perform'
# ./lib/hashie/extensions/parsers/yaml_erb_parser.rb:26:in `perform'
# ./lib/hashie/mash.rb:78:in `load'
# ./spec/hashie/mash_spec.rb:826:in `block (5 levels) in <top (required)>'
# ./spec/hashie/mash_spec.rb:825:in `block (4 levels) in <top (required)>'
# ./spec/support/logger.rb:21:in `block (2 levels) in <top (required)>'
# ./spec/support/logger.rb:21:in `block (2 levels) in <top (required)>'
# ./spec/hashie/mash_spec.rb:825:in `block (4 levels) in <top (required)>'
# ./spec/support/logger.rb:21:in `block (2 levels) in <top (required)>'
# ./spec/support/logger.rb:21:in `block (2 levels) in <top (required)>'
3) Hashie::Utils.method_information states the module or class that a native method was defined in
Failure/Error: bound_method = method(:trust)
NameError:
undefined method `trust' for class `#<Class:#<RSpec::ExampleGroups::HashieUtils::MethodInformation:0x0000674b2765fae8>>'
# ./spec/hashie/utils_spec.rb:10:in `method'
# ./spec/hashie/utils_spec.rb:10:in `block (3 levels) in <top (required)>'
Finished in 0.1896 seconds (files took 0.20311 seconds to load)
700 examples, 3 failures
Failed examples:
rspec ./spec/hashie/mash_spec.rb:139 # Hashie::Mash logs a warning when overriding built-in methods
rspec ./spec/hashie/mash_spec.rb:824 # Hashie::Mash.load(filename, options = {}) when the file has aliases in it can override the value of aliases
rspec ./spec/hashie/utils_spec.rb:9 # Hashie::Utils.method_information states the module or class that a native method was defined in
/usr/bin/ruby -I/usr/lib/ruby/gems/3.3.0/gems/rspec-support-3.13.1/lib:/usr/lib/ruby/gems/3.3.0/gems/rspec-core-3.13.1/lib /usr/lib/ruby/gems/3.3.0/gems/rspec-core-3.13.1/exe/rspec --pattern spec/\*\*/\*_spec.rb --exclude-pattern spec/integration/\*\*/\*_spec.rb failed
==> ERROR:(B A failure occurred in check().(B
 Aborting...(B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment