Permalink
Browse files

Spec ENV.select!

  • Loading branch information...
1 parent 8141ff4 commit d268400bbef70a508dd239a6d268057f4cb32a1f @jfirebaugh jfirebaugh committed Apr 5, 2012
Showing with 25 additions and 3 deletions.
  1. +25 −3 spec/ruby/core/env/select_spec.rb
@@ -1,17 +1,39 @@
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"
end
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"

0 comments on commit d268400

Please sign in to comment.