summaryrefslogtreecommitdiff
path: root/spec/unit/node
Commit message (Collapse)AuthorAgeFilesLines
* Compensate for libyaml changes in yaml parsing test.fix-test-yaml-diffsPete Higgins2020-07-281-2/+6
| | | | Signed-off-by: Pete Higgins <pete@peterhiggins.org>
* Get lib/ free of spelling violations.Pete Higgins2020-05-181-1/+1
| | | | Signed-off-by: Pete Higgins <pete@peterhiggins.org>
* Remove copyright dateslcg/remove-copyright-datesLamont Granquist2020-04-133-3/+3
| | | | | | | | Legally incredibly dubious, particularly since we don't follow it strictly as policy, and we have git history instead, which does it right. This is just a waste of time and a cargo cult. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* some spec typosVivek Singh2020-04-071-1/+1
| | | | Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
* Fix most Ruby 2.7 test failureslcg/ruby-2.7.0Lamont Granquist2020-01-211-3/+3
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Specify item path in Node.read! error messageZeust the Unoobian2019-12-091-3/+3
| | | | Obvious fix.
* Refactor the specs with shared_examplesVivek Singh2019-09-282-170/+92
| | | | | - Add specs for Node::Attribute to_json & to_yaml methods. Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
* Override the #to_yaml method for ImmutableMash & ImmutableArray  Vivek Singh2019-09-271-0/+28
| | | | | | |  - Psych module to_yaml not working as expected for ImmutableMash & ImmutableArray.  - So parse first to Hash/Array then convert it to YAML formatted string. Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
* Style/EmptyLiteralLamont Granquist2019-07-051-7/+7
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix more Style/SymbolArray autocorrect bugsLamont Granquist2019-07-021-3/+3
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Style/SymbolArrayLamont Granquist2019-07-022-51/+51
| | | | | | start enforcing using %i{} instead of arrays of symbols Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix Layout/AlignArgumentslcg/new-chefstyleLamont Granquist2019-07-021-4/+4
| | | | | | | | | | | | | | this is using: Layout/AlignArguments: Enabled: true EnforcedStyle: with_fixed_indentation the default style can use really excessive whitespace. on starting lines which are already long, it fully indents across to where the arguments start and then begins the line there. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fixes for chefstyle bumpLamont Granquist2019-07-021-3/+3
| | | | | | | | result of automation https://github.com/chef/chefstyle/pull/72 Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Remove checks for old versions of RubyTim Smith2019-02-281-9/+3
| | | | | | Some of this supports older versions of Ruby 2.1/2.2 and others support Ruby 1.8 Signed-off-by: Tim Smith <tsmith@chef.io>
* changes for rubocop engine upgrades.lcg/rubocop-upgradesLamont Granquist2019-01-151-69/+69
| | | | | | | this is the result of changes to rules we already previously had enabled. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Chef-15: add nillability to attribute deep mergingLamont Granquist2018-11-091-0/+30
| | | | | | | | | | Changes to consistently uses the "NIL" object internally to mean "not present" instead of abusing nil for that purpose. So now "nil means nil" and we can deep merge that so it will effectively override lower precedence levels if you write a nil. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Chef 15 node attribute array fixeslcg/chef-15-attribute-array-fixesLamont Granquist2018-10-312-2/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | Doing something like: ``` node.default["foo"] = [] node.default["foo"] << { "bar" => "baz } ``` Would result in a Hash instead of a VividMash inserted into the AttrArray, so that: ``` node.default["foo"][0]["bar"] # gives the correct result node.default["foo"][0][:bar] # does not work due to the sub-Hash not # converting keys ``` This fixes that behavior, but is likely a breaking change to someone who expects to ingest hashes with symbol keys and get back out symbol keys, they will now get converted to strings. This breaking change is fully 100% intentional. This makes the node attribute structure more consistent and predictable. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix Style/PreferredHashMethodsLamont Granquist2018-07-021-7/+7
| | | | | | | absolutely hard requirement on the fixes that went into chef-config 2.2.11, so the floor of that gem is bumped up. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix Style/HashSyntaxLamont Granquist2018-07-022-6/+6
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Revert "Per-container deep merge caching"lcg/revert-lazy-attributesLamont Granquist2018-02-233-111/+47
| | | | This reverts commit 0c29acc106ca774e230c8ef45694c8bffd166b69.
* Revert "remove more debugging and revert no-longer necessary fix"Lamont Granquist2018-02-231-2/+4
| | | | This reverts commit 80b9d0448d9fb01a7188cbee6c9595bf0cf5b974.
* Revert "fix node assignment of ImmutableArrays to VividMashes/AttrArrays"Lamont Granquist2018-02-231-15/+0
| | | | This reverts commit e56f8d58b80334256085907961aac9ca9f56f125.
* fix node assignment of ImmutableArrays to VividMashes/AttrArraysLamont Granquist2018-01-251-0/+15
| | | | | | | | | | | | | node.default['foo'] = node['bar'] need to have node['bar'] have its cache vivified otherwise we potentially get an empty hash or array. in the case of hashes, the assignment must have been walking though the values with #each or something which poked the cache on the target hash which caused it to vivify, so this bug only affected Arrays where the AttrArray initializer likely did a quick-n-dirty copy of the internal structure of the ImmutableArray which was empty. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* update immutable API blacklist and whitelistLamont Granquist2018-01-231-1/+11
| | | | | | | | | | | | | adds the whitelist so that when we update to new ruby versions it forces us to audit the new Array and Hash methods and figure out if they are mutators or not. this change closes the Hash#store loophole that was being abused by some cookbook consumers to directly modify merged ImmutableHashes (producing inherently undefined behavior that we 'broke' at one point). Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* prepping for rubocop 0.52.1lcg/rubocop-0.52.1Lamont Granquist2018-01-171-3/+3
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* remove more debugging and revert no-longer necessary fixLamont Granquist2017-12-061-4/+2
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Per-container deep merge cachingLamont Granquist2017-12-063-47/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replaces the one-big top level deep merge cache with individual deep merge caches in every container. The Immutable container state becomes the deep merge cache. - Does not use a pure decorator style approach since that failed before because of ruby internals breaking things like `===` and `=~` on decorated objects, so we inherit (ultimately from Hash + Array). - The state being the container state is useful in ruby since APIs on Hash and Array poke around in internal state to make things fast. If we inherit from Hash/Array but don't have the correct internal state things go wonky. - Throwing away the internal state is equivalent to flushing the cache. - Since we throw away all linked objects when we do that, we flush at every level below the level being flushed (which is correct semantics). - If a user has a pointer to an old immutable object from a sub-level, that isn't mutated so the old object still contains the old view of the data (which I think is correct, although I have some doubts that its necessary, but it came along free for the ride). - When we reset the cache we do mutate the cache being reset, which might change data in held references. If this becomes an issue the fix would be to reset the cache at the level above by creating a new, "empty" ImmutableHash/ImmutableArray object and inserting it into the deep_merge_cache datastructure instead of clearing the internal state of the child object. I don't know practically how anyone would hit this, though, so would prefer to wait on doing that work until we see an actual bug report. - Because of the way ruby pokes around internally there's some weirdnesses like the pre-generation of the cache for all the values of a subarray when #each is called, which is due to the way that ruby walks through array-serialized hashes when called like: `Array#each { key, value| ... }` (which is an undocumented(?) thing in ruby). Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* missing spec fixlcg/immutablize-speedupLamont Granquist2017-08-281-1/+1
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* speed up immutabilizationLamont Granquist2017-08-281-3/+11
| | | | | | since we only inject Mash/VividMashes do not convert Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix node#debug_value access through arrayslcg/debub-value-arraysLamont Granquist2017-03-161-3/+20
| | | | | | nod to @jaymzh for finding this one. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Chef-13 freeze merged node attributelcg/node-freezeLamont Granquist2017-03-151-0/+12
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* additional fix deep-duping as welllcg/deep-dup-attrsLamont Granquist2017-03-132-0/+70
| | | | | | | | | similarly to fixing to_hash. kind of feels like we should return a VividMash instead of a Mash here, to get a writable thing that behaves like an attribute... Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Chef-13: properly deep dup Node#to_hashLamont Granquist2017-03-132-3/+62
| | | | | | | | | | | | previously to_hash allowed mutating non-container elements, now they get properly dup'd. fixes a 2.5 year old pending spec test. also fills out the API so that there is to_h/to_hash/to_a/to_array instead of the weird mix-and-match we had before. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Chef-13: remove method_missing access to node object.Lamont Granquist2017-03-131-28/+5
| | | | | | | | | | | | | | | | | | | | So again the reasons why we break this: - node.class vs. node['class'] kinds of problems - adding node#foo to Chef::Node as an extension to the API and breaking node.foo meaning node["foo"] (we can't make exensions to that class without possibly breaking someone) - crazy things like the old CHEF-3799 issue in the old ticketing system where IO#puts in ruby blindly calls #to_ary on stuff and expects it to raise -- whereas we would potentially autovivify a 'to_ary' hash key and return nil which breaks the world. This also has caused issues with the hashie gem and they've gone to spamming warnings by default to try to deal with it: https://github.com/berkshelf/berkshelf/issues/1665 Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* add specs for array slice access to node attributeslcg/node-immutable-array-sliceLamont Granquist2016-11-152-0/+16
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* add some unit testing of new node APIslcg/attribute-setting-eventLamont Granquist2016-10-311-1/+46
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* rename __path to __path__ and __node to __node__lcg/node-path-trackingLamont Granquist2016-10-251-1/+1
| | | | | | | | | | | | consistency with Unchain here: https://github.com/chef/chef/blob/master/lib/chef/decorator/unchain.rb#L23-L24 and with SimpleDelegator: https://ruby-doc.org/stdlib-2.1.0/libdoc/delegate/rdoc/SimpleDelegator.html#method-i-__getobj__ Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* remove breadcrumb stateLamont Granquist2016-10-251-87/+24
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* standardize initializer args for VividMash+ImmutableMashLamont Granquist2016-10-251-2/+3
| | | | | | | | | | | | | | | | | | | if anyone is using these directly this might be a breaking change, although it makes it considerably easier to use VividMash and IMO ImmutableMash is an implementation detail of the deep merge cache and Chef::Node object. we definitely have never documented these APIs, so I think the onus is on the consumer to update their code. VividMash.new() should now work. VividMash.new({ foo: :bar }) should also now work. IDK what object people would have been passing in as the root object before. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* modify attributes and nodes tests for deeply converting_valuesLamont Granquist2016-09-232-1/+50
| | | | | | | | slightly more succinct and strict about types, also trying to keep the attributes tests associated with attributes even though we mix them all up like crazy anyway... Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix for #5094 12.12.13 node.default_unless issueLamont Granquist2016-07-081-20/+53
| | | | | | note that the node_spec test in this commit is not red on master so it ain't testing the right thing yet, but this fixes the issue in chef-shell...
* Attributes v1.1 changeslcg/attributes-v1.1Lamont Granquist2016-06-273-9/+355
| | | | | | | | | | | - fixes *_unless behavior and set_unless_value_present hack from Chef 12 - simplifies rm_* code - introduces functional read/write/unlink/exist? API - deprecates method_missing access to attributes for Chef 13 - deprecates set/set_unless aliases for Chef 14 - removes MultiMash mess that I wrote for Chef 13 https://github.com/chef/chef/pull/5029 for more details
* Too much log output and unnecessary warnings! Suppress that shit.Kartik Null Cating-Subramanian2016-04-252-3/+3
|
* flip multiline function arguments aroundlcg/rubocop-0.37.2Lamont Granquist2016-02-191-13/+13
| | | | no enforced trailing comma on arguments...
* deal with 0.37.2 renamed copsLamont Granquist2016-02-181-2/+2
| | | | | | | | | | | | | | | 252 Style/TrailingCommaInLiteral 84 Style/TrailingCommaInArguments 15 Style/SpaceAroundKeyword -- 351 Total We already dealt with SpaceAroundKeyword under its old name SpaceBeforeModifierKeyword, it looks like it got stricter about spaces after keywords. TrailingComma also got split, and it looks like the TrailingCommaInArguments behavior is new?
* pull rubocop 0.37.2 into chefstyleLamont Granquist2016-02-121-110/+110
| | | | | this is from the same ruleset that we had, but the new code catches more conditions.
* autofixing auto-inserted delimiterslcg/chefstyle-batchLamont Granquist2016-02-091-25/+25
|
* auto fixing some rubocopsLamont Granquist2016-02-091-25/+25
| | | | | | | | | Style/NegatedWhile Style/ParenthesesAroundCondition Style/WhileUntilDo Style/WordArray Performance/ReverseEach Style/ColonMethodCall
* autofixing whitespace copsLamont Granquist2016-02-052-198/+152
| | | | | | | | | | | | | | | | | | | | | | 4174 Style/SpaceInsideHashLiteralBraces 1860 Style/SpaceAroundOperators 1336 Style/SpaceInsideBlockBraces 1292 Style/AlignHash 997 Style/SpaceAfterComma 860 Style/SpaceAroundEqualsInParameterDefault 310 Style/EmptyLines 294 Style/IndentationConsistency 267 Style/TrailingWhitespace 238 Style/ExtraSpacing 212 Style/SpaceBeforeBlockBraces 166 Style/MultilineOperationIndentation 144 Style/TrailingBlankLines 120 Style/EmptyLineBetweenDefs 101 Style/IndentationWidth 82 Style/SpaceAroundBlockParameters 40 Style/EmptyLinesAroundMethodBody 29 Style/EmptyLinesAroundAccessModifier 1 Style/RescueEnsureAlignment
* Update all auth email address from opscode.com and getchef.com to chef.io.Noah Kantrowitz2016-02-022-3/+3
| | | Generated via git ls-files | xargs perl -pi -e "s/(Author.*?<[^@]+@)(?:opscode\\.com|getchef\\.com)(>)/\\1chef.io\\2/gi"