diff options
Diffstat (limited to 'spec/ruby/core/encoding/converter')
7 files changed, 26 insertions, 26 deletions
diff --git a/spec/ruby/core/encoding/converter/asciicompat_encoding_spec.rb b/spec/ruby/core/encoding/converter/asciicompat_encoding_spec.rb index e39d590e3a..1beb40af3f 100644 --- a/spec/ruby/core/encoding/converter/asciicompat_encoding_spec.rb +++ b/spec/ruby/core/encoding/converter/asciicompat_encoding_spec.rb @@ -2,7 +2,7 @@ require_relative '../../../spec_helper' describe "Encoding::Converter.asciicompat_encoding" do it "accepts an encoding name as a String argument" do - lambda { Encoding::Converter.asciicompat_encoding('UTF-8') }. + -> { Encoding::Converter.asciicompat_encoding('UTF-8') }. should_not raise_error end diff --git a/spec/ruby/core/encoding/converter/convert_spec.rb b/spec/ruby/core/encoding/converter/convert_spec.rb index 362e027a58..95a9e0b758 100644 --- a/spec/ruby/core/encoding/converter/convert_spec.rb +++ b/spec/ruby/core/encoding/converter/convert_spec.rb @@ -33,13 +33,13 @@ describe "Encoding::Converter#convert" do it "raises UndefinedConversionError if the String contains characters invalid for the target encoding" do ec = Encoding::Converter.new('UTF-8', Encoding.find('macCyrillic')) - lambda { ec.convert("\u{6543}".force_encoding('UTF-8')) }.should \ + -> { ec.convert("\u{6543}".force_encoding('UTF-8')) }.should \ raise_error(Encoding::UndefinedConversionError) end it "raises an ArgumentError if called on a finished stream" do ec = Encoding::Converter.new('UTF-8', Encoding.find('macCyrillic')) ec.finish - lambda { ec.convert("\u{65}") }.should raise_error(ArgumentError) + -> { ec.convert("\u{65}") }.should raise_error(ArgumentError) end end diff --git a/spec/ruby/core/encoding/converter/new_spec.rb b/spec/ruby/core/encoding/converter/new_spec.rb index 6b9c76a093..6a6343012c 100644 --- a/spec/ruby/core/encoding/converter/new_spec.rb +++ b/spec/ruby/core/encoding/converter/new_spec.rb @@ -23,7 +23,7 @@ describe "Encoding::Converter.new" do end it "raises an Encoding::ConverterNotFoundError if both encodings are the same" do - lambda do + -> do Encoding::Converter.new "utf-8", "utf-8" end.should raise_error(Encoding::ConverterNotFoundError) end @@ -65,25 +65,25 @@ describe "Encoding::Converter.new" do obj = mock("encoding converter replacement") obj.should_receive(:to_str).and_return(1) - lambda do + -> do Encoding::Converter.new("us-ascii", "utf-8", replace: obj) end.should raise_error(TypeError) end it "raises a TypeError if passed true for the replacement object" do - lambda do + -> do Encoding::Converter.new("us-ascii", "utf-8", replace: true) end.should raise_error(TypeError) end it "raises a TypeError if passed false for the replacement object" do - lambda do + -> do Encoding::Converter.new("us-ascii", "utf-8", replace: false) end.should raise_error(TypeError) end it "raises a TypeError if passed a Fixnum for the replacement object" do - lambda do + -> do Encoding::Converter.new("us-ascii", "utf-8", replace: 1) end.should raise_error(TypeError) end diff --git a/spec/ruby/core/encoding/converter/primitive_convert_spec.rb b/spec/ruby/core/encoding/converter/primitive_convert_spec.rb index 710cc262bb..4a22606375 100644 --- a/spec/ruby/core/encoding/converter/primitive_convert_spec.rb +++ b/spec/ruby/core/encoding/converter/primitive_convert_spec.rb @@ -7,19 +7,19 @@ describe "Encoding::Converter#primitive_convert" do end it "accepts a nil source buffer" do - lambda { @ec.primitive_convert(nil,"") }.should_not raise_error + -> { @ec.primitive_convert(nil,"") }.should_not raise_error end it "accepts a String as the source buffer" do - lambda { @ec.primitive_convert("","") }.should_not raise_error + -> { @ec.primitive_convert("","") }.should_not raise_error end it "accepts nil for the destination byte offset" do - lambda { @ec.primitive_convert("","", nil) }.should_not raise_error + -> { @ec.primitive_convert("","", nil) }.should_not raise_error end it "accepts an integer for the destination byte offset" do - lambda { @ec.primitive_convert("","a", 1) }.should_not raise_error + -> { @ec.primitive_convert("","a", 1) }.should_not raise_error end it "calls #to_int to convert the destination byte offset" do @@ -30,10 +30,10 @@ describe "Encoding::Converter#primitive_convert" do end it "raises an ArgumentError if the destination byte offset is greater than the bytesize of the destination buffer" do - lambda { @ec.primitive_convert("","am", 0) }.should_not raise_error - lambda { @ec.primitive_convert("","am", 1) }.should_not raise_error - lambda { @ec.primitive_convert("","am", 2) }.should_not raise_error - lambda { @ec.primitive_convert("","am", 3) }.should raise_error(ArgumentError) + -> { @ec.primitive_convert("","am", 0) }.should_not raise_error + -> { @ec.primitive_convert("","am", 1) }.should_not raise_error + -> { @ec.primitive_convert("","am", 2) }.should_not raise_error + -> { @ec.primitive_convert("","am", 3) }.should raise_error(ArgumentError) end it "uses the destination byte offset to determine where to write the result in the destination buffer" do @@ -49,19 +49,19 @@ describe "Encoding::Converter#primitive_convert" do end it "accepts nil for the destination bytesize" do - lambda { @ec.primitive_convert("","", nil, nil) }.should_not raise_error + -> { @ec.primitive_convert("","", nil, nil) }.should_not raise_error end it "accepts an integer for the destination bytesize" do - lambda { @ec.primitive_convert("","", nil, 0) }.should_not raise_error + -> { @ec.primitive_convert("","", nil, 0) }.should_not raise_error end it "allows a destination bytesize value greater than the bytesize of the source buffer" do - lambda { @ec.primitive_convert("am","", nil, 3) }.should_not raise_error + -> { @ec.primitive_convert("am","", nil, 3) }.should_not raise_error end it "allows a destination bytesize value less than the bytesize of the source buffer" do - lambda { @ec.primitive_convert("am","", nil, 1) }.should_not raise_error + -> { @ec.primitive_convert("am","", nil, 1) }.should_not raise_error end it "calls #to_int to convert the destination byte size" do diff --git a/spec/ruby/core/encoding/converter/primitive_errinfo_spec.rb b/spec/ruby/core/encoding/converter/primitive_errinfo_spec.rb index e0a5378155..1f836b259f 100644 --- a/spec/ruby/core/encoding/converter/primitive_errinfo_spec.rb +++ b/spec/ruby/core/encoding/converter/primitive_errinfo_spec.rb @@ -54,7 +54,7 @@ describe "Encoding::Converter#primitive_errinfo" do it "returns the state, source encoding, target encoding, erroneous bytes, and the read-again bytes when #convert last raised InvalidByteSequenceError" do ec = Encoding::Converter.new("utf-8", "iso-8859-1") - lambda { ec.convert("\xf1abcd") }.should raise_error(Encoding::InvalidByteSequenceError) + -> { ec.convert("\xf1abcd") }.should raise_error(Encoding::InvalidByteSequenceError) ec.primitive_errinfo.should == [:invalid_byte_sequence, "UTF-8", "ISO-8859-1", "\xF1", "a"] end @@ -62,7 +62,7 @@ describe "Encoding::Converter#primitive_errinfo" do it "returns the state, source encoding, target encoding, erroneous bytes, and the read-again bytes when #finish last raised InvalidByteSequenceError" do ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") ec.convert("\xa4") - lambda { ec.finish }.should raise_error(Encoding::InvalidByteSequenceError) + -> { ec.finish }.should raise_error(Encoding::InvalidByteSequenceError) ec.primitive_errinfo.should == [:incomplete_input, "EUC-JP", "UTF-8", "\xA4", ""] end end diff --git a/spec/ruby/core/encoding/converter/replacement_spec.rb b/spec/ruby/core/encoding/converter/replacement_spec.rb index a23be74e9b..5ca42e7e5a 100644 --- a/spec/ruby/core/encoding/converter/replacement_spec.rb +++ b/spec/ruby/core/encoding/converter/replacement_spec.rb @@ -33,7 +33,7 @@ describe "Encoding::Converter#replacement=" do it "raises a TypeError if assigned a non-String argument" do ec = Encoding::Converter.new("utf-8", "us-ascii") - lambda { ec.replacement = nil }.should raise_error(TypeError) + -> { ec.replacement = nil }.should raise_error(TypeError) end it "sets #replacement" do @@ -47,7 +47,7 @@ describe "Encoding::Converter#replacement=" do ec = Encoding::Converter.new("sjis", "ascii") utf8_q = "\u{986}".force_encoding('utf-8') ec.primitive_convert(utf8_q.dup, "").should == :undefined_conversion - lambda { ec.replacement = utf8_q }.should \ + -> { ec.replacement = utf8_q }.should \ raise_error(Encoding::UndefinedConversionError) end @@ -55,7 +55,7 @@ describe "Encoding::Converter#replacement=" do ec = Encoding::Converter.new("sjis", "ascii") utf8_q = "\u{986}".force_encoding('utf-8') ec.primitive_convert(utf8_q.dup, "").should == :undefined_conversion - lambda { ec.replacement = utf8_q }.should \ + -> { ec.replacement = utf8_q }.should \ raise_error(Encoding::UndefinedConversionError) ec.replacement.should == "?".force_encoding('us-ascii') end diff --git a/spec/ruby/core/encoding/converter/search_convpath_spec.rb b/spec/ruby/core/encoding/converter/search_convpath_spec.rb index bd7530405b..0535e7bdc3 100644 --- a/spec/ruby/core/encoding/converter/search_convpath_spec.rb +++ b/spec/ruby/core/encoding/converter/search_convpath_spec.rb @@ -25,7 +25,7 @@ describe "Encoding::Converter.search_convpath" do end it "raises an Encoding::ConverterNotFoundError if no conversion path exists" do - lambda do + -> do Encoding::Converter.search_convpath(Encoding::BINARY, Encoding::Emacs_Mule) end.should raise_error(Encoding::ConverterNotFoundError) end |