Add spec to exercise numeric Enum deserialization

This commit is contained in:
Jamie Gaskins 2022-10-21 22:21:05 -04:00
parent b7a594e00a
commit a13f0f0f4e
3 changed files with 7 additions and 7 deletions

View file

@ -8,7 +8,7 @@ describe DB::Database do
db.setup_connection do |cnn| db.setup_connection do |cnn|
cnn_setup += 1 cnn_setup += 1
cnn.scalar("1").should eq "1" cnn.scalar("a").should eq "a"
end end
cnn_setup.should eq(2) cnn_setup.should eq(2)

View file

@ -187,7 +187,7 @@ class DummyDriver < DB::Driver
return (@statement.as(DummyStatement)).params[0] return (@statement.as(DummyStatement)).params[0]
end end
return n n.to_i64? || n
end end
def next_column_index : Int32 def next_column_index : Int32

View file

@ -90,10 +90,10 @@ struct ModelWithEnum
getter c2 : MyOtherEnum getter c2 : MyOtherEnum
enum MyEnum enum MyEnum
Foo Foo = 0
Bar Bar = 1
Baz Baz = 2
Quux Quux = 3
end end
enum MyOtherEnum enum MyOtherEnum
@ -196,7 +196,7 @@ describe "DB::Serializable" do
end end
it "should initialize a model with an enum property" do it "should initialize a model with an enum property" do
expect_model("1,Baz,LOL", ModelWithEnum, { expect_model("1,2,LOL", ModelWithEnum, {
c0: 1, c0: 1,
c1: ModelWithEnum::MyEnum::Baz, c1: ModelWithEnum::MyEnum::Baz,
c2: ModelWithEnum::MyOtherEnum::LOL, c2: ModelWithEnum::MyOtherEnum::LOL,