ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:95205] [Ruby master Misc#16235] ENV.assoc spec test does not test invalid name
       [not found] <redmine.issue-16235.20191003210512@ruby-lang.org>
@ 2019-10-03 21:05 ` burdettelamar
  2019-10-03 21:31 ` [ruby-core:95207] " merch-redmine
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: burdettelamar @ 2019-10-03 21:05 UTC (permalink / raw)
  To: ruby-core

Issue #16235 has been reported by burdettelamar@yahoo.com (Burdette Lamar).

----------------------------------------
Misc #16235: ENV.assoc spec test does not test invalid name
https://bugs.ruby-lang.org/issues/16235

* 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/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:95207] [Ruby master Misc#16235] ENV.assoc spec test does not test invalid name
       [not found] <redmine.issue-16235.20191003210512@ruby-lang.org>
  2019-10-03 21:05 ` [ruby-core:95205] [Ruby master Misc#16235] ENV.assoc spec test does not test invalid name burdettelamar
@ 2019-10-03 21:31 ` merch-redmine
  2019-10-03 21:54 ` [ruby-core:95208] " burdettelamar
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: merch-redmine @ 2019-10-03 21:31 UTC (permalink / raw)
  To: ruby-core

Issue #16235 has been updated by jeremyevans0 (Jeremy Evans).


It appears if `reserve_names` is called with a name that is already an environment variable, `release_names` will remove that name from the environment, which seems like a bug.  Now, that issue exists in the current code (environment variable `foo` is always modified and removed.  But if we are going to handle this, we should probably not set @reserved until after checking the names, and only remove the @reserved entries if the instance variable is defined.

Note that since these changes are only to the specs, you may want to consider submitting them as pull requests to ruby/spec: https://github.com/ruby/spec/pulls


----------------------------------------
Misc #16235: ENV.assoc spec test does not test invalid name
https://bugs.ruby-lang.org/issues/16235#change-81881

* 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/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:95208] [Ruby master Misc#16235] ENV.assoc spec test does not test invalid name
       [not found] <redmine.issue-16235.20191003210512@ruby-lang.org>
  2019-10-03 21:05 ` [ruby-core:95205] [Ruby master Misc#16235] ENV.assoc spec test does not test invalid name burdettelamar
  2019-10-03 21:31 ` [ruby-core:95207] " merch-redmine
@ 2019-10-03 21:54 ` burdettelamar
  2019-10-03 23:07 ` [ruby-core:95210] " merch-redmine
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: burdettelamar @ 2019-10-03 21:54 UTC (permalink / raw)
  To: ruby-core

Issue #16235 has been updated by burdettelamar@yahoo.com (Burdette Lamar).


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?

----------------------------------------
Misc #16235: ENV.assoc spec test does not test invalid name
https://bugs.ruby-lang.org/issues/16235#change-81882

* 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/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:95210] [Ruby master Misc#16235] ENV.assoc spec test does not test invalid name
       [not found] <redmine.issue-16235.20191003210512@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2019-10-03 21:54 ` [ruby-core:95208] " burdettelamar
@ 2019-10-03 23:07 ` merch-redmine
  2019-10-04  0:58 ` [ruby-core:95214] " burdettelamar
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: merch-redmine @ 2019-10-03 23:07 UTC (permalink / raw)
  To: 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/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:95214] [Ruby master Misc#16235] ENV.assoc spec test does not test invalid name
       [not found] <redmine.issue-16235.20191003210512@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2019-10-03 23:07 ` [ruby-core:95210] " merch-redmine
@ 2019-10-04  0:58 ` burdettelamar
  2019-10-05 19:08 ` [ruby-core:95235] " burdettelamar
  2019-10-05 22:53 ` [ruby-core:95238] " burdettelamar
  6 siblings, 0 replies; 7+ messages in thread
From: burdettelamar @ 2019-10-04  0:58 UTC (permalink / raw)
  To: ruby-core

Issue #16235 has been updated by burdettelamar@yahoo.com (Burdette Lamar).


Got it, thanks.  Will update the diff.

----------------------------------------
Misc #16235: ENV.assoc spec test does not test invalid name
https://bugs.ruby-lang.org/issues/16235#change-81888

* 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/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:95235] [Ruby master Misc#16235] ENV.assoc spec test does not test invalid name
       [not found] <redmine.issue-16235.20191003210512@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2019-10-04  0:58 ` [ruby-core:95214] " burdettelamar
@ 2019-10-05 19:08 ` burdettelamar
  2019-10-05 22:53 ` [ruby-core:95238] " burdettelamar
  6 siblings, 0 replies; 7+ messages in thread
From: burdettelamar @ 2019-10-05 19:08 UTC (permalink / raw)
  To: ruby-core

Issue #16235 has been updated by burdettelamar@yahoo.com (Burdette Lamar).


Have put this up as a PR, so we're done here.

----------------------------------------
Misc #16235: ENV.assoc spec test does not test invalid name
https://bugs.ruby-lang.org/issues/16235#change-81908

* 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/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:95238] [Ruby master Misc#16235] ENV.assoc spec test does not test invalid name
       [not found] <redmine.issue-16235.20191003210512@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2019-10-05 19:08 ` [ruby-core:95235] " burdettelamar
@ 2019-10-05 22:53 ` burdettelamar
  6 siblings, 0 replies; 7+ messages in thread
From: burdettelamar @ 2019-10-05 22:53 UTC (permalink / raw)
  To: ruby-core

Issue #16235 has been updated by burdettelamar@yahoo.com (Burdette Lamar).


https://github.com/ruby/ruby/pull/2527

----------------------------------------
Misc #16235: ENV.assoc spec test does not test invalid name
https://bugs.ruby-lang.org/issues/16235#change-81911

* 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/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-10-05 22:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-16235.20191003210512@ruby-lang.org>
2019-10-03 21:05 ` [ruby-core:95205] [Ruby master Misc#16235] ENV.assoc spec test does not test invalid name burdettelamar
2019-10-03 21:31 ` [ruby-core:95207] " merch-redmine
2019-10-03 21:54 ` [ruby-core:95208] " burdettelamar
2019-10-03 23:07 ` [ruby-core:95210] " merch-redmine
2019-10-04  0:58 ` [ruby-core:95214] " burdettelamar
2019-10-05 19:08 ` [ruby-core:95235] " burdettelamar
2019-10-05 22:53 ` [ruby-core:95238] " burdettelamar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).