test/array_test.rb in bindata-2.4.15 vs test/array_test.rb in bindata-2.5.0
- old
+ new
@@ -16,21 +16,19 @@
_ { BinData::Array.new(args) }.must_raise ArgumentError
end
end
it "warns about :length" do
- Kernel.must_warn ":length is not used with BinData::Array. You probably want to change this to :initial_length" do
- obj = BinData::Array.new(type: :uint8, length: 3)
- obj.read "123"
- end
+ _ {
+ BinData::Array.new(type: :uint8, length: 3)
+ }.must_warn ":length is not used with BinData::Array. You probably want to change this to :initial_length"
end
it "warns about :read_length" do
- Kernel.must_warn ":read_length is not used with BinData::Array. You probably want to change this to :initial_length" do
- obj = BinData::Array.new(type: :uint8, read_length: 3)
- obj.read "123"
- end
+ _ {
+ BinData::Array.new(type: :uint8, read_length: 3)
+ }.must_warn ":read_length is not used with BinData::Array. You probably want to change this to :initial_length"
end
it "fails if a given type is unknown" do
args = {type: :does_not_exist, initial_length: 3}
_ { BinData::Array.new(args) }.must_raise BinData::UnRegisteredTypeError
@@ -68,9 +66,13 @@
_(obj.first(3)).must_equal []
end
it "returns [] for the last n elements" do
_(obj.last(3)).must_equal []
+ end
+
+ it "won't assign nil" do
+ _ { obj.assign(nil) }.must_raise ArgumentError
end
end
describe BinData::Array, "with several elements" do
let(:obj) {