diff options
Diffstat (limited to 'spec/rubyspec/core/env')
48 files changed, 0 insertions, 949 deletions
diff --git a/spec/rubyspec/core/env/assoc_spec.rb b/spec/rubyspec/core/env/assoc_spec.rb deleted file mode 100644 index fb10a52b3c..0000000000 --- a/spec/rubyspec/core/env/assoc_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe "ENV.assoc" do - after :each do - ENV.delete("foo") - end - - it "returns an array of the key and value of the environment variable with the given key" do - ENV["foo"] = "bar" - ENV.assoc("foo").should == ["foo", "bar"] - end - - it "returns nil if no environment variable with the given key exists" do - ENV.assoc("foo").should == nil - end - - it "returns the key element coerced with #to_str" do - ENV["foo"] = "bar" - k = mock('key') - k.should_receive(:to_str).and_return("foo") - ENV.assoc(k).should == ["foo", "bar"] - end -end diff --git a/spec/rubyspec/core/env/clear_spec.rb b/spec/rubyspec/core/env/clear_spec.rb deleted file mode 100644 index c184926cc2..0000000000 --- a/spec/rubyspec/core/env/clear_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe "ENV.clear" do - it "deletes all environment variables" do - orig = ENV.to_hash - begin - ENV.clear - - # This used 'env' the helper before. That shells out to 'env' which - # itself sets up certain environment variables before it runs, because - # the shell sets them up before it runs any command. - # - # Thusly, you can ONLY test this by asking through ENV itself. - ENV.size.should == 0 - ensure - ENV.replace orig - end - end - -end diff --git a/spec/rubyspec/core/env/delete_if_spec.rb b/spec/rubyspec/core/env/delete_if_spec.rb deleted file mode 100644 index 9a8220ae7d..0000000000 --- a/spec/rubyspec/core/env/delete_if_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__) - -describe "ENV.delete_if" do - it "deletes pairs if the block returns true" do - ENV["foo"] = "bar" - ENV.delete_if { |k, v| k == "foo" } - ENV["foo"].should == nil - end - - it "returns ENV even if nothing deleted" do - ENV.delete_if { false }.should_not == nil - end - - it "returns an Enumerator if no block given" do - ENV.delete_if.should be_an_instance_of(Enumerator) - end - - it "deletes pairs through enumerator" do - ENV["foo"] = "bar" - enum = ENV.delete_if - enum.each { |k, v| k == "foo" } - ENV["foo"].should == nil - end - - it_behaves_like :enumeratorized_with_origin_size, :delete_if, ENV -end diff --git a/spec/rubyspec/core/env/delete_spec.rb b/spec/rubyspec/core/env/delete_spec.rb deleted file mode 100644 index e02adf963f..0000000000 --- a/spec/rubyspec/core/env/delete_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe "ENV.delete" do - after :each do - ENV.delete("foo") - end - - it "removes the variable from the environment" do - ENV["foo"] = "bar" - ENV.delete("foo") - ENV["foo"].should == nil - end - - it "returns the previous value" do - ENV["foo"] = "bar" - ENV.delete("foo").should == "bar" - end - - it "yields the name to the given block if the named environment variable does not exist" do - ENV.delete("foo") - ENV.delete("foo") { |name| ScratchPad.record name } - ScratchPad.recorded.should == "foo" - end -end diff --git a/spec/rubyspec/core/env/each_key_spec.rb b/spec/rubyspec/core/env/each_key_spec.rb deleted file mode 100644 index 82721cdb96..0000000000 --- a/spec/rubyspec/core/env/each_key_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__) - -describe "ENV.each_key" do - - it "returns each key" do - e = [] - orig = ENV.to_hash - begin - ENV.clear - ENV["1"] = "3" - ENV["2"] = "4" - ENV.each_key { |k| e << k } - e.should include("1") - e.should include("2") - ensure - ENV.replace orig - end - end - - it "returns an Enumerator if called without a block" do - ENV.each_key.should be_an_instance_of(Enumerator) - end - - it "returns keys in the locale encoding" do - ENV.each_key do |key| - key.encoding.should == Encoding.find('locale') - end - end - - it_behaves_like :enumeratorized_with_origin_size, :each_key, ENV -end diff --git a/spec/rubyspec/core/env/each_pair_spec.rb b/spec/rubyspec/core/env/each_pair_spec.rb deleted file mode 100644 index 255ccd86c5..0000000000 --- a/spec/rubyspec/core/env/each_pair_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../shared/each.rb', __FILE__) - -describe "ENV.each_pair" do - it_behaves_like(:env_each, :each_pair) -end diff --git a/spec/rubyspec/core/env/each_spec.rb b/spec/rubyspec/core/env/each_spec.rb deleted file mode 100644 index 2424c5e4e0..0000000000 --- a/spec/rubyspec/core/env/each_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../shared/each.rb', __FILE__) - -describe "ENV.each" do - it_behaves_like(:env_each, :each) -end diff --git a/spec/rubyspec/core/env/each_value_spec.rb b/spec/rubyspec/core/env/each_value_spec.rb deleted file mode 100644 index 070a1d2cb9..0000000000 --- a/spec/rubyspec/core/env/each_value_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__) - -describe "ENV.each_value" do - - it "returns each value" do - e = [] - orig = ENV.to_hash - begin - ENV.clear - ENV["1"] = "3" - ENV["2"] = "4" - ENV.each_value { |v| e << v } - e.should include("3") - e.should include("4") - ensure - ENV.replace orig - end - end - - it "returns an Enumerator if called without a block" do - ENV.each_value.should be_an_instance_of(Enumerator) - end - - it "uses the locale encoding" do - ENV.each_value do |value| - value.encoding.should == Encoding.find('locale') - end - end - - it_behaves_like :enumeratorized_with_origin_size, :each_value, ENV -end diff --git a/spec/rubyspec/core/env/element_reference_spec.rb b/spec/rubyspec/core/env/element_reference_spec.rb deleted file mode 100644 index 2e6402dd28..0000000000 --- a/spec/rubyspec/core/env/element_reference_spec.rb +++ /dev/null @@ -1,66 +0,0 @@ -# -*- encoding: ascii-8bit -*- -require File.expand_path('../../../spec_helper', __FILE__) - -describe "ENV.[]" do - before :each do - @variable = "returns_only_frozen_values" - end - - after :each do - ENV.delete @variable - end - - it "returns nil if the variable isn't found" do - ENV["this_var_is_never_set"].should == nil - end - - it "returns only frozen values" do - ENV[@variable] = "a non-frozen string" - ENV[@variable].frozen?.should == true - end - - platform_is :windows do - it "looks up values case-insensitively" do - ENV[@variable] = "bar" - ENV[@variable.upcase].should == "bar" - end - end -end - -with_feature :encoding do - describe "ENV.[]" do - before :each do - @variable = "env_element_reference_encoding_specs" - - @external = Encoding.default_external - @internal = Encoding.default_internal - - Encoding.default_external = Encoding::ASCII_8BIT - end - - after :each do - Encoding.default_external = @external - Encoding.default_internal = @internal - - ENV.delete @variable - end - - it "uses the locale encoding if Encoding.default_internal is nil" do - Encoding.default_internal = nil - - locale = Encoding.find('locale') - locale = Encoding::ASCII_8BIT if locale == Encoding::US_ASCII - ENV[@variable] = "\xC3\xB8" - ENV[@variable].encoding.should == locale - end - - it "transcodes from the locale encoding to Encoding.default_internal if set" do - # We cannot reliably know the locale encoding, so we merely check that - # the result string has the expected encoding. - ENV[@variable] = "" - Encoding.default_internal = Encoding::IBM437 - - ENV[@variable].encoding.should equal(Encoding::IBM437) - end - end -end diff --git a/spec/rubyspec/core/env/element_set_spec.rb b/spec/rubyspec/core/env/element_set_spec.rb deleted file mode 100644 index a80cd0c51e..0000000000 --- a/spec/rubyspec/core/env/element_set_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../shared/store.rb', __FILE__) - -describe "ENV.[]=" do - it_behaves_like(:env_store, :[]=) -end diff --git a/spec/rubyspec/core/env/empty_spec.rb b/spec/rubyspec/core/env/empty_spec.rb deleted file mode 100644 index fa02985a6e..0000000000 --- a/spec/rubyspec/core/env/empty_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe "ENV.empty?" do - - it "returns true if the Environment is empty" do - if ENV.keys.size > 0 - ENV.empty?.should == false - end - orig = ENV.to_hash - begin - ENV.clear - ENV.empty?.should == true - ensure - ENV.replace orig - end - end - - it "returns false if not empty" do - if ENV.keys.size > 0 - ENV.empty?.should == false - end - end -end diff --git a/spec/rubyspec/core/env/fetch_spec.rb b/spec/rubyspec/core/env/fetch_spec.rb deleted file mode 100644 index 708ee91c39..0000000000 --- a/spec/rubyspec/core/env/fetch_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe "ENV.fetch" do - it "returns a value" do - ENV["foo"] = "bar" - ENV.fetch("foo").should == "bar" - ENV.delete "foo" - end - - it "raises a TypeError if the key is not a String" do - lambda { ENV.fetch :should_never_be_set }.should raise_error(TypeError) - end - - it "raises a KeyError if the key is not found" do - lambda { ENV.fetch "should_never_be_set" }.should raise_error(KeyError) - end - - it "provides the given default parameter" do - ENV.fetch("should_never_be_set", "default").should == "default" - end - - it "provides a default value from a block" do - ENV.fetch("should_never_be_set") { |k| "wanted #{k}" }.should == "wanted should_never_be_set" - end - - it "warns on block and default parameter given" do - lambda do - ENV.fetch("should_never_be_set", "default") { 1 }.should == 1 - end.should complain(/block supersedes default value argument/) - end - - it "uses the locale encoding" do - ENV.fetch(ENV.keys.first).encoding.should == Encoding.find('locale') - end -end diff --git a/spec/rubyspec/core/env/has_key_spec.rb b/spec/rubyspec/core/env/has_key_spec.rb deleted file mode 100644 index 8da2d94265..0000000000 --- a/spec/rubyspec/core/env/has_key_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../shared/include.rb', __FILE__) - -describe "ENV.has_key?" do - it_behaves_like(:env_include, :has_key?) -end diff --git a/spec/rubyspec/core/env/has_value_spec.rb b/spec/rubyspec/core/env/has_value_spec.rb deleted file mode 100644 index 76980a8df4..0000000000 --- a/spec/rubyspec/core/env/has_value_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../shared/value.rb', __FILE__) - -describe "ENV.has_value?" do - it_behaves_like(:env_value, :has_value?) -end diff --git a/spec/rubyspec/core/env/include_spec.rb b/spec/rubyspec/core/env/include_spec.rb deleted file mode 100644 index 4a716fee85..0000000000 --- a/spec/rubyspec/core/env/include_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../shared/include.rb', __FILE__) - -describe "ENV.include?" do - it_behaves_like(:env_include, :include?) -end diff --git a/spec/rubyspec/core/env/index_spec.rb b/spec/rubyspec/core/env/index_spec.rb deleted file mode 100644 index 95009b3558..0000000000 --- a/spec/rubyspec/core/env/index_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../shared/key.rb', __FILE__) - -describe "ENV.index" do - it_behaves_like(:env_key, :index) -end diff --git a/spec/rubyspec/core/env/indexes_spec.rb b/spec/rubyspec/core/env/indexes_spec.rb deleted file mode 100644 index 14fb93ef07..0000000000 --- a/spec/rubyspec/core/env/indexes_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) diff --git a/spec/rubyspec/core/env/indices_spec.rb b/spec/rubyspec/core/env/indices_spec.rb deleted file mode 100644 index 14fb93ef07..0000000000 --- a/spec/rubyspec/core/env/indices_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) diff --git a/spec/rubyspec/core/env/inspect_spec.rb b/spec/rubyspec/core/env/inspect_spec.rb deleted file mode 100644 index 9c4273e188..0000000000 --- a/spec/rubyspec/core/env/inspect_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe "ENV.inspect" do - - it "returns a String that looks like a Hash with real data" do - ENV["foo"] = "bar" - ENV.inspect.should =~ /\{.*"foo"=>"bar".*\}/ - ENV.delete "foo" - end - -end diff --git a/spec/rubyspec/core/env/invert_spec.rb b/spec/rubyspec/core/env/invert_spec.rb deleted file mode 100644 index 42170230db..0000000000 --- a/spec/rubyspec/core/env/invert_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe "ENV.invert" do - before :each do - ENV["foo"] = "bar" - end - - after :each do - ENV.delete "foo" - end - - it "returns a hash with ENV.keys as the values and vice versa" do - ENV.invert["bar"].should == "foo" - ENV["foo"].should == "bar" - end -end diff --git a/spec/rubyspec/core/env/keep_if_spec.rb b/spec/rubyspec/core/env/keep_if_spec.rb deleted file mode 100644 index c5bbc3dc05..0000000000 --- a/spec/rubyspec/core/env/keep_if_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__) - -describe "ENV.keep_if" do - before :each do - ENV["foo"] = "bar" - end - - after :each do - ENV.delete "foo" - end - - it "deletes pairs if the block returns false" do - ENV.keep_if { |k, v| k != "foo" } - ENV["foo"].should == nil - end - - it "returns ENV even if nothing deleted" do - ENV.keep_if { true }.should_not == nil - end - - it "returns an Enumerator if no block given" do - ENV.keep_if.should be_an_instance_of(Enumerator) - end - - it "deletes pairs through enumerator" do - enum = ENV.keep_if - enum.each { |k, v| k != "foo" } - ENV["foo"].should == nil - end - - it_behaves_like :enumeratorized_with_origin_size, :keep_if, ENV -end diff --git a/spec/rubyspec/core/env/key_spec.rb b/spec/rubyspec/core/env/key_spec.rb deleted file mode 100644 index b653b1b1a5..0000000000 --- a/spec/rubyspec/core/env/key_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../shared/include.rb', __FILE__) -require File.expand_path('../shared/key.rb', __FILE__) - -describe "ENV.key?" do - it_behaves_like(:env_include, :key?) -end - -describe "ENV.key" do - it_behaves_like(:env_key, :key) -end diff --git a/spec/rubyspec/core/env/keys_spec.rb b/spec/rubyspec/core/env/keys_spec.rb deleted file mode 100644 index d79919b79d..0000000000 --- a/spec/rubyspec/core/env/keys_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe "ENV.keys" do - - it "returns all the keys" do - ENV.keys.sort.should == ENV.to_hash.keys.sort - end - - it "returns the keys in the locale encoding" do - ENV.keys.each do |key| - key.encoding.should == Encoding.find('locale') - end - end -end diff --git a/spec/rubyspec/core/env/length_spec.rb b/spec/rubyspec/core/env/length_spec.rb deleted file mode 100644 index 83d1b58c74..0000000000 --- a/spec/rubyspec/core/env/length_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../shared/length.rb', __FILE__) - -describe "ENV.length" do - it_behaves_like(:env_length, :length) -end diff --git a/spec/rubyspec/core/env/member_spec.rb b/spec/rubyspec/core/env/member_spec.rb deleted file mode 100644 index 25aa71e973..0000000000 --- a/spec/rubyspec/core/env/member_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../shared/include.rb', __FILE__) - -describe "ENV.member?" do - it_behaves_like(:env_include, :member?) -end diff --git a/spec/rubyspec/core/env/rassoc_spec.rb b/spec/rubyspec/core/env/rassoc_spec.rb deleted file mode 100644 index 3a86e7e158..0000000000 --- a/spec/rubyspec/core/env/rassoc_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe "ENV.rassoc" do - after :each do - ENV.delete("foo") - end - - it "returns an array of the key and value of the environment variable with the given value" do - ENV["foo"] = "bar" - ENV.rassoc("bar").should == ["foo", "bar"] - end - - it "returns nil if no environment variable with the given value exists" do - ENV.rassoc("bar").should == nil - end - - it "returns the value element coerced with #to_str" do - ENV["foo"] = "bar" - v = mock('value') - v.should_receive(:to_str).and_return("bar") - ENV.rassoc(v).should == ["foo", "bar"] - end -end diff --git a/spec/rubyspec/core/env/rehash_spec.rb b/spec/rubyspec/core/env/rehash_spec.rb deleted file mode 100644 index 14fb93ef07..0000000000 --- a/spec/rubyspec/core/env/rehash_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) diff --git a/spec/rubyspec/core/env/reject_spec.rb b/spec/rubyspec/core/env/reject_spec.rb deleted file mode 100644 index 0da84425b6..0000000000 --- a/spec/rubyspec/core/env/reject_spec.rb +++ /dev/null @@ -1,77 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__) - -describe "ENV.reject!" do - it "rejects entries based on key" do - ENV["foo"] = "bar" - ENV.reject! { |k, v| k == "foo" } - ENV["foo"].should == nil - end - - it "rejects entries based on value" do - ENV["foo"] = "bar" - ENV.reject! { |k, v| v == "bar" } - ENV["foo"].should == nil - end - - it "returns itself or nil" do - ENV.reject! { false }.should == nil - ENV["foo"] = "bar" - ENV.reject! { |k, v| k == "foo" }.should == ENV - ENV["foo"].should == nil - end - - it "returns an Enumerator if called without a block" do - ENV.reject!.should be_an_instance_of(Enumerator) - end - - it "doesn't raise if empty" do - orig = ENV.to_hash - begin - ENV.clear - lambda { ENV.reject! }.should_not raise_error(LocalJumpError) - ensure - ENV.replace orig - end - end - - it_behaves_like :enumeratorized_with_origin_size, :reject!, ENV -end - -describe "ENV.reject" do - it "rejects entries based on key" do - ENV["foo"] = "bar" - e = ENV.reject { |k, v| k == "foo" } - e["foo"].should == nil - ENV["foo"].should == "bar" - ENV["foo"] = nil - end - - it "rejects entries based on value" do - ENV["foo"] = "bar" - e = ENV.reject { |k, v| v == "bar" } - e["foo"].should == nil - ENV["foo"].should == "bar" - ENV["foo"] = nil - end - - it "returns a Hash" do - ENV.reject { false }.should be_kind_of(Hash) - end - - it "returns an Enumerator if called without a block" do - ENV.reject.should be_an_instance_of(Enumerator) - end - - it "doesn't raise if empty" do - orig = ENV.to_hash - begin - ENV.clear - lambda { ENV.reject }.should_not raise_error(LocalJumpError) - ensure - ENV.replace orig - end - end - - it_behaves_like :enumeratorized_with_origin_size, :reject, ENV -end diff --git a/spec/rubyspec/core/env/replace_spec.rb b/spec/rubyspec/core/env/replace_spec.rb deleted file mode 100644 index 0c11e173ac..0000000000 --- a/spec/rubyspec/core/env/replace_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe "ENV.replace" do - - it "replaces ENV with a Hash" do - ENV["foo"] = "bar" - e = ENV.reject { |k, v| k == "foo" } - e["baz"] = "bam" - ENV.replace e - ENV["foo"].should == nil - ENV["baz"].should == "bam" - ENV.delete "baz" - end - -end diff --git a/spec/rubyspec/core/env/select_spec.rb b/spec/rubyspec/core/env/select_spec.rb deleted file mode 100644 index 8261ff593a..0000000000 --- a/spec/rubyspec/core/env/select_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__) - -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) - end - - it_behaves_like :enumeratorized_with_origin_size, :select!, ENV -end - -describe "ENV.select" 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" - end - - it "returns an Enumerator when no block is given" do - ENV.select.should be_an_instance_of(Enumerator) - end - - it_behaves_like :enumeratorized_with_origin_size, :select, ENV -end diff --git a/spec/rubyspec/core/env/shared/each.rb b/spec/rubyspec/core/env/shared/each.rb deleted file mode 100644 index 494fd5cee1..0000000000 --- a/spec/rubyspec/core/env/shared/each.rb +++ /dev/null @@ -1,65 +0,0 @@ -require File.expand_path('../../../enumerable/shared/enumeratorized', __FILE__) - -describe :env_each, shared: true do - it "returns each pair" do - orig = ENV.to_hash - e = [] - begin - ENV.clear - ENV["foo"] = "bar" - ENV["baz"] = "boo" - ENV.send(@method) { |k, v| e << [k, v] } - e.should include(["foo", "bar"]) - e.should include(["baz", "boo"]) - ensure - ENV.replace orig - end - end - - it "returns an Enumerator if called without a block" do - ENV.send(@method).should be_an_instance_of(Enumerator) - end - - before :all do - @object = ENV - end - it_should_behave_like :enumeratorized_with_origin_size - - with_feature :encoding do - describe "with encoding" do - before :each do - @external = Encoding.default_external - @internal = Encoding.default_internal - - Encoding.default_external = Encoding::ASCII_8BIT - - @locale_encoding = Encoding.find "locale" - end - - after :each do - Encoding.default_external = @external - Encoding.default_internal = @internal - end - - it "uses the locale encoding when Encoding.default_internal is nil" do - Encoding.default_internal = nil - - ENV.send(@method) do |key, value| - key.encoding.should equal(@locale_encoding) - value.encoding.should equal(@locale_encoding) - end - end - - it "transcodes from the locale encoding to Encoding.default_internal if set" do - Encoding.default_internal = internal = Encoding::IBM437 - - ENV.send(@method) do |key, value| - key.encoding.should equal(internal) - if value.ascii_only? - value.encoding.should equal(internal) - end - end - end - end - end -end diff --git a/spec/rubyspec/core/env/shared/include.rb b/spec/rubyspec/core/env/shared/include.rb deleted file mode 100644 index 8d8311dcf2..0000000000 --- a/spec/rubyspec/core/env/shared/include.rb +++ /dev/null @@ -1,11 +0,0 @@ -describe :env_include, shared: true do - it "returns true if ENV has the key" do - ENV["foo"] = "bar" - ENV.send(@method, "foo").should == true - ENV.delete "foo" - end - - it "returns false if ENV doesn't include the key" do - ENV.send(@method, "should_never_be_set").should == false - end -end diff --git a/spec/rubyspec/core/env/shared/key.rb b/spec/rubyspec/core/env/shared/key.rb deleted file mode 100644 index 5e6c21840f..0000000000 --- a/spec/rubyspec/core/env/shared/key.rb +++ /dev/null @@ -1,15 +0,0 @@ -describe :env_key, shared: true do - it "needs to be reviewed for completeness" - - it "returns the index associated with the passed value" do - ENV["foo"] = "bar" - ENV.send(@method, "bar").should == "foo" - ENV.delete "foo" - end - - it "returns nil if the passed value is not found" do - ENV.send(@method, "should_never_be_set").should be_nil - end -end - - diff --git a/spec/rubyspec/core/env/shared/length.rb b/spec/rubyspec/core/env/shared/length.rb deleted file mode 100644 index 6d788a3f4a..0000000000 --- a/spec/rubyspec/core/env/shared/length.rb +++ /dev/null @@ -1,13 +0,0 @@ -describe :env_length, shared: true do - it "returns the number of ENV entries" do - orig = ENV.to_hash - begin - ENV.clear - ENV["foo"] = "bar" - ENV["baz"] = "boo" - ENV.send(@method).should == 2 - ensure - ENV.replace orig - end - end -end diff --git a/spec/rubyspec/core/env/shared/store.rb b/spec/rubyspec/core/env/shared/store.rb deleted file mode 100644 index 4949ca8c73..0000000000 --- a/spec/rubyspec/core/env/shared/store.rb +++ /dev/null @@ -1,56 +0,0 @@ -describe :env_store, shared: true do - after :each do - ENV.delete("foo") - end - - it "sets the environment variable to the given value" do - ENV.send(@method, "foo", "bar") - ENV["foo"].should == "bar" - end - - it "returns the value" do - value = "bar" - ENV.send(@method, "foo", value).should equal(value) - end - - it "deletes the environment variable when the value is nil" do - ENV["foo"] = "bar" - ENV.send(@method, "foo", nil) - ENV.key?("foo").should be_false - end - - it "coerces the key argument with #to_str" do - k = mock("key") - k.should_receive(:to_str).and_return("foo") - ENV.send(@method, k, "bar") - ENV["foo"].should == "bar" - end - - it "coerces the value argument with #to_str" do - v = mock("value") - v.should_receive(:to_str).and_return("bar") - ENV.send(@method, "foo", v) - ENV["foo"].should == "bar" - end - - it "raises TypeError when the key is not coercible to String" do - lambda { ENV.send(@method, Object.new, "bar") }.should raise_error(TypeError) - end - - it "raises TypeError when the value is not coercible to String" do - lambda { ENV.send(@method, "foo", Object.new) }.should raise_error(TypeError) - end - - it "raises Errno::EINVAL when the key contains the '=' character" do - lambda { ENV.send(@method, "foo=", "bar") }.should raise_error(Errno::EINVAL) - end - - it "raises Errno::EINVAL when the key is an empty string" do - lambda { ENV.send(@method, "", "bar") }.should raise_error(Errno::EINVAL) - end - - it "does nothing when the key is not a valid environment variable key and the value is nil" do - ENV.send(@method, "foo=", nil) - ENV.key?("foo=").should be_false - end -end diff --git a/spec/rubyspec/core/env/shared/to_hash.rb b/spec/rubyspec/core/env/shared/to_hash.rb deleted file mode 100644 index 3bfbc415f7..0000000000 --- a/spec/rubyspec/core/env/shared/to_hash.rb +++ /dev/null @@ -1,22 +0,0 @@ -describe :env_to_hash, shared: true do - it "returns the ENV as a hash" do - ENV["foo"] = "bar" - h = ENV.send(@method) - h.should be_an_instance_of(Hash) - h["foo"].should == "bar" - ENV.delete "foo" - end - - it "uses the locale encoding for keys" do - ENV.send(@method).keys.all? {|k| k.encoding == Encoding.find('locale') }.should be_true - end - - it "uses the locale encoding for values" do - ENV.send(@method).values.all? {|v| v.encoding == Encoding.find('locale') }.should be_true - end - - it "duplicates the ENV when converting to a Hash" do - h = ENV.send(@method) - h.object_id.should_not == ENV.object_id - end -end diff --git a/spec/rubyspec/core/env/shared/value.rb b/spec/rubyspec/core/env/shared/value.rb deleted file mode 100644 index d9ee90f12d..0000000000 --- a/spec/rubyspec/core/env/shared/value.rb +++ /dev/null @@ -1,11 +0,0 @@ -describe :env_value, shared: true do - it "returns true if ENV has the value" do - ENV["foo"] = "bar" - ENV.send(@method, "bar").should == true - ENV["foo"] = nil - end - - it "returns false if ENV doesn't have the value" do - ENV.send(@method, "this_value_should_never_exist").should == false - end -end diff --git a/spec/rubyspec/core/env/shift_spec.rb b/spec/rubyspec/core/env/shift_spec.rb deleted file mode 100644 index bae6a17ba0..0000000000 --- a/spec/rubyspec/core/env/shift_spec.rb +++ /dev/null @@ -1,59 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe "ENV.shift" do - it "returns a pair and deletes it" do - ENV.empty?.should == false - orig = ENV.to_hash - begin - pair = ENV.shift - ENV.has_key?(pair.first).should == false - ensure - ENV.replace orig - end - ENV.has_key?(pair.first).should == true - end - - it "returns nil if ENV.empty?" do - orig = ENV.to_hash - begin - ENV.clear - ENV.shift.should == nil - ensure - ENV.replace orig - end - end -end - -with_feature :encoding do - describe "ENV.shift" do - before :each do - @orig = ENV.to_hash - @external = Encoding.default_external - @internal = Encoding.default_internal - - Encoding.default_external = Encoding::ASCII_8BIT - end - - after :each do - Encoding.default_external = @external - Encoding.default_internal = @internal - ENV.replace @orig - end - - it "uses the locale encoding if Encoding.default_internal is nil" do - Encoding.default_internal = nil - - pair = ENV.shift - pair.first.encoding.should equal(Encoding.find("locale")) - pair.last.encoding.should equal(Encoding.find("locale")) - end - - it "transcodes from the locale encoding to Encoding.default_internal if set" do - Encoding.default_internal = Encoding::IBM437 - - pair = ENV.shift - pair.first.encoding.should equal(Encoding::IBM437) - pair.last.encoding.should equal(Encoding::IBM437) - end - end -end diff --git a/spec/rubyspec/core/env/size_spec.rb b/spec/rubyspec/core/env/size_spec.rb deleted file mode 100644 index 882ceac485..0000000000 --- a/spec/rubyspec/core/env/size_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../shared/length.rb', __FILE__) - -describe "ENV.size" do - it_behaves_like(:env_length, :size) -end diff --git a/spec/rubyspec/core/env/store_spec.rb b/spec/rubyspec/core/env/store_spec.rb deleted file mode 100644 index 1ee5ce020e..0000000000 --- a/spec/rubyspec/core/env/store_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../shared/store.rb', __FILE__) - -describe "ENV.store" do - it_behaves_like(:env_store, :store) -end diff --git a/spec/rubyspec/core/env/to_a_spec.rb b/spec/rubyspec/core/env/to_a_spec.rb deleted file mode 100644 index ffb66b8767..0000000000 --- a/spec/rubyspec/core/env/to_a_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe "ENV.to_a" do - - it "returns the ENV as an array" do - ENV["foo"] = "bar" - a = ENV.to_a - a.is_a?(Array).should == true - a.find { |e| e.first == "foo" }.should == ["foo", "bar"] - ENV.delete "foo" - end - - it "returns the entries in the locale encoding" do - ENV.to_a.each do |key, value| - key.encoding.should == Encoding.find('locale') - value.encoding.should == Encoding.find('locale') - end - end -end diff --git a/spec/rubyspec/core/env/to_h_spec.rb b/spec/rubyspec/core/env/to_h_spec.rb deleted file mode 100644 index d0fef5382b..0000000000 --- a/spec/rubyspec/core/env/to_h_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../shared/to_hash.rb', __FILE__) - -describe "ENV.to_hash" do - it_behaves_like(:env_to_hash, :to_h) -end diff --git a/spec/rubyspec/core/env/to_hash_spec.rb b/spec/rubyspec/core/env/to_hash_spec.rb deleted file mode 100644 index 3362fa9307..0000000000 --- a/spec/rubyspec/core/env/to_hash_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../shared/to_hash.rb', __FILE__) - -describe "ENV.to_hash" do - it_behaves_like(:env_to_hash, :to_hash) -end diff --git a/spec/rubyspec/core/env/to_s_spec.rb b/spec/rubyspec/core/env/to_s_spec.rb deleted file mode 100644 index 10aca09723..0000000000 --- a/spec/rubyspec/core/env/to_s_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe "ENV.to_s" do - it "returns \"ENV\"" do - ENV.to_s.should == "ENV" - end -end diff --git a/spec/rubyspec/core/env/update_spec.rb b/spec/rubyspec/core/env/update_spec.rb deleted file mode 100644 index 7ebfbb313d..0000000000 --- a/spec/rubyspec/core/env/update_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe "ENV.update" do - - it "adds the parameter hash to ENV" do - ENV["foo"].should == nil - ENV.update "foo" => "bar" - ENV["foo"].should == "bar" - ENV.delete "foo" - end - - it "yields key, the old value and the new value when replacing entries" do - ENV.update "foo" => "bar" - ENV["foo"].should == "bar" - ENV.update("foo" => "boo") do |key, old, new| - key.should == "foo" - old.should == "bar" - new.should == "boo" - "rab" - end - ENV["foo"].should == "rab" - ENV.delete "foo" - end - -end diff --git a/spec/rubyspec/core/env/value_spec.rb b/spec/rubyspec/core/env/value_spec.rb deleted file mode 100644 index c7eb7c5376..0000000000 --- a/spec/rubyspec/core/env/value_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../shared/value.rb', __FILE__) - -describe "ENV.value?" do - it_behaves_like(:env_value, :value?) -end diff --git a/spec/rubyspec/core/env/values_at_spec.rb b/spec/rubyspec/core/env/values_at_spec.rb deleted file mode 100644 index efc7de2a05..0000000000 --- a/spec/rubyspec/core/env/values_at_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe "ENV.values_at" do - - it "returns an array of the values referenced by the parameters as keys" do - ENV["foo"] = "oof" - ENV["bar"] = "rab" - ENV.values_at.should == [] - ENV.values_at("bar", "foo").should == ["rab", "oof"] - ENV.delete "foo" - ENV.delete "bar" - end - - it "uses the locale encoding" do - ENV.values_at(ENV.keys.first).first.encoding.should == Encoding.find('locale') - end -end diff --git a/spec/rubyspec/core/env/values_spec.rb b/spec/rubyspec/core/env/values_spec.rb deleted file mode 100644 index 3a620bdb8b..0000000000 --- a/spec/rubyspec/core/env/values_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe "ENV.values" do - - it "returns an array of the values" do - orig = ENV.to_hash - begin - ENV.replace "a" => "b", "c" => "d" - a = ENV.values - a.sort.should == ["b", "d"] - ensure - ENV.replace orig - end - end - - it "uses the locale encoding" do - ENV.values.each do |value| - value.encoding.should == Encoding.find('locale') - end - end -end |