New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX data_bag_item.rb:161: warning: circular argument reference - data_bag #2707
Conversation
…erence - data_bag This fixes a warning in Ruby 2.2 about circular argument references in data_bag_item.rb See this ruby issue for more details: https://bugs.ruby-lang.org/issues/10314
I would like to see a test added to https://github.com/opscode/chef/blob/master/spec/unit/data_bag_item_spec.rb that ensures this does not regress in the future. There are no specs for the Otherwise, this LGTM. Although I am worried that we could be bitten by this Ruby change elsewhere. |
Hmm. I'm not quite sure how a proper test would look like. I got a spec working like this, should i add it? @orig_stderr = $stderr
$stderr = StringIO.new
require 'spec_helper'
require 'chef/data_bag_item'
stderr = $stderr
stderr.rewind
$stderr = @orig_stderr
describe Chef::DataBagItem do
before(:each) do
@data_bag_item = Chef::DataBagItem.new
end
describe "initialize" do
it "should be a Chef::DataBagItem" do
expect(@data_bag_item).to be_a_kind_of(Chef::DataBagItem)
end
it "does not warn on initialization" do
expect(stderr.string.chomp).to be_empty
end
end
.... Although i think this kind of spec should be added somewhere else...or maybe not at all. |
I'm thinking you should add this to data_bag_item_spec.rb: describe "destroy" do
let(:server) { instance_double(Chef::REST) }
# TODO we should convert this whole file to `let` syntax
let(:data_bag_item) {
data_bag_item = Chef::DataBagItem.new
data_bag_item.data_bag('a_baggy_bag')
data_bag_item.raw_data = { "id" => "some_id" }
data_bag_item
}
it "should set default parameters" do
expect(Chef::REST).to receive(:new).and_return(server)
expect(server).to receive(:delete_rest).with("data/a_baggy_bag/data_bag_item_a_baggy_bag_some_id")
data_bag_item.destroy
end
end When I run that locally with Ruby 2.2.0-preview1 I get the following rspec failure:
Which is what I expect. So the purpose of this test is not to test that we miss a Ruby warning - it is to test that we are upholding our internal contract. Namely, that we will construct that REST URL correctly. Let me know if this doesn't make sense. Extra credit if you want to convert this whole file to |
Thanks, that makes sense. |
👍 |
That |
Any update on when this could be merged and released? |
+1, I'm looking forward the merging. |
merge, pleeaaaase 💋 |
thanks! ❤️ |
Hi. I am an automated pull request bot named Curry. There are commits in this pull request whose authors are not yet authorized to contribute to Chef Software, Inc. projects or are using a non-GitHub verified email address. To become authorized to contribute, you will need to sign the Contributor License Agreement (CLA) as an individual or on behalf of your company. You can read more on Chef's blog. GitHub Users Who Are Not Authorized To ContributeThe following GitHub users do not appear to have signed a CLA: |
This fixes a warning in Ruby 2.2 about circular argument references in data_bag_item.rb
See this ruby issue for more details: https://bugs.ruby-lang.org/issues/10314