Skip to content

Commit

Permalink
Merge pull request #72 from jrester/bucket_cmp
Browse files Browse the repository at this point in the history
Add ability to compare bucket name to string
  • Loading branch information
taylorfinnell authored Apr 9, 2020
2 parents f965c93 + 3438530 commit 48bb79a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions spec/awscr-s3/bucket_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 5 additions & 0 deletions src/awscr-s3/bucket.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 48bb79a

Please sign in to comment.