From 343853055c59e1e9dab8f7c6b3fd70e2e3b4f3ee Mon Sep 17 00:00:00 2001 From: Jrester Date: Fri, 27 Mar 2020 16:04:19 +0100 Subject: [PATCH] Add ability to compare bucket name to string modified: spec/awscr-s3/bucket_spec.cr modified: src/awscr-s3/bucket.cr --- spec/awscr-s3/bucket_spec.cr | 12 ++++++++++++ src/awscr-s3/bucket.cr | 5 +++++ 2 files changed, 17 insertions(+) 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