diff --git a/spec/awscr-s3/bucket_spec.cr b/spec/awscr-s3/bucket_spec.cr index abc3f30..1b35265 100644 --- a/spec/awscr-s3/bucket_spec.cr +++ b/spec/awscr-s3/bucket_spec.cr @@ -14,6 +14,18 @@ module Awscr::S3 (Bucket.new("test", Time.unix(Time.local.to_unix + 123)) == bucket).should eq(false) end + it "has the same name as the string provided" do + time = Time.local + bucket = Bucket.new("test3", time) + (bucket == "test3").should eq(true) + end + + it "has not the same name as the string provided" do + time = Time.local + bucket = Bucket.new("test4", time) + (bucket == "abcdef").should eq(false) + end + it "has a name" do bucket = Bucket.new("name", Time.local) diff --git a/src/awscr-s3/bucket.cr b/src/awscr-s3/bucket.cr index d36defb..9c3a994 100644 --- a/src/awscr-s3/bucket.cr +++ b/src/awscr-s3/bucket.cr @@ -13,6 +13,11 @@ module Awscr::S3 def initialize(@name : String, @creation_time : Time, @owner : String? = nil) end + # Compares the name of the bucket to other + def ==(other : String) + @name == other + end + def_equals @name, @creation_time end end