summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2024-01-11 11:34:25 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2024-01-17 08:28:31 +0900
commitafb30eb2654253c938fbf47dbb6e24c2a3b74625 (patch)
treebc7a577b06b118da4115e1e493f25e2c5dad296d
parent05e798269fd4471fbc87f3e4de7728b28b6a0915 (diff)
spec/mspec/tool/wrap_with_guard.rb 'ruby_version_is ""..."3.4"' spec/ruby/library/base64/**/*_spec.rb
-rw-r--r--spec/ruby/library/base64/decode64_spec.rb41
-rw-r--r--spec/ruby/library/base64/encode64_spec.rb33
-rw-r--r--spec/ruby/library/base64/strict_decode64_spec.rb77
-rw-r--r--spec/ruby/library/base64/strict_encode64_spec.rb27
-rw-r--r--spec/ruby/library/base64/urlsafe_decode64_spec.rb27
-rw-r--r--spec/ruby/library/base64/urlsafe_encode64_spec.rb29
6 files changed, 126 insertions, 108 deletions
diff --git a/spec/ruby/library/base64/decode64_spec.rb b/spec/ruby/library/base64/decode64_spec.rb
index 6dd33dddfe..c587c82d28 100644
--- a/spec/ruby/library/base64/decode64_spec.rb
+++ b/spec/ruby/library/base64/decode64_spec.rb
@@ -1,29 +1,32 @@
require_relative '../../spec_helper'
-require 'base64'
+ruby_version_is ""..."3.4" do
-describe "Base64#decode64" do
- it "returns the Base64-decoded version of the given string" do
- Base64.decode64("U2VuZCByZWluZm9yY2VtZW50cw==\n").should == "Send reinforcements"
- end
+ require 'base64'
- it "returns the Base64-decoded version of the given shared string" do
- Base64.decode64("base64: U2VuZCByZWluZm9yY2VtZW50cw==\n".split(" ").last).should == "Send reinforcements"
- end
+ describe "Base64#decode64" do
+ it "returns the Base64-decoded version of the given string" do
+ Base64.decode64("U2VuZCByZWluZm9yY2VtZW50cw==\n").should == "Send reinforcements"
+ end
- it "returns the Base64-decoded version of the given string with wrong padding" do
- Base64.decode64("XU2VuZCByZWluZm9yY2VtZW50cw===").should == "]M\x95\xB9\x90\x81\xC9\x95\xA5\xB9\x99\xBD\xC9\x8D\x95\xB5\x95\xB9\xD1\xCC".b
- end
+ it "returns the Base64-decoded version of the given shared string" do
+ Base64.decode64("base64: U2VuZCByZWluZm9yY2VtZW50cw==\n".split(" ").last).should == "Send reinforcements"
+ end
- it "returns the Base64-decoded version of the given string that contains an invalid character" do
- Base64.decode64("%3D").should == "\xDC".b
- end
+ it "returns the Base64-decoded version of the given string with wrong padding" do
+ Base64.decode64("XU2VuZCByZWluZm9yY2VtZW50cw===").should == "]M\x95\xB9\x90\x81\xC9\x95\xA5\xB9\x99\xBD\xC9\x8D\x95\xB5\x95\xB9\xD1\xCC".b
+ end
- it "returns a binary encoded string" do
- Base64.decode64("SEk=").encoding.should == Encoding::BINARY
- end
+ it "returns the Base64-decoded version of the given string that contains an invalid character" do
+ Base64.decode64("%3D").should == "\xDC".b
+ end
+
+ it "returns a binary encoded string" do
+ Base64.decode64("SEk=").encoding.should == Encoding::BINARY
+ end
- it "decodes without padding suffix ==" do
- Base64.decode64("eyJrZXkiOnsibiI6InR0dCJ9fQ").should == "{\"key\":{\"n\":\"ttt\"}}"
+ it "decodes without padding suffix ==" do
+ Base64.decode64("eyJrZXkiOnsibiI6InR0dCJ9fQ").should == "{\"key\":{\"n\":\"ttt\"}}"
+ end
end
end
diff --git a/spec/ruby/library/base64/encode64_spec.rb b/spec/ruby/library/base64/encode64_spec.rb
index 64de6257bc..e31c6604f0 100644
--- a/spec/ruby/library/base64/encode64_spec.rb
+++ b/spec/ruby/library/base64/encode64_spec.rb
@@ -1,23 +1,26 @@
require_relative '../../spec_helper'
-require 'base64'
+ruby_version_is ""..."3.4" do
-describe "Base64#encode64" do
- it "returns the Base64-encoded version of the given string" do
- Base64.encode64("Now is the time for all good coders\nto learn Ruby").should ==
- "Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g\nUnVieQ==\n"
- end
+ require 'base64'
- it "returns the Base64-encoded version of the given string" do
- Base64.encode64('Send reinforcements').should == "U2VuZCByZWluZm9yY2VtZW50cw==\n"
- end
+ describe "Base64#encode64" do
+ it "returns the Base64-encoded version of the given string" do
+ Base64.encode64("Now is the time for all good coders\nto learn Ruby").should ==
+ "Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g\nUnVieQ==\n"
+ end
- it "returns the Base64-encoded version of the given shared string" do
- Base64.encode64("Now is the time for all good coders\nto learn Ruby".split("\n").last).should ==
- "dG8gbGVhcm4gUnVieQ==\n"
- end
+ it "returns the Base64-encoded version of the given string" do
+ Base64.encode64('Send reinforcements').should == "U2VuZCByZWluZm9yY2VtZW50cw==\n"
+ end
+
+ it "returns the Base64-encoded version of the given shared string" do
+ Base64.encode64("Now is the time for all good coders\nto learn Ruby".split("\n").last).should ==
+ "dG8gbGVhcm4gUnVieQ==\n"
+ end
- it "returns a US_ASCII encoded string" do
- Base64.encode64("HI").encoding.should == Encoding::US_ASCII
+ it "returns a US_ASCII encoded string" do
+ Base64.encode64("HI").encoding.should == Encoding::US_ASCII
+ end
end
end
diff --git a/spec/ruby/library/base64/strict_decode64_spec.rb b/spec/ruby/library/base64/strict_decode64_spec.rb
index d258223c82..f4dd3a60fe 100644
--- a/spec/ruby/library/base64/strict_decode64_spec.rb
+++ b/spec/ruby/library/base64/strict_decode64_spec.rb
@@ -1,41 +1,44 @@
require_relative '../../spec_helper'
-require 'base64'
-
-describe "Base64#strict_decode64" do
- it "returns the Base64-decoded version of the given string" do
- Base64.strict_decode64("U2VuZCByZWluZm9yY2VtZW50cw==").should == "Send reinforcements"
- end
-
- it "returns the Base64-decoded version of the given shared string" do
- Base64.strict_decode64("base64: U2VuZCByZWluZm9yY2VtZW50cw==".split(" ").last).should == "Send reinforcements"
- end
-
- it "raises ArgumentError when the given string contains CR" do
- -> do
- Base64.strict_decode64("U2VuZCByZWluZm9yY2VtZW50cw==\r")
- end.should raise_error(ArgumentError)
- end
-
- it "raises ArgumentError when the given string contains LF" do
- -> do
- Base64.strict_decode64("U2VuZCByZWluZm9yY2VtZW50cw==\n")
- end.should raise_error(ArgumentError)
- end
-
- it "raises ArgumentError when the given string has wrong padding" do
- -> do
- Base64.strict_decode64("=U2VuZCByZWluZm9yY2VtZW50cw==")
- end.should raise_error(ArgumentError)
- end
-
- it "raises ArgumentError when the given string contains an invalid character" do
- -> do
- Base64.strict_decode64("%3D")
- end.should raise_error(ArgumentError)
- end
-
- it "returns a binary encoded string" do
- Base64.strict_decode64("SEk=").encoding.should == Encoding::BINARY
+ruby_version_is ""..."3.4" do
+
+ require 'base64'
+
+ describe "Base64#strict_decode64" do
+ it "returns the Base64-decoded version of the given string" do
+ Base64.strict_decode64("U2VuZCByZWluZm9yY2VtZW50cw==").should == "Send reinforcements"
+ end
+
+ it "returns the Base64-decoded version of the given shared string" do
+ Base64.strict_decode64("base64: U2VuZCByZWluZm9yY2VtZW50cw==".split(" ").last).should == "Send reinforcements"
+ end
+
+ it "raises ArgumentError when the given string contains CR" do
+ -> do
+ Base64.strict_decode64("U2VuZCByZWluZm9yY2VtZW50cw==\r")
+ end.should raise_error(ArgumentError)
+ end
+
+ it "raises ArgumentError when the given string contains LF" do
+ -> do
+ Base64.strict_decode64("U2VuZCByZWluZm9yY2VtZW50cw==\n")
+ end.should raise_error(ArgumentError)
+ end
+
+ it "raises ArgumentError when the given string has wrong padding" do
+ -> do
+ Base64.strict_decode64("=U2VuZCByZWluZm9yY2VtZW50cw==")
+ end.should raise_error(ArgumentError)
+ end
+
+ it "raises ArgumentError when the given string contains an invalid character" do
+ -> do
+ Base64.strict_decode64("%3D")
+ end.should raise_error(ArgumentError)
+ end
+
+ it "returns a binary encoded string" do
+ Base64.strict_decode64("SEk=").encoding.should == Encoding::BINARY
+ end
end
end
diff --git a/spec/ruby/library/base64/strict_encode64_spec.rb b/spec/ruby/library/base64/strict_encode64_spec.rb
index 7cabcf190c..c7f9f12a96 100644
--- a/spec/ruby/library/base64/strict_encode64_spec.rb
+++ b/spec/ruby/library/base64/strict_encode64_spec.rb
@@ -1,19 +1,22 @@
require_relative '../../spec_helper'
-require 'base64'
+ruby_version_is ""..."3.4" do
-describe "Base64#strict_encode64" do
- it "returns the Base64-encoded version of the given string" do
- Base64.strict_encode64("Now is the time for all good coders\nto learn Ruby").should ==
- "Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4gUnVieQ=="
- end
+ require 'base64'
- it "returns the Base64-encoded version of the given shared string" do
- Base64.strict_encode64("Now is the time for all good coders\nto learn Ruby".split("\n").last).should ==
- "dG8gbGVhcm4gUnVieQ=="
- end
+ describe "Base64#strict_encode64" do
+ it "returns the Base64-encoded version of the given string" do
+ Base64.strict_encode64("Now is the time for all good coders\nto learn Ruby").should ==
+ "Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4gUnVieQ=="
+ end
+
+ it "returns the Base64-encoded version of the given shared string" do
+ Base64.strict_encode64("Now is the time for all good coders\nto learn Ruby".split("\n").last).should ==
+ "dG8gbGVhcm4gUnVieQ=="
+ end
- it "returns a US_ASCII encoded string" do
- Base64.strict_encode64("HI").encoding.should == Encoding::US_ASCII
+ it "returns a US_ASCII encoded string" do
+ Base64.strict_encode64("HI").encoding.should == Encoding::US_ASCII
+ end
end
end
diff --git a/spec/ruby/library/base64/urlsafe_decode64_spec.rb b/spec/ruby/library/base64/urlsafe_decode64_spec.rb
index 1b813ee1b9..f9a46787f7 100644
--- a/spec/ruby/library/base64/urlsafe_decode64_spec.rb
+++ b/spec/ruby/library/base64/urlsafe_decode64_spec.rb
@@ -1,19 +1,22 @@
require_relative '../../spec_helper'
-require 'base64'
+ruby_version_is ""..."3.4" do
-describe "Base64#urlsafe_decode64" do
- it "uses '_' instead of '/'" do
- decoded = Base64.urlsafe_decode64("V2hlcmUgYW0gST8gV2hvIGFtIEk_IEFtIEk_IEk_")
- decoded.should == 'Where am I? Who am I? Am I? I?'
- end
+ require 'base64'
- it "uses '-' instead of '+'" do
- decoded = Base64.urlsafe_decode64('IkJlaW5nIGRpc2ludGVncmF0ZWQgbWFrZXMgbWUgdmUtcnkgYW4tZ3J5ISIgPGh1ZmYsIGh1ZmY-')
- decoded.should == '"Being disintegrated makes me ve-ry an-gry!" <huff, huff>'
- end
+ describe "Base64#urlsafe_decode64" do
+ it "uses '_' instead of '/'" do
+ decoded = Base64.urlsafe_decode64("V2hlcmUgYW0gST8gV2hvIGFtIEk_IEFtIEk_IEk_")
+ decoded.should == 'Where am I? Who am I? Am I? I?'
+ end
+
+ it "uses '-' instead of '+'" do
+ decoded = Base64.urlsafe_decode64('IkJlaW5nIGRpc2ludGVncmF0ZWQgbWFrZXMgbWUgdmUtcnkgYW4tZ3J5ISIgPGh1ZmYsIGh1ZmY-')
+ decoded.should == '"Being disintegrated makes me ve-ry an-gry!" <huff, huff>'
+ end
- it "does not require padding" do
- Base64.urlsafe_decode64("MQ").should == "1"
+ it "does not require padding" do
+ Base64.urlsafe_decode64("MQ").should == "1"
+ end
end
end
diff --git a/spec/ruby/library/base64/urlsafe_encode64_spec.rb b/spec/ruby/library/base64/urlsafe_encode64_spec.rb
index de1f235cea..0c7b08757e 100644
--- a/spec/ruby/library/base64/urlsafe_encode64_spec.rb
+++ b/spec/ruby/library/base64/urlsafe_encode64_spec.rb
@@ -1,20 +1,23 @@
require_relative '../../spec_helper'
-require 'base64'
+ruby_version_is ""..."3.4" do
-describe "Base64#urlsafe_encode64" do
- it "uses '_' instead of '/'" do
- encoded = Base64.urlsafe_encode64('Where am I? Who am I? Am I? I?')
- encoded.should == "V2hlcmUgYW0gST8gV2hvIGFtIEk_IEFtIEk_IEk_"
- end
+ require 'base64'
- it "uses '-' instead of '+'" do
- encoded = Base64.urlsafe_encode64('"Being disintegrated makes me ve-ry an-gry!" <huff, huff>')
- encoded.should == 'IkJlaW5nIGRpc2ludGVncmF0ZWQgbWFrZXMgbWUgdmUtcnkgYW4tZ3J5ISIgPGh1ZmYsIGh1ZmY-'
- end
+ describe "Base64#urlsafe_encode64" do
+ it "uses '_' instead of '/'" do
+ encoded = Base64.urlsafe_encode64('Where am I? Who am I? Am I? I?')
+ encoded.should == "V2hlcmUgYW0gST8gV2hvIGFtIEk_IEFtIEk_IEk_"
+ end
+
+ it "uses '-' instead of '+'" do
+ encoded = Base64.urlsafe_encode64('"Being disintegrated makes me ve-ry an-gry!" <huff, huff>')
+ encoded.should == 'IkJlaW5nIGRpc2ludGVncmF0ZWQgbWFrZXMgbWUgdmUtcnkgYW4tZ3J5ISIgPGh1ZmYsIGh1ZmY-'
+ end
- it "makes padding optional" do
- Base64.urlsafe_encode64("1", padding: false).should == "MQ"
- Base64.urlsafe_encode64("1").should == "MQ=="
+ it "makes padding optional" do
+ Base64.urlsafe_encode64("1", padding: false).should == "MQ"
+ Base64.urlsafe_encode64("1").should == "MQ=="
+ end
end
end