summaryrefslogtreecommitdiff
path: root/spec/unit/resource_spec.rb
Commit message (Collapse)AuthorAgeFilesLines
* Update tests and docs for umask on Windows.fix-umask-test-on-windowsPete Higgins2020-06-261-8/+25
| | | | Signed-off-by: Pete Higgins <pete@peterhiggins.org>
* Cleanup test, add failsafe reset.Pete Higgins2020-06-161-10/+11
| | | | Signed-off-by: Pete Higgins <pete@peterhiggins.org>
* Fix chefstyle violation.Pete Higgins2020-06-161-1/+1
| | | | Signed-off-by: Pete Higgins <pete@peterhiggins.org>
* Add a umask property for resources.Pete Higgins2020-06-161-0/+51
| | | | Signed-off-by: Pete Higgins <pete@peterhiggins.org>
* Fix rspec warning about `not_to raise_error` with a specific exception.fix-rspec-warningPete Higgins2020-05-291-1/+1
| | | | | | WARNING: Using `expect { }.not_to raise_error(SpecificErrorClass)` risks false positives, since literally any other error would cause the expectation to pass, including those raised by Ruby (e.g. NoMethodError, NameError and ArgumentError), meaning the code you are intending to test may not even get reached. Instead consider using `expect { }.not_to raise_error` or `expect { }.to raise_error(DifferentSpecificErrorClass)`. This message can be suppressed by setting: `RSpec::Expectations.configuration.on_potential_false_positives = :nothing`. Called from /Users/pete/work/chef/spec/unit/resource_spec.rb:381:in `block (4 levels) in <top (required)>'. Signed-off-by: Pete Higgins <pete@peterhiggins.org>
* Chef-16.2 breaking changelcg/resource_name_fixesLamont Granquist2020-05-201-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a breaking change to fix a breaking change in Chef 16.0. The new behavior is that a resource which relies upon the reource_name statement to wire the resource up to the DSL will fail (although the very old wiring of the "<cookbook_name>_<resource filename>" continues to work). So for a resource which does not get its DSL wiring from the filename, only declaring a resource_name will fail: ``` resource_name :foo ``` This can be fixed by adding an explicit `provides` line (which is backwards compatible): ``` resource_name :foo provides :foo ``` If backwards compatibility is not a concern, then post-16.0 the resource_name call can be completely dropped: ``` provides :foo ``` This is a vastly simpler backwards compatibility break than the unintentional break in #9885, which is difficult to describe and to detect. The rules going forward are fairly simple to explain: 1. The resource_name now only sets the resource_name. 2. The old behavior of the fallback resource_name and DSL wiring based on the filename is preserved (unless the values are set). 3. In Chef 16, The first provides line will set the resource_name if it has not already been set, allowing the resource_name to be omitted. It is recommended that all resources only set provides lines, the use of the fallback filename-based wiring is discouraged and explicitly setting the resource_name is discouraged. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Remove copyright dateslcg/remove-copyright-datesLamont Granquist2020-04-131-1/+1
| | | | | | | | 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-4/+4
| | | | Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
* fix for 2.6Lamont Granquist2020-03-031-1/+1
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Remove the canonical DSLLamont Granquist2020-03-031-2/+2
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* more fixes to the ruby 2.7 fixesLamont Granquist2020-01-221-1/+8
| | | | | | this should pass on both now Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix a few more ruby 2.7 specslcg/ruby-2.7-2Lamont Granquist2020-01-221-2/+2
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Style/MethodCallWithoutArgsParenthesesLamont Granquist2019-07-021-1/+1
| | | | | | | | zero args methods don't get parens. this certainly reads better than the inverse. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Style/SymbolArrayLamont Granquist2019-07-021-20/+20
| | | | | | start enforcing using %i{} instead of arrays of symbols Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Remove resource collision deprecationsLamont Granquist2019-05-071-13/+1
| | | | | | | Switch to only doing warnings. Remove the features in the node_map that we never used. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* changes for rubocop engine upgrades.lcg/rubocop-upgradesLamont Granquist2019-01-151-1/+1
| | | | | | | this is the result of changes to rules we already previously had enabled. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* now user can use tagged method in both only_if and not_ifKapil Chouhan2018-11-291-0/+23
| | | | Signed-off-by: Kapil Chouhan <kapil.chouhan@msystechnologies.com>
* add rdoc and testsLamont Granquist2018-08-061-0/+26
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix Layout/LeadingCommentSpaceLamont Granquist2018-07-021-1/+1
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix Layout/IndentHeredocLamont Granquist2018-07-021-8/+8
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix Style/HashSyntaxLamont Granquist2018-07-021-21/+21
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Feed the rubocop.Noah Kantrowitz2018-06-051-3/+3
| | | Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
* Streamline the map locking process with a resource level flag.Noah Kantrowitz2018-06-051-0/+34
| | | Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
* Try to resolve a funky multi-test collision.Noah Kantrowitz2018-06-051-1/+1
| | | | Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
* convert shell_out_with_systems_locale to `default_env: true`lcg/remove-shell-out-with-systems-localeLamont Granquist2018-05-301-5/+1
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Feed the Rubocop.Noah Kantrowitz2018-04-261-2/+2
| | | | | | Some day I will remember which is which on string styles. Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
* Allow specifying `ignore_failure :quiet` to disable the error spew.Noah Kantrowitz2018-04-261-0/+10
| | | | Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
* allow resources to be documentedThom May2018-02-121-0/+31
| | | | Signed-off-by: Thom May <thom@chef.io>
* Remove the spec for epic_failepic_fail_specTim Smith2018-01-291-5/+0
| | | | | | Missed this one Signed-off-by: Tim Smith <tsmith@chef.io>
* And fix the resource name.Noah Kantrowitz2017-08-131-1/+1
| | | | Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
* Better spec label.Noah Kantrowitz2017-08-131-1/+1
| | | | Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
* Ignore validation errors in Resource#to_text.Noah Kantrowitz2017-08-131-0/+8
| | | | Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
* Chef-13: Support nameless resources and remove deprecated multi-arg resourcesLamont Granquist2017-03-301-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes nameless resources work in the DSL: ```ruby apt_update ``` It does it by giving it an empty-string name of "" It also drops support for multi-arg resources, that has been deprecated for some time: ```ruby some_resource "foo", "bar", "baz" ``` Note that multipackage package resources do not use multiple args, but a single argument which is an arry: ```ruby package [ "lsof", "strace", "tcpdump" ] ``` So this change does not affect that usage. Multi-arg has been deprecated for some time now and its not clear that it was ever used by anyone. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Don't `rescue Exception` for retriable resourcesStephan Renatus2017-03-271-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | Without this, sending an interrupt signal (hitting Ctrl+C) during a chef-client run that is currently executing a resources that has `retries` set will not interrupt the run, although the interrupt handler set up in Chef::Application calls Process.exit, which raises SystemExit. If the retryable resource is shelling out, the spawned process also gets the INT signal and will stop -- however, the chef-run would go on, merely noticing that the resource has failed and theres X-1 retries left. It is imaginable that users depend on some (whacky) Ruby script in a retriable resource that raises SystemExit, and they want this to _not_ stop the chef-run. So it's up for debate if we just want to merge this or make it configurable. In general, I'd like Ctrl+C to _stop my chef-run_, but this expectation could also be misled. When adapting tests to this change, it became apparent that for some reason the runner_spec.rb test didn't behave as expected. I've thus made those tests a little stricter by replacing some allows by expects. Signed-off-by: Stephan Renatus <srenatus@chef.io>
* Chef-13: remove Chef::Platform.set and related methodsLamont Granquist2017-03-171-5/+1
| | | | | | Switch over the Chef-12.0 ProviderResolver is now completed. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix specs broken by removal of state methodLamont Granquist2017-03-171-1/+1
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Kill JSON auto inflate with firetm/remove_json_autoinflateThom May2017-03-141-1/+1
| | | | Signed-off-by: Thom May <thom@chef.io>
* Chef-13: Chef::Resource cleanupLamont Granquist2017-03-081-47/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | most of this deletes useless old code. the change to lookup_provider_constant changes to more strictly stop using class name based lookups and to go through the resource resolver and provider resolver. as a result in order to find the provider class for a given dsl name you have to go through the resource resolver to find the resource in order to be able to pass a resource instance through the provider resolver. since the provider resolver api passes resources into blocks passed into provides api you must construct a resource instance. that means that providers need to be associated with resources in order to be looked up (which makes sense in Real Life(tm) use of Chef, but breaks quite a few lazy tests we had where we constructed providers without doing the work of wrapping them in a resource. note that as the deploy resource shows this filters into a changed behavior of the `provider` syntax where before `provider :revision` would look up Chef::Provider::Deploy::Revision via class-name based magic. this breaks that API so that `provider :deploy_revision` is used instead -- the symbol (or string) there is turned into a resource first via the Chef::ResourceResolver and then looked up via the Chef::ProviderResolver into Chef::Provider::Deploy::Revision. this is a breaking change but is also a bug fix so that the symbol here goes through the same lookup that you get when you type it in the DSL. i had considered implementing a lookup from a resource_name symbol to a provider, but in looking at how to implement that in the ProviderResolver the issue is that we really need to have a resource instance order to pass to the ProviderResolver. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* convert additional resource methods to propertieslcg/chef-resource-propertiesLamont Granquist2017-03-071-6/+6
| | | | | | | converts sensitive, retries, retry_delay and ignore_failure to properties Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* remove most of supports APILamont Granquist2017-03-061-17/+3
| | | | | | | | | | | | | | | still there on service (where it makes some sense) also still on mount (because i have no idea if that is actively being used or if it makes any sense at all). converts it to a property on mount + service as well. also removed setting it as an array -- did we ever document that and/or does anyone use it? i'm not religiously against that way of setting it, but if nobody ever used it i'd rather remove the YAGNI. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Suppress sensitive properties from resource outputTom Duffield2017-02-101-0/+18
| | | | Signed-off-by: Tom Duffield <tom@chef.io>
* Properly deprecate old Chef::Platform methodsLamont Granquist2016-12-071-0/+2
| | | | | | | | These should have been deprecated formally in 12.5.1 after the Dynamic Provider-Resolver'ing of the internal chef resources was completed. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Allow flagging a resource property as sensitiveadamleff/sensitive-propertiesAdam Leff2016-08-251-0/+20
| | | | | | | | | | | | Some properties in custom resources may include sensitive data, such as a password for a database server. When the Resource's state is built for use by Data Collector or similar auditing tool, `Chef::Resource#state_for_resource_reporter` builds a hash of all state properties for that resource and their values. This leads to sensitive data being transmitted and potentially stored in the clear. This change enhances properties with the ability to set an individual property as sensitive and then have the value of that property suppressed when exporting the Resource's state.
* fix Style/BlockDelimiters, Style/MultilineBlockLayout and 0.42.0 engine upgradeLamont Granquist2016-08-171-16/+16
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Too much log output and unnecessary warnings! Suppress that shit.Kartik Null Cating-Subramanian2016-04-251-1/+1
|
* flip multiline function arguments aroundlcg/rubocop-0.37.2Lamont Granquist2016-02-191-1/+1
| | | | no enforced trailing comma on arguments...
* autofixing auto-inserted delimiterslcg/chefstyle-batchLamont Granquist2016-02-091-4/+4
|
* auto fixing some rubocopsLamont Granquist2016-02-091-4/+4
| | | | | | | | | Style/NegatedWhile Style/ParenthesesAroundCondition Style/WhileUntilDo Style/WordArray Performance/ReverseEach Style/ColonMethodCall
* autofixing whitespace copsLamont Granquist2016-02-051-20/+20
| | | | | | | | | | | | | | | | | | | | | | 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-021-4/+4
| | | Generated via git ls-files | xargs perl -pi -e "s/(Author.*?<[^@]+@)(?:opscode\\.com|getchef\\.com)(>)/\\1chef.io\\2/gi"