summaryrefslogtreecommitdiff
path: root/spec/ruby/core/array/pack/b_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/array/pack/b_spec.rb')
-rw-r--r--spec/ruby/core/array/pack/b_spec.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/spec/ruby/core/array/pack/b_spec.rb b/spec/ruby/core/array/pack/b_spec.rb
index 872c1b88d5..ec82b7d1ab 100644
--- a/spec/ruby/core/array/pack/b_spec.rb
+++ b/spec/ruby/core/array/pack/b_spec.rb
@@ -13,11 +13,16 @@ describe "Array#pack with format 'B'" do
it_behaves_like :array_pack_taint, 'B'
it "calls #to_str to convert an Object to a String" do
- obj = mock("pack H string")
+ obj = mock("pack B string")
obj.should_receive(:to_str).and_return("``abcdef")
[obj].pack("B*").should == "\x2a"
end
+ it "will not implicitly convert a number to a string" do
+ -> { [0].pack('B') }.should raise_error(TypeError)
+ -> { [0].pack('b') }.should raise_error(TypeError)
+ end
+
it "encodes one bit for each character starting with the most significant bit" do
[ [["0"], "\x00"],
[["1"], "\x80"]