Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Spec ENV.select!

  • Loading branch information...
commit d268400bbef70a508dd239a6d268057f4cb32a1f 1 parent 8141ff4
@jfirebaugh jfirebaugh authored
Showing with 25 additions and 3 deletions.
  1. +25 −3 spec/ruby/core/env/select_spec.rb
View
28 spec/ruby/core/env/select_spec.rb
@@ -1,9 +1,31 @@
require File.expand_path('../../../spec_helper', __FILE__)
-describe "ENV.select" do
+ruby_version_is "1.9" do
+ describe "ENV.select!" do
+ it "removes environment variables for which the block returns true" do
+ ENV["foo"] = "bar"
+ ENV.select! { |k, v| k != "foo" }
+ ENV["foo"].should == nil
+ end
+ it "returns self if any changes were made" do
+ ENV["foo"] = "bar"
+ ENV.select! { |k, v| k != "foo" }.should == ENV
+ end
+
+ it "returns nil if no changes were made" do
+ ENV.select! { true }.should == nil
+ end
+
+ it "returns an Enumerator if called without a block" do
+ ENV.select!.should be_an_instance_of(enumerator_class)
+ end
+ end
+end
+
+describe "ENV.select" do
ruby_version_is ""..."1.9" do
- it "returns the Hash for which block return true" do
+ it "returns an Array of names and value for which block returns true" do
ENV["foo"] = "bar"
ENV.select { |k, v| k == "foo" }.should == [["foo", "bar"]]
ENV.delete "foo"
@@ -11,7 +33,7 @@
end
ruby_version_is "1.9" do
- it "returns the Hash for which block return true" do
+ it "returns a Hash of names and values for which block return true" do
ENV["foo"] = "bar"
ENV.select { |k, v| k == "foo" }.should == {"foo" => "bar"}
ENV.delete "foo"
Please sign in to comment.
Something went wrong with that request. Please try again.