summaryrefslogtreecommitdiff
path: root/spec/ruby/library/English
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/English')
-rw-r--r--spec/ruby/library/English/English_spec.rb88
-rw-r--r--spec/ruby/library/English/alias_spec.rb14
2 files changed, 53 insertions, 49 deletions
diff --git a/spec/ruby/library/English/English_spec.rb b/spec/ruby/library/English/English_spec.rb
index 75a336eba2..bdc3774608 100644
--- a/spec/ruby/library/English/English_spec.rb
+++ b/spec/ruby/library/English/English_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'English'
@@ -7,165 +7,155 @@ describe "English" do
begin
raise "error"
rescue
- $ERROR_INFO.should_not be_nil
+ $ERROR_INFO.should_not == nil
$ERROR_INFO.should == $!
end
- $ERROR_INFO.should be_nil
+ $ERROR_INFO.should == nil
end
it "aliases $ERROR_POSITION to $@" do
begin
raise "error"
rescue
- $ERROR_POSITION.should_not be_nil
+ $ERROR_POSITION.should_not == nil
$ERROR_POSITION.should == $@
end
- $ERROR_POSITION.should be_nil
+ $ERROR_POSITION.should == nil
end
it "aliases $FS to $;" do
original = $;
- $; = ","
- $FS.should_not be_nil
+ suppress_warning {$; = ","}
+ $FS.should_not == nil
$FS.should == $;
- $; = original
+ suppress_warning {$; = original}
end
it "aliases $FIELD_SEPARATOR to $;" do
original = $;
- $; = ","
- $FIELD_SEPARATOR.should_not be_nil
+ suppress_warning {$; = ","}
+ $FIELD_SEPARATOR.should_not == nil
$FIELD_SEPARATOR.should == $;
- $; = original
+ suppress_warning {$; = original}
end
it "aliases $OFS to $," do
original = $,
- $, = "|"
- $OFS.should_not be_nil
+ suppress_warning {$, = "|"}
+ $OFS.should_not == nil
$OFS.should == $,
- $, = original
+ suppress_warning {$, = original}
end
it "aliases $OUTPUT_FIELD_SEPARATOR to $," do
original = $,
- $, = "|"
- $OUTPUT_FIELD_SEPARATOR.should_not be_nil
+ suppress_warning {$, = "|"}
+ $OUTPUT_FIELD_SEPARATOR.should_not == nil
$OUTPUT_FIELD_SEPARATOR.should == $,
- $, = original
+ suppress_warning {$, = original}
end
it "aliases $RS to $/" do
- $RS.should_not be_nil
+ $RS.should_not == nil
$RS.should == $/
end
it "aliases $INPUT_RECORD_SEPARATOR to $/" do
- $INPUT_RECORD_SEPARATOR.should_not be_nil
+ $INPUT_RECORD_SEPARATOR.should_not == nil
$INPUT_RECORD_SEPARATOR.should == $/
end
it "aliases $ORS to $\\" do
original = $\
- $\ = "\t"
- $ORS.should_not be_nil
+ suppress_warning {$\ = "\t"}
+ $ORS.should_not == nil
$ORS.should == $\
- $\ = original
+ suppress_warning {$\ = original}
end
it "aliases $OUTPUT_RECORD_SEPARATOR to $\\" do
original = $\
- $\ = "\t"
- $OUTPUT_RECORD_SEPARATOR.should_not be_nil
+ suppress_warning {$\ = "\t"}
+ $OUTPUT_RECORD_SEPARATOR.should_not == nil
$OUTPUT_RECORD_SEPARATOR.should == $\
- $\ = original
+ suppress_warning {$\ = original}
end
it "aliases $INPUT_LINE_NUMBER to $." do
- $INPUT_LINE_NUMBER.should_not be_nil
+ $INPUT_LINE_NUMBER.should_not == nil
$INPUT_LINE_NUMBER.should == $.
end
it "aliases $NR to $." do
- $NR.should_not be_nil
+ $NR.should_not == nil
$NR.should == $.
end
it "aliases $LAST_READ_LINE to $_ needs to be reviewed for spec completeness"
it "aliases $DEFAULT_OUTPUT to $>" do
- $DEFAULT_OUTPUT.should_not be_nil
+ $DEFAULT_OUTPUT.should_not == nil
$DEFAULT_OUTPUT.should == $>
end
it "aliases $DEFAULT_INPUT to $<" do
- $DEFAULT_INPUT.should_not be_nil
+ $DEFAULT_INPUT.should_not == nil
$DEFAULT_INPUT.should == $<
end
it "aliases $PID to $$" do
- $PID.should_not be_nil
+ $PID.should_not == nil
$PID.should == $$
end
it "aliases $PID to $$" do
- $PID.should_not be_nil
+ $PID.should_not == nil
$PID.should == $$
end
it "aliases $PROCESS_ID to $$" do
- $PROCESS_ID.should_not be_nil
+ $PROCESS_ID.should_not == nil
$PROCESS_ID.should == $$
end
it "aliases $CHILD_STATUS to $?" do
ruby_exe('exit 0')
- $CHILD_STATUS.should_not be_nil
+ $CHILD_STATUS.should_not == nil
$CHILD_STATUS.should == $?
end
it "aliases $LAST_MATCH_INFO to $~" do
/c(a)t/ =~ "cat"
- $LAST_MATCH_INFO.should_not be_nil
+ $LAST_MATCH_INFO.should_not == nil
$LAST_MATCH_INFO.should == $~
end
- it "aliases $IGNORECASE to $=" do
- $VERBOSE, verbose = nil, $VERBOSE
- begin
- $IGNORECASE.should_not be_nil
- $IGNORECASE.should == $=
- ensure
- $VERBOSE = verbose
- end
- end
-
it "aliases $ARGV to $*" do
- $ARGV.should_not be_nil
+ $ARGV.should_not == nil
$ARGV.should == $*
end
it "aliases $MATCH to $&" do
/c(a)t/ =~ "cat"
- $MATCH.should_not be_nil
+ $MATCH.should_not == nil
$MATCH.should == $&
end
it "aliases $PREMATCH to $`" do
/c(a)t/ =~ "cat"
- $PREMATCH.should_not be_nil
+ $PREMATCH.should_not == nil
$PREMATCH.should == $`
end
it "aliases $POSTMATCH to $'" do
/c(a)t/ =~ "cat"
- $POSTMATCH.should_not be_nil
+ $POSTMATCH.should_not == nil
$POSTMATCH.should == $'
end
it "aliases $LAST_PAREN_MATCH to $+" do
/c(a)t/ =~ "cat"
- $LAST_PAREN_MATCH.should_not be_nil
+ $LAST_PAREN_MATCH.should_not == nil
$LAST_PAREN_MATCH.should == $+
end
end
diff --git a/spec/ruby/library/English/alias_spec.rb b/spec/ruby/library/English/alias_spec.rb
new file mode 100644
index 0000000000..3ff92f964d
--- /dev/null
+++ b/spec/ruby/library/English/alias_spec.rb
@@ -0,0 +1,14 @@
+require_relative '../../spec_helper'
+require 'English'
+
+describe "English" do
+ it "aliases $! to $ERROR_INFO and $ERROR_INFO still returns an Exception with a backtrace" do
+ exception = (1 / 0 rescue $ERROR_INFO)
+ exception.should.is_a?(Exception)
+ exception.backtrace.should.is_a?(Array)
+ end
+
+ it "aliases $@ to $ERROR_POSITION and $ERROR_POSITION still returns a backtrace" do
+ (1 / 0 rescue $ERROR_POSITION).should.is_a?(Array)
+ end
+end