Commit Graph

23 Commits

Author SHA1 Message Date
Michael Herold f152e25912
Fix inconsistencies with Dash defaults
The normal behavior of Dash with respect to property defaults differed
from the behavior of a Dash/Trash with IgnoreUndeclared mixed in. This
is because some situations called the defaults and some did not.

This change normalizes the behavior so that all situations where the
defaults should be used to override unset values behave consistently,
as well as all situations where the default should not override a `nil`
value.
2020-10-23 21:57:10 -05:00
kenner kliemann 4759e049ae require json at spec_helper to fix #532 2020-10-05 10:10:00 -03:00
Michael Herold eb69c58b62
Don't warn when setting most affixed keys (#500)
Due to how we have implemented the bang/underbang/query behavior within
Mash, setting keys that have those affixes in them actually allow
overwriting the behavior of those affixes. As such, we shouldn't warn
when setting a key that matches those patterns.

When it comes to setter-like keys, I believe we still _do_ want to warn
for two reasons:

1. Trying to access the key via method access is a syntax error. Ruby
   expects any method ending in `=` to be a 2+-arity method due to the
   infix notation of setter methods. This is unexpected behavior unless
   you're very familiar with Ruby parsing.
2. You can still retrieve the key via the normal `Hash#[]` reader, but
   it prevents setting a similar key without the equal sign. You can see
   this in the test about setters. I'd say that is unexpected and
   surprising behavior.

Because of these two gotchas, I think we should still warn in cases
where you try to set a key that looks like a setter.
2020-01-15 13:17:27 -06:00
Bobby McDonald 25fe2f747e Fix except use in Mash#load (#508) 2020-01-14 08:50:43 -05:00
Alexandre Filipe Campos 9f965feb37 Fix "@disable_warnings" spec warning (#416)
When running rspec specs on the ruby-grape project with warnings enabled
this warning is printed hundreds of times.

This change fixes the warning.

Also, turn on warnings when running rspec to see when this happens.
2017-03-01 06:13:50 -06:00
Michael Herold b2f94a4866 Allow Mash subclasses to disable warnings
Since we are transitively used as a dependency in many projects, we
should have given the ability to toggle this behavior off. The logging
feature is more of a "help people get started with Mash" feature. If
you're using Hashie in a library, it's likely that you already know the
tradeoffs of attempting to override methods on the object.

To use this feature, you only have to subclass Mash and then call the
class method:

```ruby
class KeyStore < Hashie::Mash
  disable_warnings
end
```
2017-02-04 14:38:00 -06:00
Paul Bowsher a59592e032 Update to CodeClimate 1.0.x
CodeClimate > 1.0 uses SimpleCov and requires the test reporter to be
called explicitly:

https://github.com/codeclimate/ruby-test-reporter/blob/master/CHANGELOG.
md#v100-2016-11-03
2016-12-04 15:24:58 +00:00
sazor 453ae843d4 Evaluate procs default values in object initialization 2016-10-31 09:56:09 +03:00
Joe Van Dyk 018551cfd0 failing test for Dash default with proc not working with AS as_json 2016-10-28 11:57:12 +03:00
jonathan schatz fa524096f3 Fix support for Array#dig 2016-06-01 14:53:29 -07:00
Peter Boling 43d86f1c52 @dblock
- a one liner with no complexity for pending specs by Ruby Engine / Version
- removes all complexity from Hashie
2015-10-22 02:07:21 -07:00
Bartosz Kopiński 60b8e803d0 Code coverage reporting 2014-11-27 07:09:36 +01:00
Michael Herold a3208c4a11 Add simple RSpec.configure block for expect syntax
Without the configure block, [mutant][mutant] was raising an error. I'm
interested in mutation testing our test suite, so thought this would be
the simplest thing to add to get that working. It also enforces the
expect syntax, which is a nice side benefit.

[mutant]: https://github.com/mbj/mutant
2014-09-07 19:59:38 -05:00
Michael Herold 783a989ec2 Don't require rubygems in spec_helper 2014-09-06 16:16:36 -05:00
Michael Herold f33111d576 Remove lines adding lib to the load path
RSpec does this automatically now.
2014-09-06 16:12:14 -05:00
Michael Herold 3aa8834e23 Add pry and pry-stack_explorer for debugging 2014-08-24 11:59:51 -05:00
dblock 2c8d5d56ed Upgraded to RSpec 3.0. 2014-06-03 09:35:55 -07:00
dblock 6dec18c47d Present tense for specs. 2014-04-06 15:09:37 -04:00
Michael Bleigh 9192a26828 Trying to fix up specs for multi-rubies. 2011-07-28 23:32:57 -05:00
Michael Bleigh 7665f687d9 Update to RSpec 2.0 2011-01-27 08:20:39 -06:00
Daniel Neighman 0c85e9482f Adds a fix for json generation 2010-06-22 22:00:39 +08:00
Michael Bleigh fc03a24666 All specs are passing again after fixing a namespacing issue. 2009-09-06 00:27:54 -04:00
Michael Bleigh a7781d369a Initial commit to hashie. 2009-09-02 21:32:57 -04:00