summaryrefslogtreecommitdiff
path: root/spec/ruby/library/stringscanner/exist_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/stringscanner/exist_spec.rb')
-rw-r--r--spec/ruby/library/stringscanner/exist_spec.rb18
1 files changed, 7 insertions, 11 deletions
diff --git a/spec/ruby/library/stringscanner/exist_spec.rb b/spec/ruby/library/stringscanner/exist_spec.rb
index 3f40c7a5a5..2207622366 100644
--- a/spec/ruby/library/stringscanner/exist_spec.rb
+++ b/spec/ruby/library/stringscanner/exist_spec.rb
@@ -32,7 +32,7 @@ describe "StringScanner#exist?" do
it "raises TypeError if given a String" do
-> {
@s.exist?('T')
- }.should raise_error(TypeError, 'wrong argument type String (expected Regexp)')
+ }.should.raise(TypeError, 'wrong argument type String (expected Regexp)')
end
end
@@ -57,34 +57,32 @@ describe "StringScanner#exist?" do
it "returns nil when matching failed" do
@s.exist?(/(?<a>2008)/)
@s.should_not.matched?
- @s[:a].should be_nil
+ @s[:a].should == nil
end
end
version_is StringScanner::Version, "3.1.1" do # ruby_version_is "3.4"
context "when #exist? was called with a String pattern" do
# https://github.com/ruby/strscan/issues/139
- ruby_version_is ""..."3.5" do # Don't run on 3.5.0dev that already contains not released fixes
version_is StringScanner::Version, "3.1.1"..."3.1.3" do # ruby_version_is "3.4.0"..."3.4.3"
it "returns nil when matching succeeded" do
@s.exist?("This")
@s.should.matched?
- @s[:a].should be_nil
+ @s[:a].should == nil
end
end
- end
version_is StringScanner::Version, "3.1.3" do # ruby_version_is "3.4.3"
it "raises IndexError when matching succeeded" do
@s.exist?("This")
@s.should.matched?
- -> { @s[:a] }.should raise_error(IndexError)
+ -> { @s[:a] }.should.raise(IndexError)
end
end
it "returns nil when matching failed" do
@s.exist?("2008")
@s.should_not.matched?
- @s[:a].should be_nil
+ @s[:a].should == nil
end
it "returns a matching substring when given Integer index" do
@@ -93,7 +91,6 @@ describe "StringScanner#exist?" do
end
# https://github.com/ruby/strscan/issues/135
- ruby_version_is ""..."3.5" do # Don't run on 3.5.0dev that already contains not released fixes
version_is StringScanner::Version, "3.1.1"..."3.1.3" do # ruby_version_is "3.4.0"..."3.4.3"
it "ignores the previous matching with Regexp" do
@s.exist?(/(?<a>This)/)
@@ -102,10 +99,9 @@ describe "StringScanner#exist?" do
@s.exist?("This")
@s.should.matched?
- @s[:a].should be_nil
+ @s[:a].should == nil
end
end
- end
version_is StringScanner::Version, "3.1.3" do # ruby_version_is "3.4.0"..."3.4.3"
it "ignores the previous matching with Regexp" do
@s.exist?(/(?<a>This)/)
@@ -114,7 +110,7 @@ describe "StringScanner#exist?" do
@s.exist?("This")
@s.should.matched?
- -> { @s[:a] }.should raise_error(IndexError)
+ -> { @s[:a] }.should.raise(IndexError)
end
end
end