aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/library/getoptlong/initialize_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/getoptlong/initialize_spec.rb')
-rw-r--r--spec/ruby/library/getoptlong/initialize_spec.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/ruby/library/getoptlong/initialize_spec.rb b/spec/ruby/library/getoptlong/initialize_spec.rb
new file mode 100644
index 0000000000..6ac46b8b5d
--- /dev/null
+++ b/spec/ruby/library/getoptlong/initialize_spec.rb
@@ -0,0 +1,28 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'getoptlong'
+
+describe "GetoptLong#initialize" do
+ it "sets ordering to REQUIRE_ORDER if ENV['POSIXLY_CORRECT'] is set" do
+ begin
+ old_env_value = ENV["POSIXLY_CORRECT"]
+ ENV["POSIXLY_CORRECT"] = ""
+
+ opt = GetoptLong.new
+ opt.ordering.should == GetoptLong::REQUIRE_ORDER
+ ensure
+ ENV["POSIXLY_CORRECT"] = old_env_value
+ end
+ end
+
+ it "sets ordering to PERMUTE if ENV['POSIXLY_CORRECT'] is not set" do
+ begin
+ old_env_value = ENV["POSIXLY_CORRECT"]
+ ENV["POSIXLY_CORRECT"] = nil
+
+ opt = GetoptLong.new
+ opt.ordering.should == GetoptLong::PERMUTE
+ ensure
+ ENV["POSIXLY_CORRECT"] = old_env_value
+ end
+ end
+end