From a13f0f0f4e69b66f67140b953996f7850f779ea4 Mon Sep 17 00:00:00 2001 From: Jamie Gaskins Date: Fri, 21 Oct 2022 22:21:05 -0400 Subject: [PATCH] Add spec to exercise numeric Enum deserialization --- spec/database_spec.cr | 2 +- spec/dummy_driver.cr | 2 +- spec/serializable_spec.cr | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/database_spec.cr b/spec/database_spec.cr index 31db8bd..8371d57 100644 --- a/spec/database_spec.cr +++ b/spec/database_spec.cr @@ -8,7 +8,7 @@ describe DB::Database do db.setup_connection do |cnn| cnn_setup += 1 - cnn.scalar("1").should eq "1" + cnn.scalar("a").should eq "a" end cnn_setup.should eq(2) diff --git a/spec/dummy_driver.cr b/spec/dummy_driver.cr index aa40790..994eeaf 100644 --- a/spec/dummy_driver.cr +++ b/spec/dummy_driver.cr @@ -187,7 +187,7 @@ class DummyDriver < DB::Driver return (@statement.as(DummyStatement)).params[0] end - return n + n.to_i64? || n end def next_column_index : Int32 diff --git a/spec/serializable_spec.cr b/spec/serializable_spec.cr index 89fed0e..4ad2cf9 100644 --- a/spec/serializable_spec.cr +++ b/spec/serializable_spec.cr @@ -90,10 +90,10 @@ struct ModelWithEnum getter c2 : MyOtherEnum enum MyEnum - Foo - Bar - Baz - Quux + Foo = 0 + Bar = 1 + Baz = 2 + Quux = 3 end enum MyOtherEnum @@ -196,7 +196,7 @@ describe "DB::Serializable" do end it "should initialize a model with an enum property" do - expect_model("1,Baz,LOL", ModelWithEnum, { + expect_model("1,2,LOL", ModelWithEnum, { c0: 1, c1: ModelWithEnum::MyEnum::Baz, c2: ModelWithEnum::MyOtherEnum::LOL,