spec/registry_spec.rb in bindata-1.1.0 vs spec/registry_spec.rb in bindata-1.2.0
- old
+ new
@@ -21,11 +21,13 @@
@r.is_registered?('a').should be_true
end
it "should determine if a name is not registered" do
- @r.is_registered?('xyz').should be_false
+ lambda {
+ @r.is_registered?('xyz')
+ }.should raise_error(BinData::UnRegisteredTypeError)
end
it "should lookup registered names" do
@r.register('ASubClass', A)
@r.register('AnotherSubClass', B)
@@ -33,11 +35,13 @@
@r.lookup('a_sub_class').should == A
@r.lookup('another_sub_class').should == B
end
it "should not lookup unregistered names" do
- @r.lookup('a_non_existent_sub_class').should be_nil
+ lambda {
+ @r.lookup('a_non_existent_sub_class')
+ }.should raise_error(BinData::UnRegisteredTypeError)
end
it "should allow overriding of registered classes" do
@r.register('A', A)
@r.register('A', B)
@@ -69,16 +73,24 @@
@r.lookup("uint24", :big).to_s.should == "BinData::Uint24be"
@r.lookup("uint24", :little).to_s.should == "BinData::Uint24le"
end
it "should not lookup integers without endian" do
- @r.lookup("int24").should be_nil
+ lambda {
+ @r.lookup("int24")
+ }.should raise_error(BinData::UnRegisteredTypeError)
end
it "should not lookup non byte based integers" do
- @r.lookup("int3").should be_nil
- @r.lookup("int3", :big).should be_nil
- @r.lookup("int3", :little).should be_nil
+ lambda {
+ @r.lookup("int3")
+ }.should raise_error(BinData::UnRegisteredTypeError)
+ lambda {
+ @r.lookup("int3", :big)
+ }.should raise_error(BinData::UnRegisteredTypeError)
+ lambda {
+ @r.lookup("int3", :little)
+ }.should raise_error(BinData::UnRegisteredTypeError)
end
it "should lookup floats with endian" do
@r.lookup("float", :big).to_s.should == "BinData::FloatBe"
@r.lookup("float", :little).to_s.should == "BinData::FloatLe"