From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.6 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id B86BE1F4BD for ; Thu, 3 Oct 2019 23:07:16 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 09797120929; Fri, 4 Oct 2019 08:07:07 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 3C0F21208FD for ; Fri, 4 Oct 2019 08:07:03 +0900 (JST) Received: by filter0130p3las1.sendgrid.net with SMTP id filter0130p3las1-14419-5D967F18-24 2019-10-03 23:07:04.279223953 +0000 UTC m=+15833.460217277 Received: from herokuapp.com (unknown [54.81.242.65]) by ismtpd0039p1iad2.sendgrid.net (SG) with ESMTP id FwH0yGk0QWiEibo9nY8Ijg for ; Thu, 03 Oct 2019 23:07:04.151 +0000 (UTC) Date: Thu, 03 Oct 2019 23:07:04 +0000 (UTC) From: merch-redmine@jeremyevans.net Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 70797 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 16235 X-Redmine-Issue-Author: burdettelamar@yahoo.com X-Redmine-Sender: jeremyevans0 X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?RVE3t853K5scBhbmJHUzZTFFeVC=2FZSUmHZ0Dc+26wcEi2CTgsF1oz0wTSSxGGN?= =?us-ascii?Q?BIq2GQHBbLC575Ie=2FcLxAvL4jAMD=2F6TRp3on40x?= =?us-ascii?Q?sTWCDcBQ47zk=2FXxCHpOmy5ryWRsSv8G5l7sb4h+?= =?us-ascii?Q?oRk3PzBWuDvOMTUc8Ow87=2FVZBQ4P9m4GX5hgAa4?= =?us-ascii?Q?7CWzBJ4SmTwDl5iSbicNkdOhkr5gFE2MPzQ=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 95210 Subject: [ruby-core:95210] [Ruby master Misc#16235] ENV.assoc spec test does not test invalid name X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #16235 has been updated by jeremyevans0 (Jeremy Evans). burdettelamar@yahoo.com (Burdette Lamar) wrote: > Method :reserve_names fails if any name is already in use: > > ``` > def reserve_names(*names) > @reserved = names > @reserved.each do |name| > fail "Name #{name} is already in use" if ENV.include?(name) > end > end > ``` > > So, not a problem? `reserve_names` is called in a `before :each` block. When it fails, the `after :each` block is called. That block calls `release_names` which will delete the entry from the environment. In my opinion, if you are checking whether the environment variable is already set, and it is already set, and the spec fails because of this, you probably should not remove the entry from the environment. Otherwise you are making the spec fail for no reason. ---------------------------------------- Misc #16235: ENV.assoc spec test does not test invalid name https://bugs.ruby-lang.org/issues/16235#change-81884 * Author: burdettelamar@yahoo.com (Burdette Lamar) * Status: Open * Priority: Normal * Assignee: ---------------------------------------- The most important thing here is an added test for an invalid name argument to ENV.assoc, which should raise TypeError. I've also added to spec_helper.rb: - Methods :reserve_names and :release_names, to reserve and release names used in the test. - Method :mock_to_str, to return a mock object that responds to :to_str. The updated assoc_spec.rb uses all of these, as will many other spec tests for ENV, as I get to them. It's known that some of the ENV spec tests do not test a method's return value, and that some do not test error conditions (as above), so more to come. All in good time. ---Files-------------------------------- t.diff (2.24 KB) -- https://bugs.ruby-lang.org/